Hey all,
I am going crazy trying to work out how to make this work.
I have 2 human presence sensors (ZG-204ZM) and I am trying to do an automation to turn the lights off, but not while its still detecting presence.
I have a motion sensor which is the main one while I am trying to get these working and I have an automation to turn off the lights in the room after motion is no longer detected 5 and 20mins.
I have added a step of and not having the presence of home.
However when the automation triggers, the presence sensors return null instead of the state.
Config as below, when looking at a trace both presence sensors are showing state “on” or null and the lights never turn off. Am i configuring something wrong?
So the problem I am trying to solve here is, the motion sensor can detect no motion for a period of time if we are sitting still and turn off the lights why we are in the room.
I want it to make sure there is not presence in the room before turning off the lights.
Which is made up of living room and dining presence (as the lights are the same room.
I couldnt work out a way to combine the 2 sensors and just do a turn off lights when there is no presence on either of them.
I seem to be missing something in the automations to make the presence work.
And when searching for it I just get a lot of results about the home presence based on the home assistant app instead.
Your automation would be easier to interpret if you change it. In the Trigger section you entered Devices as triggers - if you change those to Entities and repost the YAML, I’ll follow up.
Bear with me here, my Presence sensor reports Occupancy On/Off, my Motion sensors report Occupancy or Motion On/Off depending on the application. I don’t know what your presence sensor reports.
To make it easier you can create a group helper for the two presence sensors set to act as one , with a “if either has motion, occupancy, or presence” setting (as opposed to "if all detect motion, occupancy, or presence.)
But first, we have to sort out what you’re using to get the sensors Occupancy or Presence state. It shouldn’t have anything to do with “Home”, it should just confirm whether the device itself detects Presence or Occupancy. Eliminating the use of Devices in your automation (using Entities instead) will help with that. If you’re having a hard time entering the right Entity for the presence sensor in the automation, if you type “binary_sensor.p” you’ll get the list of presence sensor entities (that you named starting with P).
What we need from you, is information on these presence sensor(s). We need t know, what state to look for. Please post the information aboout the presence sensor from developer tools > state.
I did try to create a group previously and it was not changing at all, however I just tried it again (have had a few HA updates since then) and now it seems to be working!
The presence seems to report as home or away.
I think part of the key was moving away from using devices like you stated.
Here is the new one I have setup with the group to test and using the group presence as the trigger to simplify it.
Ill see if that works now and turns off correctly. Set to a short timeout for testing.
alias: Turn off livingroom
description: Turns off the living room lights when there is no motion for 15 mins
trigger:
- platform: state
entity_id:
- binary_sensor.presence_living
from: null
to: "off"
for:
hours: 0
minutes: 0
seconds: 5
id: 5min
condition:
- condition: not
conditions:
- condition: state
entity_id: light.living_room
state: "off"
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- 5min
sequence:
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.living_room
- conditions:
- condition: trigger
id:
- 20min
sequence:
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.living_room
default: []
mode: single
EDIT: So far this config seems to be working a lot better, ill play with it more! Thanks for the direction
Thanks guys, this seems to have gotten me sorted out and I can build on it from here And definitely will use entities in the future after this education