renemarc/home-assistant-config

View on GitHub
automations/devices/nightlight_on.yaml

Summary

Maintainability
Test Coverage
#
# Turn on nightlights when appropriate
#
# Todo: split this into area-managed automations.
#
# @subscribe group.motion_sensors_critical
# @subscribe input_boolean.night_mode
#
- id: nightlight_on
  alias: "Nightlight ON"
  initial_state: 'off'

  trigger:
    # When motion is detected.
    - platform: state
      entity_id: group.motion_sensors_critical
      to: 'on'

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

  action:
    # Turn night lights on.
    - service: light.turn_on
      data:
        entity_id:
          - group.lifx_lights
        brightness_pct: 8
        transition: 5

    # Enable dedicated kitchen night lights effect.
    - service: homeassistant.turn_on
      data:
        entity_id:
          - group.kitchen_lights
        effect: 'night'