Razer
(Razer)
January 23, 2023, 6:02pm
1
I’ve set up an automation to turn on a light if there is motion and off if there’s none,
it seems to work but stops working as soon as i try to add a delay to the turning off of the light
Any idea on how to fix it?
alias: Luci cucina
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_motion_ac02_iaszone
condition: []
action:
- choose:
- conditions:
- type: is_motion
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
- type: is_illuminance
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: sensor.lumi_lumi_motion_ac02_illuminance
domain: sensor
below: 60
sequence:
- type: turn_on
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_on
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
- conditions:
- type: is_no_motion
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 45
sequence:
- type: turn_off
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_off
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
mode: single
Razer:
it seems to work
? “seems to” ?, does it work ?.. in real
… i wonder because i have some aqara motion sensors ( lumi ), which does have “states” … But it’s not like “is_motion/is_no_motion”
Beside it has a default of about 45 seconds, so you just have to make 2 simple automation
1 if motion detected (and illlumn below 60) turn_on_light)
… after about 45 seconds the ( MY) Motion-sensor-Device will automatically “check” again
2 if no motion … turn of
Razer
(Razer)
January 23, 2023, 6:35pm
3
It works but only if i do not add a delay, i would rather have them in one single automation
And how often (which interval) does your motion sensor have ?, maybe it’'s similar to mine approx. 45 second, so you only have to tell " if no motion detected / .turn of light "
What if, let’s say your Motion-Devices actually default “checks for motion” every 30-seconds ?
I don’t think you can use that " 45 second " condition like that
Razer
(Razer)
January 23, 2023, 6:45pm
5
Motion timeframe is set to 30 seconds on device, without any delay after 30 seconds the lights turn off, as soon as i add delay the automation stops working and light keep on
If i go to automation and then start it manually, the lights will turn off, so it seems like it’s an issue with the kind of structure of the automation
I would like to add another delay to the automation so i can test the best delay not to have lights shut on me while i’m still in the room
It’s not a delay you have there, it’s a condition for the is_no_motion ( i.e if No motion for 45 second , but you say that you can ( or there is a default
so after 30 seconds, it checks for motion/illumn again
I don’t know ur device, but i think you have to " if-motion/illum-ok … turn on light for x seconds
And Skip the if_no_motion
What makes it turn off ? … is the motion-sensor integrated in the “lights”, or does the motion-sensor send a “turn_of_light” after 30 seconds ?
Razer
(Razer)
January 23, 2023, 7:10pm
8
The motion sensor state changes to no movement present, then the consecutive action is for HA to shut the lights
Having them separated like this seems to work now, but i would like to have both in a single automation if possible
alias: Luci OFF cucina
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_motion_ac02_iaszone
to: "off"
for:
hours: 0
minutes: 0
seconds: 45
condition: []
action:
- type: turn_off
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_off
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
mode: single
On
alias: Luci ON cucina
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_lumi_motion_ac02_iaszone
to: "on"
condition: []
action:
- type: turn_on
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_on
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
mode: single
DiGibr02
(Chris Smith)
January 23, 2023, 7:17pm
9
This is how I do it and it works flawlessly. Hope this helps!
automation:
- id: masterbathroom_lighting
alias: "Master Bathroom Lighting"
mode: restart
trigger:
- platform: state
id: "motion"
entity_id: binary_sensor.masterbathroom_motion
to: "on"
- platform: state
id: "clear"
entity_id: binary_sensor.masterbathroom_motion
to: "off"
for: "00:00:30"
- platform: state
id: "close"
entity_id: binary_sensor.masterbathroom_door
to: "off"
- platform: state
id: "open"
entity_id: binary_sensor.masterbathroom_door
to: "on"
condition:
- condition: state
entity_id: input_boolean.masterbathroom_override
state: "off"
action:
- choose:
- conditions:
- condition: trigger
id: "motion"
- condition: and
conditions:
- condition: state
entity_id: sensor.home_mode
state:
- "early morning"
- condition: state
entity_id: binary_sensor.workday
state: "on"
sequence:
- scene: scene.masterbathroom_morning
- conditions:
- condition: trigger
id: "motion"
- condition: and
conditions:
- condition: state
entity_id: sensor.home_mode
state:
- "early morning"
- condition: state
entity_id: binary_sensor.workday
state: "off"
sequence:
- scene: scene.masterbathroom_weekend
- conditions:
- condition: trigger
id: "motion"
- condition: state
entity_id: sensor.home_mode
state:
- "morning"
- "afternoon"
- "evening"
sequence:
- scene: scene.masterbathroom_day
- conditions:
- condition: trigger
id: "motion"
- condition: state
entity_id: sensor.home_mode
state:
- "bedtime"
- "sleep"
- "late night"
sequence:
- scene: scene.masterbathroom_night
- conditions:
- condition: trigger
id: "clear"
- condition: state
entity_id: binary_sensor.masterbathroom_door
state: "on"
sequence:
- service: light.turn_off
entity_id: light.masterbathroom_lights
- conditions:
- condition: trigger
id: "close"
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.masterbathroom_occupied
- service: switch.turn_on
entity_id: switch.fragrance_thing
- conditions:
- condition: trigger
id: "open"
sequence:
- service: input_boolean.turn_off
entity_id: input_boolean.masterbathroom_occupied
- service: switch.turn_off
entity_id: switch.fragrance_thing`Preformatted text`
So did you check how long time this took ?
so if im right, your intentions in to turn of the light, 45 seconds “after” the motion-sensor state changed to “no Motion” , which it might do 30 seconds, after it first detected motion … sorry im lost
In specific as you above have a condition “illumin below 60” for turning on the light, and you didn’t specify that 30-second interval you mentioned above, and your choice of words just makes me drops out/redraw
(When you latest showed 2 other separate automations, you again used “They seems to work”)
Move around, get out, or have the light turned on for X-seconds
Razer
(Razer)
January 23, 2023, 8:13pm
11
This fixed it
Key was adding delay to the trigger rather than the action
1 Like
realm
(realm)
January 24, 2023, 12:44am
12
I use this on my top floor.
1 automation to turn on light.
And the one below to turn off.
Pay attention at “mode:restart”
This will “restart” will not turn off light while there is motion.
alias: Zolder verlichting uit
description: “”
trigger:
type: no_motion
platform: device
device_id: e05553bf1deb6d95ea48b4c349b6ef50
entity_id: binary_sensor.zolder_sensor_motion
domain: binary_sensor
for:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
condition: []
action:
type: turn_off
device_id: 55e134e83ca8518b82bafac1c9a4c69d
entity_id: light.switch_aqara_light
domain: light
mode: restart
Razer
(Razer)
March 5, 2023, 4:45am
13
I thought i had it fixed, but seems like after lights turn on, they turn off while motion is still found by the sensor. Seems like the automation is successfully triggered, but action is not performed
Here is current automation, what am i missing?
alias: Movimento cucina
description: ""
trigger:
- type: motion
platform: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
- type: motion
platform: device
device_id: 7ec5496ee2f1f04e2326b1216f226aec
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
domain: binary_sensor
- type: no_motion
platform: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
- type: no_motion
platform: device
device_id: 7ec5496ee2f1f04e2326b1216f226aec
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
condition: []
action:
- choose:
- conditions:
- condition: or
conditions:
- type: is_motion
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
- type: is_motion
condition: device
device_id: 7ec5496ee2f1f04e2326b1216f226aec
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
domain: binary_sensor
- type: is_illuminance
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: sensor.lumi_lumi_motion_ac02_illuminance
domain: sensor
below: 60
- condition: device
type: is_off
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- condition: device
type: is_off
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
sequence:
- type: turn_on
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_on
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
- conditions:
- condition: and
conditions:
- type: is_no_motion
condition: device
device_id: 9d695aebdef65308a0585ff5941b81bc
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
- type: is_no_motion
condition: device
device_id: 7ec5496ee2f1f04e2326b1216f226aec
entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 10
sequence:
- type: turn_off
device_id: f73c5c97a4f0f2b6189d230a21c9b09a
entity_id: switch.sonoff_10014b7427
domain: switch
- type: turn_off
device_id: 62148fdbba8e02d3bf0d99600524e7f8
entity_id: switch.sonoff_10014b25ee
domain: switch
mode: restart
Rofo
(Ro)
March 5, 2023, 10:43am
14
I use this for my kitchen, works perfectly:
alias: Kitchen - Motion Lights
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.kitchen_motion_sensor_group
to: "on"
condition:
- condition: numeric_state
entity_id: sensor.lumi_lumi_motion_ac02_illuminance
below: input_number.kitchen_illuminance_threshold
action:
- if:
- condition: state
entity_id: light.kitchen_light_group
state: "off"
then:
- service: light.turn_on
data:
brightness_pct: 100
rgb_color:
- 255
- 255
- 255
transition: 1
target:
entity_id: light.kitchen_light_group
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.kitchen_motion_sensor_group
from: "on"
for:
hours: 0
minutes: 2
seconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.kitchen_light_group
mode: restart
1 Like