renemarc/home-assistant-config

View on GitHub
automations/devices/nightlight_off.yaml

Summary

Maintainability
Test Coverage
#
# Turn off nightlights when no longer needed
#
# Todo: split this into area-managed automations.
# Todo: use an OFF timer instead of relying on motion detectors.
#
# @subscribe group.motion_sensors_critical
# @subscribe input_boolean.night_mode
#
- id: nightlight_off
  alias: "Nightlight OFF"
  initial_state: 'off'

  trigger:
    # Motion no longer detected.
    - platform: state
      entity_id: group.motion_sensors_critical
      to: 'off'

  condition:
    # If it's during the night mode.
    - condition: state
      entity_id: input_boolean.night_mode
      state: 'on'

  action:
    # Turn night lights off.
    - service: light.turn_off
      data:
        entity_id:
          - group.lifx_lights
        transition: 10

    # Disable dedicated kitchen night lights effect.
    - service: homeassistant.turn_off
      data:
        entity_id:
          - group.kitchen_lights

    # Turn off kiosk.
    - service: homeassistant.turn_off
      data:
        entity_id:
          - display.kiosk