porch_light.yaml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. switch:
  2. - platform: group
  3. name: "Entrance: Porch light"
  4. entities:
  5. - switch.entrance_porch_light_1
  6. - switch.entrance_porch_light_4
  7. light:
  8. - platform: template
  9. lights:
  10. entrance_porch_light:
  11. friendly_name: "Entrance: Porch light"
  12. turn_on:
  13. service: switch.turn_on
  14. entity_id: switch.entrance_porch_light
  15. turn_off:
  16. service: switch.turn_off
  17. entity_id: switch.entrance_porch_light
  18. value_template: >-
  19. {{ false if is_state('switch.entrance_porch_light', 'unknown') else states('switch.entrance_porch_light') }}
  20. availability_template: >-
  21. {{ not is_state('switch.entrance_porch_light', 'unavailable') }}
  22. automation:
  23. - id: entrance_switch_on_off_porch_light
  24. alias: "Entrance: Switch on/off porch light"
  25. trigger:
  26. - platform: state
  27. entity_id: sensor.period_of_day
  28. - platform: homeassistant
  29. event: start
  30. action:
  31. - wait_template: "{{ not is_state('light.entrance_porch_light', 'unavailable') }}"
  32. - if: "{{ is_state('sensor.period_of_day', 'day') }}"
  33. then:
  34. service: light.turn_off
  35. entity_id: light.entrance_porch_light
  36. else:
  37. service: light.turn_on
  38. entity_id: light.entrance_porch_light