renemarc/home-assistant-config

View on GitHub
automations/devices/bed_select.yaml

Summary

Maintainability
Test Coverage
#
# Manually select a LIFX cloud effect for the bed underglow lights
#
# @subscribe input_select.bed_effect
#
# @publish variable.bed_effect
#
# @see /scenes/lifx_cloud.yaml
#
- id: bed_select
  alias: "Bed SELECT"

  trigger:
    # When an effect has been selected.
    - platform: state
      entity_id: input_select.bed_effect

    # When an item which was off comes back online.
    - platform: state
      entity_id:
        - light.headboard
        - light.underbed
      to: 'on'

  condition:
    # If an actual effect is selected, not the default.
    - condition: template
      value_template: >-
        {{ not is_state('input_select.bed_effect', 'Auto') }}

  action:
    # Update the bed effect variable.
    - service: variable.set_variable
      data:
        variable: bed_effect
        value_template: >-
          {{ states('input_select.bed_effect') }}