I am having a problem with a relatively basic ESPHome program for my garage door.
I have a RGB LED to indicate if the door is open/closed based on a reed sensor.
My problem is that after a power interruption, the LED is totally off until I cycle the door to open/closed.
I am trying to use the Restore from flash command, but still not working.
Very grateful for any help.
esphome:
name: testy
platform: ESP8266
board: nodemcuv2
esp8266_restore_from_flash : True
light:
- platform: rgb
name: "RGB LED"
red: output_red
green: output_green
blue: output_blue
output:
- platform: esp8266_pwm
id: output_red
pin: D5
- platform: esp8266_pwm
id: output_green
pin: D7
restore_mode: RESTORE_DEFAULT_ON
- platform: esp8266_pwm
id: output_blue
pin: D6
switch:
- platform: gpio
pin: D1
inverted: true
id: relay
name: "Garage Remote"
icon: "mdi:gate"
on_turn_on:
# - output.turn_off: output_blue
# - output.turn_off: output_green
- output.turn_on: output_red
- delay: 500ms
- output.turn_off: output_red
- switch.turn_off: relay
binary_sensor:
- platform: gpio
pin: D2
name: "Garage Sensor"
device_class: garage_door
on_press:
then:
- output.turn_off: output_red
- output.turn_off: output_green
- output.turn_on: output_blue
on_release:
then:
- output.turn_off: output_blue
- output.turn_off: output_red
- output.turn_on: output_green
nickrout
(Nick Rout)
May 12, 2022, 9:24am
2
Try an on_boot automation to turn the correct led on.
Thank you.
Do you know how the on_boot command will know which LED is correct after the power interruption?
myle
(StePhan McKillen (Other kiwi Here))
May 12, 2022, 8:06pm
4
them inside the on_boot you just need to set the state of that binary_sensor
nickrout
(Nick Rout)
May 12, 2022, 8:40pm
5
By looking at the pin that is telling you the state of the door. But you really should set up a garage door as a cover.
I have tried using a cover now and I am trying to use a lambda to change output state based on binary sensor.
I now get a message during compile “Component not found: lambda.”
esphome:
name: toady
platform: esp8266
board: nodemcuv2
esp8266_restore_from_flash: True
light:
- platform: rgb
name: "RGB LED"
red: output_red
green: output_green
blue: output_blue
output:
- platform: esp8266_pwm
id: output_red
pin: D5
- platform: esp8266_pwm
id: output_green
pin: D7
- platform: esp8266_pwm
id: output_blue
pin: D6
switch:
- platform: gpio
pin: D1
name: "Garage Door Open Switch"
id: open_switch
binary_sensor:
- platform: gpio
pin: D2
name: "Garage Door Closed"
id: garage_door_closed
lambda: |-
if (id(garage_door_closed).state) {
- output.turn_off: output_red
- output.turn_off: output_green
- output.turn_on: output_blue;
} else {
- output.turn_off: output_blue
- output.turn_off: output_red
- output.turn_on: output_green ;
cover:
- platform: template
name: "Garage Door"
open_action:
# Cancel any previous action
#- switch.turn_off: close_switch
# Turn the OPEN switch on briefly
- switch.turn_on: open_switch
- delay: 0.1s
- switch.turn_off: open_switch
optimistic: true
assumed_state: true
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "hf/hXjQqkwQIvr6apeFn3b/Fz6sLnS9ePEE7qv78XKY="
ota:
password: "d3fc3d453ed2320f56e740f4dcd7d462"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Toady Fallback Hotspot"
password: "F7WUpmndgK7z"
captive_portal: