I am using an esp32 running esphome as a control panel for home assistant.
is there a way on restarting the esp32 for it to poll home assistant for the state of certain switches?
so for example i have a bipolar led that shows is a certain door is open or not - this is managed through home assistant and hows on the dashboard etc - so pins 19 and 21 are red and green on the led (with an interlock) if i lose power to the esp 32, is there a way for esp home to query home assistant for the setting.
or, is there a way for home assistant to see when a esphome instance becomes available and send those results to the esphome? I tend to use node-red more than automation, but happy to use either.
Many thanks for you help in advace.
tom_l
May 15, 2021, 3:06am
2
In ESPHome, use the on-boot trigger to call the update component action for all the entities you want to update.
Thank you.
Does that call an update from home assistant. I up trying to update esphome with date in home assistant.
tom_l
May 15, 2021, 7:06am
4
To get the data from home assistant into ESPHome you must have used something like this: Home Assistant Binary Sensor ā ESPHome if so, yes it should update that.
Iām guessing here because you have not shared your ESPHome config.
apologies, i should have shared my script, the switches get set by home assistant via a state change in nide red.
esphome:
name: house_monitor
platform: ESP32
board: esp-wrover-kit
wifi:
ssid: "xxxxxxxxxxx"
password: "xxxxxxxxxxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "House Monitor Fallback Hotspot"
password: "xxxxxxxxxxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
switch:
- platform: gpio
pin: 15
name: "Mon_Buzzer"
inverted: yes
- platform: gpio
pin: GPIO19
name: "Boys_door_red"
id: Boys_door_red
interlock: [Boys_door_green]
- platform: gpio
pin: GPIO21
name: "Boys_door_green"
id: Boys_door_green
interlock: [Boys_door_red]
- platform: gpio
pin: GPIO22
name: "jonPC_green"
id: jonPC_green
interlock: [jonPC_red]
- platform: gpio
pin: GPIO23
name: "jonPC_red"
id: jonPC_red
interlock: [jonPC_green]
- platform: gpio
pin: GPIO2
name: "GamePC_green"
id: GamePC_green
interlock: [GamePC_red]
- platform: gpio
pin: GPIO4
name: "GamePC_red"
id: GamePC_red
interlock: [GamePC_green]
- platform: gpio
pin: GPIO05
name: "spare_green"
id: spare_green
interlock: [spare_red]
- platform: gpio
pin: GPIO18
name: "spare_red"
id: spare_red
interlock: [spare_green]
- platform: gpio
pin: GPIO27
name: "recycling"
id: recycling
- platform: template
name: Recycling_flash
id: Recycling_flash
optimistic: true
turn_on_action:
- switch.turn_on: recycling
- delay: 500ms
- switch.turn_off: recycling
- delay: 500ms
# turn self on again if still enabled
- if:
condition:
lambda: 'return id(Recycling_flash).state;'
then:
- switch.turn_on: Recycling_flash
turn_off_action:
- switch.turn_off: recycling
- platform: gpio
pin: GPIO13
name: "bins"
id: bins
- platform: template
name: bins_flash
id: bins_flash
optimistic: true
turn_on_action:
- switch.turn_on: bins
- delay: 500ms
- switch.turn_off: bins
- delay: 500ms
# turn self on again if still enabled
- if:
condition:
lambda: 'return id(bins_flash).state;'
then:
- switch.turn_on: bins_flash
turn_off_action:
- switch.turn_off: bins
binary_sensor:
- platform: gpio
pin:
number: 33
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 50ms
name: "acknowledge"
- platform: gpio
pin:
number: 25
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 50ms
name: "gamepc"
- platform: gpio
pin:
number: 34
mode: INPUT
inverted: true
filters:
- delayed_on: 50ms
name: "jonpc"
- platform: gpio
pin:
number: 32
mode: INPUT_PULLUP
inverted: true
filters:
- delayed_on: 50ms
name: "cctv_mon"
1 Like