#Automation that ensures a target entity's state is updated, regardless of momentary unavailability

9 messages · Page 1 of 1 (latest)

full elm
#

I think there is a well-established way to have a trigger pick up when the state of entity A changes, including cleanly handling if entity A is temporarily unavailable or a restart of HA causes it to be so, (e.g., trigger when some state on entity A changes to value "foo", unless coming from an unavailable state) and then resulting in an action on entity B (e.g., call the "set config value X to value 'bar'" on entity B).

However, I do not think there is a well-established way to ensure the action occurs eventually on entity B if entity B is unavailable, or if some service call to entity B failed, etc. For example, say I want to ensure that a lightbulb turns on when the dishwasher stops. I can trigger on the state of the dishwasher changing to "stopped" and have the "turn on" service call target the lightbulb. But what if the lighbulb is unavailable during the trigger firing? Or put another way, let's say I want the lightbulb to be forced to be turned on, even if somebody comes along and turns the bulb off, or if the bulb is disconnected from the network and then reconnected later in an "off" state, until the dishwasher is no longer in the "stopped" state -- i.e., essentially have HA govern the direct linkage of the dishwasher's "stopped" state and the lightbulb's "on" state.

Is this kind of thing possible without significant custom automation involving polling-and-checking the lightbulb's state to see if it's still in the desired "on" state? Surely there is something more elegant and repeatable... or no?

#

Automation that ensures a target entity's state is updated, regardless of momentary unavailability

median cloak
#

You can do all of this in a couple of automations. So, forcing the light on when it’s state is in “off” or “unavailable” is a simple automation that could have a condition of the dishwasher’s state. The other one is that if the light is unavailable when the dishwasher hits whatever state you want to target can be done with an if block. Check the state of the light, if it’s unavailable, use a wait_for_trigger to turn on the light once it becomes available again.

full elm
#

I don't think this quite solves it. First, if the light appears to be available to HA, but a network failure causes it to not receive the message after all, then it won't turn on and won't hit the "unavailable" conditional. Second, if somebody came along to turn the light off, nothing would turn it back on.

I think the requirement is a two-way linkage which checks both states at all times and fires actions based on the two states in tandem...?

#

Hmm maybe I have just talked myself into the solution...

Two triggers. First trigger checks dishwasher state for transition to "stopped" while light is "off." Second trigger checks for light transitioning to "off" while dishwasher state is "stopped." If either trigger occurs, turn light on.

That sound right or am I missing something?

#

Doesn't it feel like there should be a Helper for this kind of linkage?

full elm
sharp slate
#

could use a repeat building block:
something like:

repeat until light = on
set light on
delay 5 seconds

its pretty dirty but would try and turn the light on every 5 seconds until it succeeds.

median cloak