So I am trying to use a number of entities to detect “presence” in a room. Motion sensors, device_trackers (network devices) lights etc together in one group. These are all items that would indicate that somebody is in a room.
Question is how to I “normalize” what the status is to something like just on/off as opposed to home, on, open etc so that I can better use the status in automations.
Might be there is a better way to do this, but this seemed like a good way to go.
Thanks! This seems to be working well. I have another issue. My motion sensors are set to turn on/off right away (which I want for other reasons) is there a way to add a “timeout” in this new sensor that essentially once turned on (via any of the devices) will not shut off for a preset amount of time. (ie: stay on for 10 minutes since the last device was on, home etc)
Yeah, there are attributes on the state trigger of an automation where you can say "Only trigger this automation if an entity has held the current state for xx minutes.
You want the Template Binary Sensor to latch for a period of 10 minutes (during which it ignores all received input). Template Binary Sensors don’t offer that feature.
Didn’t catch this was a template sensor. I use a timer for this kind of thing. Split the automation into two halves: The first half detects the condition and fires off a timer, the second half triggers on the timer finishing and completes your automation.
timer:
my_automation:
duration: "00:05:00"
automation:
- alias: my_automation_part_1
description: Starts the timer when conditions are met
trigger:
- platform: template
value_template: " {{ whatevs }}"
action:
- service: timer.start
data_template:
entity_id: timer.my_automation
- alias: my_automation_part_2
description: Trigger on the timer finishing and keep going with your actions
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.my_automation
action:
- service: do.mystuff
I use this pattern in a few places. Hope that helps.
I have used that before in automatons, was wondering if there was a way directly in the configuration. I found what I believe is the right way to do this was to add the delay_off: attribute like this.
basement_occupied:
friendly_name: "Basement Occupied"
value_template: >-
{{ is_state('media_player.xbr_55x850d', 'on') or
is_state('binary_sensor.aeon_labs_zw100_multisensor_6_sensor_5', 'on') or
is_state('binary_sensor.aeon_labs_zw100_multisensor_6_sensor_3', 'on') or
is_state('binary_sensor.aeon_labs_dsb05_multisensor_sensor_3', 'on') or
is_state('zwave.aeon_labs_zw100_multisensor_6_4', 'on')}}
device_class: occupancy
delay_off:
minutes: 10
Using a delay_off of ten minutes means there must be 10 solid minutes where the value_template is not met (i.e. evaluates to false).
The documentation contains a Washing Machine example using a delay_off of 5 minutes. The value_template is monitoring the washing machine power consumption which varies during its washing cycle. The sensor won’t turn off until the power flatlines for a minimum of 5 minutes.
In your case, every entity in your value_template will have to hold a state of off for a period of 10 minutes before binary_sensor.basement_occupied reverts to off. That’s not quite the same as latching to on for a period of 10 minutes. This is looking for 10 solid minutes of silence before it returns to indicating off.
If that’s what you originally wanted, then I misunderstood your original request and just muddied the waters with my ‘latch’ reference.