Good morning everyone…
I have a esp01 relay board and s d1 device that have binary sensors, that i monitor in HASS automations to do tasks, that i would like to move from hass into the esphome code.
First one is a pool pump controller made of a single esp01 relay board and i added a physical switch to the esp01 that triggers a binary sensor and from there it toggles the pump switch via hass autoamtion.
Here the esphome code:
switch:
- platform: gpio
pin: GPIO0
name: ""
inverted: True
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
name: ""
pin:
number: GPIO2
inverted: True
mode:
input: True
pullup: True
device_class: door
So how would i code this in esphome to say when binary sensor state changes from off to on, then toggle switch?
Thx a lot for any input.
Second would be similar.
I have a similar physical button on the d1 that is meant to open or close the door locally depending on if it is open or closed right now.
I tried to code it already but failed…
Right now it is toggled via hass automation again which i want to move into the esphome code
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode:
input: true
pullup: true
inverted: true
id: lsw1_open
name: "Chicken Coop open"
filters:
- delayed_on: 30ms
- delayed_off: 30ms
on_press:
then:
- button.press: button_stop
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
inverted: true
id: lsw2_closed
name: "Chicken Coop closed"
filters:
- delayed_on: 30ms
- delayed_off: 30ms
on_press:
then:
- button.press: button_stop
- platform: gpio
name: "Toggle Door"
pin:
number: GPIO3
inverted: True
mode:
input: True
pullup: True
filters:
- delayed_on: 30ms
- delayed_off: 30ms
device_class: door
# - platform: gpio
# name: "Toggle Door"
# pin:
# number: GPIO3
# inverted: True
# mode:
# input: True
# pullup: True
# filters:
# - delayed_on: 30ms
# - delayed_off: 30ms
# on_press:
# if:
# condition:
# binary_sensor.is_off: lsw1_open
# then:
# - fan.turn_on:
# id: chickendoormotor
# speed: 30
# direction: forward
# - wait_until:
# condition:
# binary_sensor.is_on: lsw1_open
# - fan.turn_off: chickendoormotor
# else:
# if:
# condition:
# binary_sensor.is_off: lsw2_closed
# then:
# - fan.turn_on:
# id: chickendoormotor
# speed: 20
# direction: REVERSE
# - wait_until:
# condition:
# binary_sensor.is_on: lsw2_ closed
# - fan.turn_off: chickendoormotor
# else:
# - fan.turn_off: chickendoormotor
Thx for input on this one as well