I use an automation to turn on a hot water circulation system. It turns on the switch for 2 minutes, then turns it off.
Recently I noted in the log a series of episodes where the OFF command was ignored because the switch became “unavailable.” The reason for this is unknown.
I am now creating a companion “safety check” automation for these occurances. It would notify me when the switch goes offline/unavailable, and then send repeated OFF instructions to the switch, so that when it comes back online, it does not remain ON.
Here’s the code thus far:
alias: Hot water switch offline ALERT
description: ""
triggers:
- trigger: state
entity_id:
- switch.hot_water_localtuya_switch_1
from: null
to: unavailable
conditions: []
actions:
- action: notify.mobile_app_pixel_9
metadata: {}
data:
message: Hot water switch OFFLINE?!?! Initiating flurry of OFF
- repeat:
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.hot_water_localtuya_switch_1
until:
- condition: state
entity_id: switch.hot_water_localtuya_switch_1
state: "off"
mode: single
What would be the frequency of these OFF attempts in its current code? I was thinking I should probably put a delay between these requests. Would I simply insert a delay command after the OFF command?
Thanks for the replies. I’ll put in a 15s delay, so it’ll try 4x/minute to turn off the switch.
Appreciate the questions re: equipment failure.
I’ve tried to put in as many safeguards as possible, but thinking about this, I could do more.
If the switch fails to DEactivate, hot water gets pushed through my plumbling via a pump indefinitely. It just means all the water in my plumbing will eventually get warm. This automation only activates when I am physically at home. But it would go unnoticed until I turn on the water tap.
Obviously, the smart switch depends on wifi access and power. My HA Green is connected to a UPS, and the same as with the router. The failure point that spurred this discussion looks like two transient losses of wifi connectivity.
Currently, HA sends the ON, waits 2 minutes, then sends the OFF. This necessitates HA doesn’t “forget,” and that the switch can receive the OFF command.
This is a Tuya/Smartthings capable switch. In the past I used a “scene” within Tuya that included a simple on + timer + off. I do not know if the switch requires a wifi connection to complete the scene once activated (commands ON then OFF sent via Tuya’s server), or if the circuitry within the switch can contain the full instructions independent of wifi connectivity. If it is the latter, it would then be best to activate that Tuya scene from Home Assistant and let the Tuya server start the cycle. I have been moving away from Tuya to Localtuya, hence the move away from Tuya-dependent activities.