luishang
(Luishang)
May 7, 2023, 7:00pm
1
I’m using a presence sensor to trigger a light. This works fine.
However when I try to turn off when there’s no movement, it doesn’t work.
Can anyone help?
alias: Teste
description: ""
trigger:
- type: motion
platform: device
device_id: facfda392f5186458afc2362920c86dc
entity_id: binary_sensor.ewelink_ms01_motion
domain: binary_sensor
condition: []
action:
- type: turn_on
device_id: c5cc681f3b5b457c31aca37705f36138
entity_id: light.um_switch_2
domain: light
- wait_for_trigger:
- type: no_motion
platform: device
device_id: facfda392f5186458afc2362920c86dc
entity_id: binary_sensor.ewelink_ms01_motion
domain: binary_sensor
timeout:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
continue_on_timeout: false
- type: turn_off
device_id: c5cc681f3b5b457c31aca37705f36138
entity_id: light.um_switch_2
domain: light
mode: single
ddaniel
(Daniel Dekovic)
May 7, 2023, 7:08pm
2
After some experimenting with turning on/off lights on motion I found out that this automation works the best using timer helper. I created timer helper and set it for one minute and used it in automation something like this.
When motion is clear start timer and when timer is idle turn off light. If motion is detected while timer is running cancel timer and start it again when motion is cleared.
This is my automation for mirror light in bathroom
alias: Bathroom mirror light
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.bathroom_motion_sensor_occupancy
from: "off"
to: "on"
id: Motion detected
- platform: state
entity_id:
- binary_sensor.bathroom_motion_sensor_occupancy
from: "on"
to: "off"
id: Motion cleared
for:
hours: 0
minutes: 0
seconds: 0
- platform: state
entity_id:
- timer.bathroom_mirror_light_helper
to: idle
id: Helper
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Motion detected
- type: is_illuminance
condition: device
device_id: 50e83835f19e9a57aefaf434dba281e9
entity_id: sensor.bathroom_motion_sensor_illuminance_lux
domain: sensor
below: 50
enabled: true
sequence:
- service: timer.cancel
data: {}
target:
entity_id: timer.bathroom_mirror_light_helper
- service: light.turn_on
data: {}
target:
entity_id: light.switch_2
- conditions:
- condition: trigger
id: Motion cleared
sequence:
- service: timer.start
data: {}
target:
entity_id: timer.bathroom_mirror_light_helper
- conditions:
- condition: trigger
id: Helper
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.switch_2
mode: single
1 Like
luishang
(Luishang)
May 7, 2023, 7:18pm
3
Somehow the issue was the sensor…
Chaged and it worked, also included the condition to work only after sunset:
alias: Cozinha noite
description: ""
trigger:
- type: motion
platform: device
device_id: 8e4d2678c1fd7cb797b01a93f748416c
entity_id: binary_sensor.ewelink_ms01_motion_2
domain: binary_sensor
condition:
- condition: sun
after: sunset
before: sunrise
before_offset: "-00:15:00"
after_offset: "00:15:00"
action:
- type: turn_on
device_id: c5cc681f3b5b457c31aca37705f36138
entity_id: light.um_switch_2
domain: light
- wait_for_trigger:
- type: no_motion
platform: device
device_id: 8e4d2678c1fd7cb797b01a93f748416c
entity_id: binary_sensor.ewelink_ms01_motion_2
domain: binary_sensor
- type: turn_off
device_id: c5cc681f3b5b457c31aca37705f36138
entity_id: light.um_switch_2
domain: light
mode: single
ddaniel
(Daniel Dekovic)
May 7, 2023, 7:32pm
4
Its better to buy a motion sensor with light sensor because sometimes it can be dark in a house during the day or some places like stairs does’t have windows so it’s darker during the day.
i suggest you to try timer helper. In my case it really works great.
Entity Controller from HACS handles this sort of thing very effectively.