this post was submitted on 06 May 2025
14 points (93.8% liked)

homeassistant

14104 readers
36 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. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 2 years ago
MODERATORS
 

I currently have a lot of my light automations setup by first having an automation that turns the light on at a certain time, then another that turns the light off at another time. This works, and it has for years, but I'm imagining there must be blueprints or other methods to do this on/ off behavior in a single automation rather than having them in pairs (this is not scaling very well).

Anyone have suggestions? The image is a blueprint I have for turning lights on/ off based on a time window which is very handy, and I'm hoping there's something similar out there for my needs.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] vk6flab@lemmy.radio 6 points 12 hours ago (1 children)

Before you start consolidating, consider what might happen if the switch is in an unexpected state. For example, someone turned off the heater or pump and you were expecting it to be on.

In other words, you need to consider what a "safe state" is for each thing and how your code, when it fails, reverts to that state. This is an example of "failsafe".

Note that I said "when it fails". This is true for all software, even on mission critical systems.

Source: I write software for a living.

[โ€“] root@lemmy.world 1 points 10 hours ago* (last edited 10 hours ago)

Yes, definitely. That's one of the reasons I've implemented this way. If a light (for example) had the physical switch turned off and back on, a lot of smart bulbs will go to the on state, even if HA had previously set (and expects it to be) off. The next execution may turn it off in an off state, on in an on state, on from an off state or off from an on state, but either way that truth table will resolve after an iteration