I thought I read that someone else had done this at some point, but I’m not having any luck finding it unfortunately and am hoping someone can help me out.
Basically, my light switches trigger a binary sensor that HASS then sees the state change on and then HASS controls my smart bulbs.
Every now and then HASS goes down for some reason or I lose wireless, in which case my switches can’t communicate with HASS and don’t work at all since all they know to do is change a binary sensor while the button is pressed. Ideally, I’d like the switches to always act as a dumb light switches even if the automation platform is down and I’d ideally like the switch to trigger the relay instead of just its binary sensor.
So, I believe I’d need some logic to know if HASS is available and then some logic to say:
If HASS==online THEN
If relay==offline THEN turn it on
--AND --
Trigger the binary sensor //in case HASS is supposed to adjust colors/brightness
Else
Toggle the relay
No longer available, but these are the light switches themselves too.
My existing YAML below in case anyone has any ideas, but my description wasn’t clear. As you can see, the relay is configured and exposed to HASS in case I ever need to power cycle the smart bulbs, but other than that, basically doesn’t do anything w/in ESPHOME itself.
Thanks in advance all!
esphome:
name: hallway02_switch
platform: ESP8266
board: esp01_1m
on_boot:
priority: 700
# ...
then:
- switch.turn_on: relay
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
domain: .MYinternalDOMAIN.com
manual_ip:
static_ip: 10.1.100.161
gateway: 10.1.100.1
subnet: 255.255.255.0
logger:
# Enable Home Assistant API
api:
ota:
safe_mode: true
web_server:
port: 80
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: true
name: "Hallway Lightswitch (Bedrooms)"
on_click:
then:
- logger.log: "Hallway Lightswitch (Bedrooms) Clicked"
switch:
- platform: gpio
name: "Hallway Lightswitch Power"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: no