#having trouble with lighting automation
1 messages · Page 1 of 1 (latest)
description: ""
triggers:
- entity_id: binary_sensor.kitchen_light_and_motion_sensor_occupancy
from: "off"
to: "on"
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: sun
after: sunset
before: sunrise
- condition: and
conditions:
- condition: time
before: "23:30:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
sequence:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 100
target:
area_id: kitchen
- action: switch.turn_on
metadata: {}
data: {}
target:
area_id: kitchen
- conditions:
- condition: sun
before: sunrise
- condition: time
after: "23:30:00"
sequence:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 10
target:
entity_id:
- light.kitchen_nook_lights
light.kitchen_sink_light
- conditions:
- type: is_not_occupied
condition: device
device_id: 8a99e8cda4338a169c45f254384fc298
entity_id: b1283d6c68b3bb8b4f4a7f6b3ae4daf6
domain: binary_sensor
for:
hours: 0
minutes: 5
seconds: 0
sequence:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.kitchen_sink_light
- light.kitchen_nook_lights
- action: switch.turn_off
metadata: {}
data: {}
target:
device_id: 559a10b0b47732f00205ec70cbf54172
mode: restart
max_exceeded: silent
Thank you!
I'm not sure if I'll be much help here but time does not "roll-over" after midnight like we would expect it to. Technically, after 23:30 is only going to get you to midnight; you don't have anything to get from midnight to, say, 05:30, for example.
I think your before:sunrise/after:sunset is catching everything because of the way your conditions are laid out.
To start, I would say trying simplifying your automation a bit. Set hard times for when you want everything to fire. So, 06:00 to 23:30 would be 100% brightness. Then 23:30 to 23:59 and 00:00 to 06:00 would be 10% brightness.
Afterwards, you can start incorporating sunset/sunrise into the automation.
On a side note, I notice that you're using the occupancy entity instead of the motion detected entity. IMO, the occupancy entity could be a bit finicky. It probably has its own cooldown time before it changes to clear. At least with the Philips Hue Motion Sensors, it takes five minutes before occupancy clears so, so your automation wouldn't turn off the lights for five more minutes past that. Plus, I've seen motion be detected but occupancy would not.
You only trigger the automation once the motion sensor goes from off to on, so at the point of triggering the conditions in your choose to turn off the lights will never be fulfilled.
Try the following logic instead, in psuedocode:
triggers:
- motion goes from off to on
id: motion
- motion goes from on to off
for: 5min
id: no_motion
actions:
- if:
triggered by: motion
then:
- if:
time is between X and Y
then:
- turn on light at 10%
else:
- turn on light at 100%
else:
- turn off light
sorry i didn't see that anyone had responded
I will try this thank you!
I was told by someone else to use choose statements instead of if/then
would you recommend using if then for this set up?
Yes if: will suffice if you only have 2 different scenarios. choose: is for handling if-elif-...-else.