I made Layers: automations can borrow a light and give it back, without scene snapshots

I kept running into the same problem: an automation dims the lights for a film, another one flashes a lamp for a notification, and restoring afterwards with scene.create breaks all the time. The snapshot is gone after a restart, the restore undoes what someone changed in the meantime, and two automations restore each other’s leftovers.

So I built Layers, a custom integration (HACS). Each automation puts a layer on a light and removes it when it’s done. The light always shows the top layer, and removing it shows whatever is underneath now, not a saved copy.

Example: the film turns the sofa lamp off (priority 40), and the washer finishing turns it orange (priority 70). Empty the washer and the lamp goes back to off, because the film is still on. When the film ends, it goes back to how you had it.

  • People always win: switch a light by hand and Layers leaves that light alone
  • Survives restarts; checks commands actually arrived and retries
  • A timer running out never lights up a dark room
  • Blueprint included for “dim the room while the TV plays”
  • Starts in watch-only mode, so you can see what it would do first

It’s v0.1.0 and has been running in my house for about ten days. I’d really like feedback, especially on how it should behave when someone changes a light by hand.

4 Likes

This looks interesting. There’s another similar integration (topic here) that looks to address the same problem in a similar manner. I haven’t tried that one either, but now I’m putting both on my list to try out when I get some time.

Yeah, they’re quite similar. I think ha-priority is more straightforward: it works with your existing automations as they are. Layers has its own actions, so you’d need to update the automations you want it to manage, but in return it’s a bit more flexible. For example, a layer can just dim a light and keep whatever colour is underneath, and you can choose per light what happens when someone changes it by hand. Right now Layers only does lights and switches (plugs, relays). If there’s interest I can add heating and other things too. Also credit where it’s due. ha-priority was a big part of the inspo for my project.

1 Like

This is rather interesting. I’m assuming it only works for light entities at the moment?

I have scenes for saving/restoring state on media players since I have alerts that play TTS so they take over and adjust volume, play, and then restore. The scene is short lived, but I have never liked the tediousness of having to save/restore the state - always felt like there should be a simpler way.

I didn’t even know anyone was using my integration, much less that it might’ve been inspiring people to make their own flavor. :slight_smile:

There are a couple of things I don’t understand.

Go to Settings → Devices & services → Add integration → Layers and pick the lights it should manage. Switches (smart plugs, relays) work too, as on/off lights.

So, do I need to specify all the entities that the integration will manage? And will it manage only those?
Or is any entity (even an empty one) sufficient here, and is this simply required to register the services? And the integration will manage them all.