How to handle unavailable entities (prescriptive state)

Hi all,
I’m using Home Assistant with good success in general and a number of HomeMatic and ZigBee devices (lights and switches) in particular. These are connected via their respective bridges.
Now, since I retrofitted them in my apartment, they are sometimes behind other switches, some of which are “smart” and others which are just dumb physical ones.
That by itself isn’t a problem, but I can’t properly set the state for them. At best, their power on behaviour will be to restart their previous settings. They aren’t being set to their should state. They’ve missed all scene/automation updates.

I understand why - HA sets the state for devices directly, and can’t set them for unavailable ones.

What I’d like to achieve is to set their target state, regardless of whether they were unavailable or not.

Now, what I also don’t want is for entities that were available but that I’ve explicitly set since their last update. (Think: a wall switch that I’ve turned off since the last scene turned it on, or somesuch.) So it’s not a simple “override always with prescriptive state”. More of a “queue last target state for unavailable entities”.

Has someone already done this, or do I need to write some code? Is there, perhaps, a native method in HA to achieve this that I’ve missed?

Thanks!

There’s no native method unfortunately.

I’ve used automations that check for the device going from: 'unavailable' and then checking whether the light should be on or off. That works for me since I use “modes” that define what the state of the room should be, so I know that if the room is “Dim” then certain things should be on, and others should be off.

Thanks, might have to look at a more generic layer then - wondering if I should either do a proxy_switch and proxy_light component which acts as a such an intermediary or whether those might be more sensibly added as queue_if_unavailable options to switch/light?