Hi all. I have two automations I run at night. one that turns on the lights once motion is detected (via Eufy 2k indoor camera).
The second one that turns off the lights once detection is clear.
However, once the lights are turned off - somehow the camera detects it as motion and run the first automation once again.
Any suggestion will be appreciated - to remedy this problem.
I was using the sun down condition but had to remove it since HA is telling me its sunny now 00:40:00 (Brooklyn, NY). I googled my elevation and set it - but she sun condition does not work for me overnight.
alias: 'Turn bedroom lights off (overnight) '
description: Turn the light off when motion is detected in Cardel's room (Overnight)
trigger:
- type: no_motion
platform: device
device_id: 0a861f6a7f9c881b0a1540b689a2b53c
entity_id: binary_sensor.indoorcam_2k_0d5f
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: and
conditions:
- condition: state
entity_id: light.5122860850029121dbd8
state: 'on'
- condition: and
conditions:
- condition: state
entity_id: light.5122860850029120dcf7
state: 'on'
action:
- service: notify.mobile_app_s_iphone
data:
title: Automation running
message: Overnight bedroom lights off.
- type: turn_off
device_id: e3255eb8cc0ea6722cb72902d36c2cd3
entity_id: light.5122860850029121dbd8
domain: light
- type: turn_off
device_id: 9a2de22ed2219d9821e096af4fa55e84
entity_id: light.5122860850029120dcf7
domain: light
- wait_template: ''
timeout: '00:00:30'
mode: single
That condition is a little wonky - it’s worth reading the condition docs to understand how it should have been formatted. Conditions are and by default anyway, so all you need is:
condition:
- condition: state
entity_id: light.5122860850029121dbd8
state: 'on'
- condition: state
entity_id: light.5122860850029120dcf7
state: 'on'
That final wait_template is doing nothing for you, you can remove it.
As mentioned in response to your Discord post, the simplest fix is to add a condition to the on automation (that you didn’t share) requiring the lights to have been off for a second, or 5 seconds, or whatever works.
The other option would be to have the off automation disable it when it turns the lights off. Add the following before the turn off actions:
Thank you so much… I will need to do some more reading on conditions.
I appreciate you taking the timeout to respond.
This is my first project to automate my elder mother’s home, will take a pause this weekend and do some more reading; before attempting the next project.
alias: Turn bedroom lights on (overnight)
description: Turn the light on when motion is detected in Cardel's room (Overnight)
trigger:
- type: motion
platform: device
device_id: 0a861f6a7f9c881b0a1540b689a2b53c
entity_id: binary_sensor.indoorcam_2k_0d5f
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: and
conditions:
- condition: state
entity_id: light.5122860850029121dbd8
state: 'off'
- condition: state
entity_id: light.5122860850029120dcf7
state: 'off'
- condition: or
conditions:
- condition: sun
before: sunrise
- condition: sun
after: sunset
action:
- service: notify.mobile_app_kevins_iphone
data:
title: Automation running
message: Overnight bedroom lights on.
- domain: light
entity_id: light.5122860850029121dbd8
device_id: e3255eb8cc0ea6722cb72902d36c2cd3
type: turn_on
brightness_pct: 100
- domain: light
entity_id: light.5122860850029120dcf7
device_id: 9a2de22ed2219d9821e096af4fa55e84
type: turn_on
brightness_pct: 100
- wait_template: ''
timeout: '00:00:10'
mode: single
Thanks again, I will revise the automation and test today with the advised you suggested.
I am thinking about getting a physical motion sensor - since I believe the camera one is not reliable.
Everything working as it should so far with the automation - with the exception of the camera detection trigger.
I need to figure out a much better way to keep the lights on (once trigger, and person is presence). I have a elderly mother that say in the bed most of the time, however - the camera clears after 15 seconds and keeps on turning the lights on/off.
Will anyone suggest I invest in physical motion sensor, and if so what good wifi sensor will be recommended?
First off, you don’t have to turn the lights off immediately See this example that turns the lights off 10 minutes after motion ended.
WiFi and sensors … no. Battery life is generally poor to terrible.
Now, if you’re talking Zigbee or Z-Wave, that’s different. For Zigbee the Xiaomi Aqara sensors are cheep and work well enough. The Discord server has a #Zigbee channel that has pinned messages listing known working Zigbee hardware, and many people can help provide recommendations.