I tried to build a simple system to periodically turn on and off a relay connected to a switch for heater.
It had worked for 2 or 3 hours without any problem.
3 hours later, it seems that the ESPhome device was frozen at a certain state.
LED indicating relay ON (blue led) was turned on, and the heater was also turned on during long time.
The ESPHome device lost the connection with HomeAsistant.
According to the log in HomeAssistant,
- 11:40:53 Switch turn on trigger by automation
No turned-off on 11:43:53 - 11:45:23 Switch became unavailable
no response anymore
I got an advice to use “interval component” instead of “delay”.
I could re-implement my code, but I’d like to know the reason why my system was frozen in current code.
I worried about that the ESPHome device was out of control.
It could loss the connections with HomeAssistant, but it should be connected again.
Moreover, “on_turn_on” in ESPHome device was jumped over.
Is there any possibility that my code caused this situation?
According to HA log, there were lot of “became unavailable” records.
But, in all cases except the above one, HA got the control of ESPHome again.
Automation code and ESPhome code
alias: SpaceHeating
description: ""
trigger:
- platform: state
entity_id:
- switch.heater
from: "off"
to: "on"
condition: []
action:
- repeat:
until:
- condition: state
entity_id: switch.heater
state: "off"
sequence:
- if:
- condition: state
entity_id: switch.first_heater
state: "on"
then:
- service: switch.turn_on
data: {}
target:
entity_id: switch.first_floor_heater_switch
- delay:
hours: 0
minutes: 30
seconds: 0
milliseconds: 0
mode: restart
ESPCode
switch:
- platform: gpio
id: relay
pin:
number: 0
inverted: true
name: "switch"
on_turn_on:
- delay: 180s
- switch.turn_off: relay