Hi, I’m using a shelly behind a wall switch to catch the button pushes and send to home-assistant. The connected light is a zigbee light that should always have power.
I notice that on reboot of the shelly, the relay toggles and this causes the light to go on. This happened now at night when the wifi went offline for a bit. This is a problem I’m looking into but into, but I’m also trying to not toggle the relay on reboot.
I already enabled these settings:
reboot_timeout: 60min, will make it less sensitive to shorter wifi outagesesp8266: early_pin_init: falseaccording to the documentation: Specifies whether pins should be initialised as early as possible to known values. Recommended value isfalsewhere switches are involved, as these will toggle when updating the firmware or when restarting the device. Defaults totrue.switch: restore_mode: ALWAYS_ON→ Should keep it on during reboot?
Currently testing by updating the configuration and triggering a restart via home assistant and obseverving the light status.
This is my configuration:
substitutions:
devicename: "bedroom_wall_switch"
upper_devicename: "Bedroom wall switch"
device_group: "bedroom"
manual_ip: "192.168.0.242"
multiclick_GPIO: GPIO5
multiclick_relay_for_offline: relay
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_passwd
manual_ip:
# Set this to the IP of the ESP
static_ip: $manual_ip
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.0.1
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: $upper_devicename
password: !secret access_mode_passwd
# No power saving
power_save_mode: none
# Only reboot after 1h
reboot_timeout: 60min
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
# OTA updates:
ota:
- platform: esphome
# ESP:
esphome:
name: $devicename
# Enable the relay at boot:
#on_boot:
# then:
# - switch.turn_on: relay
esp8266:
board: esp01_1m
early_pin_init: false
switch:
# Relais:
- platform: gpio
name: Relay
pin: GPIO4
id: ${multiclick_relay_for_offline}
restore_mode: ALWAYS_ON
# Trigger restart
- platform: restart
name: Restart
# Event configuration
event:
- platform: template
id: button_press_events
name: button press events
event_types:
- "single_click"
- "double_click"
- "hold"
binary_sensor:
# Multi-click sensor:
- platform: gpio
pin:
number: ${multiclick_GPIO}
name: switch_sensor
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.1s
then:
- logger.log: "Double Clicked"
- event.trigger:
id: button_press_events
event_type: double_click
- delay: 3s
- timing:
- ON for at least 1s
then:
- while:
condition:
binary_sensor.is_on: switchid
then:
- logger.log: "Hold"
- event.trigger:
id: button_press_events
event_type: hold
- delay: 3s
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- if:
condition:
and:
- wifi.connected:
- api.connected:
then:
- logger.log: "Single Short Clicked"
- event.trigger:
id: button_press_events
event_type: single_click
- delay: 3s
else:
- logger.log: "Toggling relay because the device is offline"
- switch.toggle: ${multiclick_relay_for_offline}
internal: false
id: switchid
# Status sensor:
- platform: status
name: Status