this post was submitted on 05 Feb 2024
17 points (100.0% liked)
homeassistant
15748 readers
7 users here now
Home Assistant is open source home automation that puts local control and privacy first.
Powered by a worldwide community of tinkerers and DIY enthusiasts.
Home Assistant can be self-installed on ProxMox, Raspberry Pi, or even purchased pre-installed: Home Assistant: Installation
Discussion of Home-Assistant adjacent topics is absolutely fine, within reason.
If you're not sure, DM @GreatAlbatross@feddit.uk
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
This is a great case for templates. Templates are Home Assistant's way of doing dynamic actions or data.
When: whatever triggers you need for the lights - can be multiple triggers or one trigger with every light/switch listed, with a For clause. The list is "OR"ed so do however you want. You could use a group but then all devices would be changed together - which doesn't sound like is what you want.
And if: Whatever conditions you want, time, day of week, etc.
Then do: The action is where it gets interesting add an action to execute "Generic turn off", select any device (we'll change that in a moment). The reason for the "Generic turn off" is that it works with devices in any domain (light or switch). Then drop into the YAML view and chcange the entity_id value to this template:
'{{ trigger.from_state.entity_id }}'
. The trigger is a variable that's available inside the automation and can be used instead of specifying a static value somewhere. https://www.home-assistant.io/docs/automation/trigger/ for details on triggers.Here's the complete automation, you could create a new empty automation, then copy and paste this in place and just change the trigger and conditions as you want.