Everything on this Automation is working perfectly, except for the closed door automation. The trigger is working, but it is NOT turning the light off when I close the door. The sensor is reading the data, when viewing it in live conditions the trigger is being triggered. Only problem is that the automation to turn the light off when the door is closed, isn’t firing???
alias: Living Room - Liquor Cabinet
description: Turn Liquor cabinet lights on with sunset and off with time
triggers:
- event: sunset
offset: "+00:00:00"
id: Turn On
trigger: sun
- type: opened
device_id: 1f5f59b258e7248fde674b922b5b06bf
entity_id: faf8a9132d7104a10b87019fcd12a2bb
domain: binary_sensor
trigger: device
id: Door Open
- type: not_opened
device_id: 1f5f59b258e7248fde674b922b5b06bf
entity_id: faf8a9132d7104a10b87019fcd12a2bb
domain: binary_sensor
trigger: device
id: Closed
- trigger: time
at: "23:01:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
id: Turn Off days
conditions:
- condition: state
entity_id: input_boolean.automations_kill_switch
state: "off"
actions:
- choose:
- conditions:
- condition: template
value_template: "{{ (2,7) <= (now().month, now().day) <= (2,14) }}"
alias: February Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data: {}
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- data:
option: Valentine
target:
entity_id:
- select.wled_liquor_preset
action: select.select_option
- conditions:
- condition: template
value_template: "{{ (3,10) <= (now().month, now().day) <= (3,17) }}"
alias: St Patrick Day Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data:
color_name: green
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- action: select.select_option
metadata: {}
data:
option: St Pats Day
target:
entity_id: select.wled_liquor_preset
- conditions:
- condition: template
value_template: "{{ (7,1) <= (now().month, now().day) <= (7,4) }}"
alias: July Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data:
effect: Fireworks 1D
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- action: select.select_option
metadata: {}
data:
option: Us flag Colorloop
target:
entity_id: select.wled_liquor_preset
- conditions:
- condition: template
value_template: "{{ (10,1) <= (now().month, now().day) <= (11,1) }}"
alias: October Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data: {}
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- action: select.select_option
metadata: {}
data:
option: |
{{ ['Halloween', 'Halloween2', 'Halloween3' ] | random }}
target:
entity_id: select.wled_liquor_preset
- conditions:
- condition: template
value_template: "{{ (11,2) <= (now().month, now().day) <= (11,30) }}"
alias: November Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data:
effect: Halloween
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- action: select.select_option
metadata: {}
data:
option: >
{{ ['Candy2 Palette', 'Orange Dancing', 'Yellow Fireworks 1D',
'Fall Flow' ] | random }}
target:
entity_id: select.wled_liquor_preset
- conditions:
- condition: template
value_template: "{{ (12,1) <= (now().month, now().day) <= (12,31) }}"
alias: December Template
- condition: trigger
id:
- Turn On
- Door Open
sequence:
- data: {}
target:
entity_id:
- light.wled_liquor
action: light.turn_on
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- data:
option: Christmas
target:
entity_id:
- select.wled_liquor_preset
action: select.select_option
- conditions:
- condition: trigger
id:
- Turn Off days
sequence:
- data: {}
action: light.turn_off
target:
entity_id: light.wled_liquor
- conditions:
- condition: trigger
id:
- Closed
sequence:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.wled_liquor
default:
- data: {}
action: light.turn_on
target:
entity_id: light.wled_liquor
- action: select.select_option
metadata: {}
data:
option: "{{ state_attr('select.wled_liquor_preset','options') | random }}"
target:
entity_id: select.wled_liquor_preset
mode: single
Thanks, because it is in the month of November it is not allowing it to see the other option of the door closing. Any suggestions? This just got complicated… Maybe a separate automation?
Confirmed, it works in a separate automation because of the date.
Here is the separate automation. Anything to combine these?
alias: Living Room - Liquor Cabinet Close
description: Turn Liquor cabinet lights on with sunset and off with time
triggers:
- trigger: state
entity_id:
- binary_sensor.liquor_cab_door_opening
from:
- "on"
to:
- "off"
conditions:
- condition: state
entity_id: input_boolean.automations_kill_switch
state: "off"
- condition: or
conditions:
- condition: sun
before: sunset
- condition: time
after: "23:00:00"
actions:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.wled_liquor
mode: single
That shouldn’t be an issue… what’s more likely is the automation mode should be changed. While you’re at it there are a few thing you can do to make the automation more efficient and, maybe, more responsive:
Thanks for that, just did the testing and it is working. It is a bit of a delayed response for the lights to turn off but using the traces it confirms of going down that branch. Appreciate the advice! That is a lot cleaner.
If the test is opening then closing the door, you might be able to make that case a little snappier by changing the mode to restart instead of the queued that I used. This will allow the “closing” trigger to break out of the running “turn on” actions and delays.