I am just starting out with Home Assistant but want to do it correct from the start to avoid lots of unnecessary automations that will clog up my system.
I currently have 2 automatons set up to turn off my kitchen lights. first automation turns them off a 7pm on Wednesday, Saturday and Sunday. The second automation turns off the same lights at 7:30pm on Monday, Tuesday, Thursday and Friday
alias: Kitchen Diner Lights Off Wed/Sat/Sun
description: ""
trigger:
- platform: time
at: "19:00:00"
condition:
- condition: time
weekday:
- wed
- sat
- sun
action:
- service: light.turn_off
data: {}
target:
device_id:
- 3b9f8e36f9fed64f4c0826a40fa99d14
- cf06f537fc927526a7015ece0971fbbb
mode: single
The 2 automations are above but this seems like a lot of code just to turn lights off at different times on different days. I have tried to copy code from a different post and wondered if the below would work.
- id: Kitchen Diner Lights off
alias: 'Kitchen Diner Lights off'
trigger:
- platform: time
at: '19:00:00'
action:
- delay: "{{ '00:00:00' if now().weekday() in (0,1,3,4) else '00:30:00' }}"
- service: light.turn_off
data: {}
target:
device_id:
- 3b9f8e36f9fed64f4c0826a40fa99d14
- cf06f537fc927526a7015ece0971fbbb