-
-
Notifications
You must be signed in to change notification settings - Fork 39
How to retain states after reboot #240
Description
Operating environment/Installation (Hass.io/Docker/pip/etc.):
Home Assistant, Hass.io and ESPHome with Sonoff
ESP (ESP32/ESP8266, Board/Sonoff):
Using a Sonoff 4Ch pro r2, basic config
Affected component:
https://esphome.io/devices/sonoff_4ch.html
Description of problem:
When the Sonoff has been rebooted in HA the device (and switches etc) become unavailbe until it gets back online.
When it gets back online, all states are returned to default (relays off, blue led off).
during the downtime the states become 'unavailable' so i think that's were it fails.
Would it be possible to keep the states until the device gets back online, and then update the states if the uptime of the device is more then - lets say - 5 minutes from the device (maybe some interaction was done on the device.
If the uptime is less then those 5 minutes keep the states.
on the other hand, when the device boots it should look at the states and use them to set the pins etc after a reboot.
Problem-relevant YAML-configuration entries:
PASTE YAML FILE HERE
esphome:
name: sonoff_4pro_1
platform: ESP8266
board: esp01_1m
web_server:
port: 80
wifi:
ssid: "10"
password: ""
manual_ip:
static_ip: 192.168.178.17
gateway: 192.168.178.1
subnet: 255.255.255.0
dns1: 192.168.178.1
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff 4pro1 Button 1"
on_press:
then:
- switch.toggle: sonoff4pro1r1
- platform: gpio
pin:
number: GPIO9
mode: INPUT_PULLUP
inverted: True
name: "Sonoff 4pro1 Button 2"
- platform: gpio
pin:
number: GPIO10
mode: INPUT_PULLUP
inverted: True
name: "Sonoff 4pro1 Button 3"
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: True
name: "Sonoff 4pro1 Button 4"
- platform: status
name: "Sonoff 4pro1 Status"
switch:
- platform: gpio
name: "Sonoff 4pro1 Relay 1"
pin: GPIO12
id: sonoff4pro1r1
- platform: gpio
name: "Sonoff 4pro1 Relay 2"
pin: GPIO5
- platform: gpio
name: "Sonoff 4pro1 Relay 3"
pin: GPIO4
- platform: gpio
name: "Sonoff 4pro1 Relay 4"
pin: GPIO15
output:
# Register the blue LED as a dimmable output ....
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
light:
# ... and then make a light out of it.
- platform: monochromatic
name: "Sonoff 4pro1 Blue LED"
output: blue_led
debug:
# Enable logging
logger:
level: debug
# Enable Home Assistant API
api:
password: ''
ota:
password: ''
Traceback (if applicable):
Additional information and things you've tried: