I have an automation in the kitchen which was working but stopped a while ago when I changed the sensors.
Essentially i am looking for the automation to do the following:
After 19.30 and before 00:30 if the kitchen lights are on for 2 mins and no motion is detected on the Kitchen or Dining Room sensor, all the lights should turn off. I have another automation which turns the lights on during this time if motion is detected so I want this to continually turn on and off during this time on trigger of motion or no motion.
alias: Kitchen No Motion Evening (New v2)
description: Kitchen lights off after 2 mins of no motion.
triggers:
- trigger: state
entity_id:
- light.kitchen_lights
to: 'on'
for:
hours: 0
minutes: 2
seconds: 0
conditions:
- type: is_not_occupied
condition: device
device_id: 8432837d7f12663595646277dc57998f
entity_id: 32628c877b79a87244899865bb118f25
domain: binary_sensor
for:
hours: 0
minutes: 2
seconds: 0
- type: is_not_occupied
condition: device
device_id: 6702be4b7e92333bc5d69263f076b33b
entity_id: 9b747b5e633a85874d51ebd982b4f29a
domain: binary_sensor
for:
hours: 0
minutes: 2
seconds: 0
- condition: time
after: '19:30:00'
before: 00:30:00
weekday:
- sun
- sat
- fri
- thu
- wed
- tue
- mon
- condition: state
entity_id: input_boolean.guest_mode
state: 'off'
- condition: state
entity_id: input_boolean.flip_mode
state: 'off'
actions:
- type: turn_off
device_id: 63100c864650976e5ee028cdcdb7d120
entity_id: 3af9b50cacdbdf8508f0939b26fb0448
domain: light
- type: turn_off
device_id: 27a82779aa61114da85fad319f3ee2d9
entity_id: 2d5ede666d72ed8dd8e5e21fc95c3721
domain: light
- type: turn_off
device_id: 0fc582e96373c45d0941ab64d28833bd
entity_id: d685ae9c38cb89ee90e12d56407c2508
domain: light
- type: turn_off
device_id: efb3a51e4350ef7461fc928602c8cc30
entity_id: 8ffbdc04b9af3785364797f837ad4694
domain: light
mode: single
type or paste code here
The lights seem to turn off the first time it is triggered but then after the first time it will never turn off again.
Your automation logic seems quite flawed. The trigger will only fire once, when the light has been on for two minutes, and if at that particular time there is no motion the lights will turn off. If there is motion however, the lights will never turn off, as the trigger will never fire again.
I don’t see any difference where it matters. Why trigger when the light has been on a certain time? That makes zero sense to me. The only thing that should matter is how long it’s been since any motion was detected. I would replace the triggers with this:
triggers:
- trigger: state
entity_id:
- binary_sensor.kitchen_aqara_motion
- binary_sensor.dining_room_motion
to: "off"
for:
minutes: 2
Keep all of the conditions as is, since you only want the actions to run when all motion sensors are off. Though you can combine all of the state conditions into one, as they are all required to have the same state (off).
Edit: Or if you want to make sure that all motion detectors really have been off for those 2 minutes, and not trigger when one of them has been off for 2 minutes and the other may only have been off for a few seconds, split the conditions up into two and add a for parameter: