johnvpr
(johnvpr)
May 22, 2022, 11:15pm
1
I am not able to trigger the lights when my Garage door opens or closes
My automation to turn on
alias: Garage Lights Auto ON for X minutes (when Motion or garage door open)
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.garage_door_contact_sensor
to: Open #tried also On, OPEN, open, etc
condition:
- condition: device
type: is_off
device_id: acb3b4b8d936e4f7eb7f24c52571d5c4
entity_id: switch.garage_lights
domain: switch
action:
- type: turn_on
device_id: acb3b4b8d936e4f7eb7f24c52571d5c4
entity_id: switch.garage_lights
domain: switch
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
- type: turn_off
device_id: acb3b4b8d936e4f7eb7f24c52571d5c4
entity_id: switch.garage_lights
domain: switch
mode: single
ESPhome
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: true
name: "Garage Door Contact Sensor"
id: garage_door_contact_sensor
# internal: true
device_class: garage_door
filters:
- delayed_on: 1s
switch:
- platform: gpio
id: relay
internal: true
pin:
number: GPIO5
inverted: False
restore_mode: ALWAYS_OFF
cover:
- platform: template
device_class: garage
name: "Garage Door"
id: template_cov
lambda: |-
if (id(garage_door_contact_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
close_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
pedolsky
(Pedolsky)
May 23, 2022, 5:12am
2
To be sure you are using the correct state, check Developer Tools β> States. Binary sensors are on
or off
(lower case).
1 Like
johnvpr
(johnvpr)
May 23, 2022, 11:25pm
3
Tried and it does not trigger with βonβ or βoffβ
pedolsky
(Pedolsky)
May 24, 2022, 4:16am
4
Please check the debug trace.
johnvpr
(johnvpr)
May 24, 2022, 4:35am
5
step config
platform: state
entity_id:
- binary_sensor.garage_door_contact_sensor
to: 'on'
changed variable
this:
entity_id: automation.garage_lights_auto_on
state: 'on'
attributes:
last_triggered: '2022-05-24T04:28:15.053518+00:00'
mode: single
current: 1
id: '1653257601421'
friendly_name: Garage Lights Auto ON for X minutes (when Motion or garage door open)
last_changed: '2022-05-23T23:30:57.870389+00:00'
last_updated: '2022-05-24T04:28:15.053892+00:00'
context:
id: 0180f452974b0adbba0ab6ca5ddd38ec
parent_id: 0180f452974646a7242fea4251fe2736
user_id: null
trigger:
id: '0'
idx: '0'
platform: state
entity_id: binary_sensor.garage_door_contact_sensor
from_state:
entity_id: binary_sensor.garage_door_contact_sensor
state: 'off'
attributes:
device_class: garage_door
friendly_name: Garage Door Contact Sensor
last_changed: '2022-05-24T04:29:41.028089+00:00'
last_updated: '2022-05-24T04:29:41.028089+00:00'
context:
id: 0180f453e72409638b4eb8aacf1c893c
parent_id: null
user_id: null
to_state:
entity_id: binary_sensor.garage_door_contact_sensor
state: 'on'
attributes:
device_class: garage_door
friendly_name: Garage Door Contact Sensor
last_changed: '2022-05-24T04:30:12.194360+00:00'
last_updated: '2022-05-24T04:30:12.194360+00:00'
context:
id: 0180f45460e26758709833495f47de3e
parent_id: null
user_id: null
for: null
attribute: null
description: state of binary_sensor.garage_door_contact_sensor
johnvpr
(johnvpr)
May 24, 2022, 4:39am
6
After a quick google search i got it to work with changing from single to queues.
But why?
Queued
Start a new run after all previous runs complete. Runs are guaranteed to execute in the order they were queued. Note that subsequent queued automations will only join the queue if any conditions it may have are met at the time it is triggered.
Im guessing the condition is_off will mess things up
pedolsky
(Pedolsky)
May 24, 2022, 4:45am
7
Maybe it has to do with the gpio platform.
If you suspect the device condition test it with state condition instead.