Hello everyone…
This morning i was surprised to see that my chicken door wasnt open all the way and was stuck in the middle…so i was wondering how to make an alert notification that watches my “is open” or “is closed” status that i have available and when one or the other changes, wait 20 or 30 seconds and if the other status hasn’t changed after that throw an alert for either did not open or did not close…
I tried a couple versions, but somehow i dont get the logic in to read both status, plug it into a variable, use the on the one that is “on” (for open or closed) dynamically and as soon the “on” changes to off, wait 30 seconds and when the other on reaches "on in that time frame do nothing, but when it does not reach the “on”, throw an alert that uses the variable to tell if it either did not reach open or closed in time.
Here the ESPHOME c
ode that does the opening and closing:
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
on_press:
then:
- if:
condition:
binary_sensor.is_off: lsw2_closed
then:
- button.press: button_on_sunset
- if:
condition:
binary_sensor.is_off: lsw1_open
then:
- button.press: button_on_sunrise
switch:
- platform: template
id: disable_open_on_sunrise
name: "Disable open on sunrise"
optimistic: true
button:
- platform: template
id: button_on_sunset
name: Close Door
on_press:
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
- platform: template
id: button_on_sunrise
name: Open Door
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
- platform: template
id: button_stop
name: Stop Door
on_press:
- fan.turn_off: chickendoormotor