Did you detect this behavior with or without the early_pin_init
setting?
- early_pin_init (Optional, boolean): Specifies whether pins should be initialized as early as possible to known values. Recommended value is
false
where switches are involved, as these will toggle when updating the firmware or when restarting the device. Defaults totrue
.
Did you dig in deeper here already? Logs, bug report etc.?
I had this config in the past for a “always on” switch with “reset” function. It’s not possible to turn the switch off (not exposed) but only to “reset” it (turns off the relay, waits 20 seconds, turns the relay on again).
Never had problems that the device had the load off at some point (early_pin_init
is default on
)
esphome:
platform: ESP8266
board: esp01_1m
name: ...
on_boot:
priority: -100
then:
- delay: 10s
- switch.turn_on: relay
switch:
- platform: gpio
pin: ...
id: relay
on_turn_on:
then:
- binary_sensor.template.publish:
id: relay_state
state: ON
on_turn_off:
then:
- binary_sensor.template.publish:
id: relay_state
state: OFF
binary_sensor:
- platform: template
name: "Relay State"
id: relay_state
button:
- platform: template
name: "Relay Load Reset (20s)"
on_press:
then:
- switch.turn_off: relay
- delay: 20s
- switch.turn_on: relay