[BUG] Docs: ha automation example is not suitable for testing with one camera
trigger.{to|from}_state.state in my configuration is a name of camera
I have only one camera, so that state never changes.
condition:
- condition: template
value_template: '{{ trigger.to_state.state != trigger.from_state.state }}'
Please consider providing better example for users with one camera and without spamming with notifications. Maybe some timer ? I don't know.. how to solve this
If you only have one camera you can use the same logic just do trigger.to_state.state.attributes.id and same for the from_state
id is different on every event (is it ?) ..if so, I can just remove condition from automation. The problem is that without any condition I got multiple events spamming my phone with same face. How can I limit number of events to one per one minute per person?
I have an idea. Now entity sensor.double_take_facename state is equal to camera name where face was last seen. It would be awesome that optionally, after configured time, that entity will changes its state to None/off/null/not_seen. It will behave more like motion sensor.
It uses the id from the frigate event so they can be linked. I don't think it needs to be that complicated. And if you only want one notification all you need to do is add a wait at the end of the automation with a mode of single so the other ones are cancelled
But it is not only notifications.
- home assistant history (current behavior suggests that I am now at front doors and I am there for many hours)
- building automations ( ex. unlock doors when I am recognized and pressing ring button ) - now such automation is quite complicated, with entity state changing from None/off/null/not_sen to camera name it easy
- With that new behavior it would be more suitable to connect with ha native https://www.home-assistant.io/getting-started/presence-detection/
- ..and native occupancy binary state
But it is not only notifications.
home assistant history (current behavior suggests that I am now at front doors and I am there for many hours)
building automations ( ex. unlock doors when I am recognized and pressing ring button ) - now such automation is quite complicated, with entity state changing from None/off/null/not_sen to camera name it easy
With that new behavior it would be more suitable to connect with ha native https://www.home-assistant.io/getting-started/presence-detection/
..and native occupancy binary state
I understand what you're saying, but that doesn't all add up. For example, double take already has a specific sensor added for each person that shows the last camera they were seen by (along with lots of attributes about that event) which is really easy to use for presence detection already.
For the "unlock door" scenario I have a similar automation already going in my setup.
A motion sensor could be helpful though, but it should likely just be a new sensor instead of a configuration change to the existing one.
I know that project shouldn't break its existing behavior. What I suggest is an option to set timeout inside double take to make such function possible without creating whole layer of sensors for room presence. Maybe there is a way to reuse https://www.home-assistant.io/integrations/mqtt_room/
It uses the id from the frigate event so they can be linked. I don't think it needs to be that complicated. And if you only want one notification all you need to do is add a wait at the end of the automation with a mode of single so the other ones are cancelled
What if I enter home with other persons ? If someone will be reported before me, then I would have to wait for timeout to get another chance to get into automation. It is just complicated without setting up some timers.
It uses the id from the frigate event so they can be linked. I don't think it needs to be that complicated. And if you only want one notification all you need to do is add a wait at the end of the automation with a mode of single so the other ones are cancelled
What if I enter home with other persons ? If someone will be reported before me, then I would have to wait for timeout to get another chance to get into automation. It is just complicated without setting up some timers.
That's not true. If you are using the camera sensor the automation would fire multiple times with the associated event ids and matches that were found. it would also work using the person sensor instead of the camera sensor so that it fires whenever any recognized person is seen by a camera, and then just filter by camera of interest.
Also, if two people entered at the same time timers wouldn't help you anyways since the camera sensor can only hold one set of attributes for a single event.
Even if I use "single" mode as you suggested ?
Even if I use "single" mode as you suggested ?
So there are some wires getting crossed here. The single mode suggestion was to make it so notifications only came in once every x seconds. This would not work with two people coming in at the same time, just like a motion-sensor-like version, because it still holds one state at a time.
It really comes down to priorities, if you have a priority of not so many notifications then a timer will work at the cost of not working for two people coming in at the same time. If make sure it always sends a notification for multiple people that enter at the same time then the default automation will send many notifications. It is possible to get both but will take crafting of the automation and conditions instead of just using the basic example that was provided in the docs (which is meant to be built upon for specific use cases).
The solution to get the behavior you want in both cases is to not use a timer and instead allow double-take with a automation mode of "parallel" and add conditions comparing the from_state and to_state to only fire when useful information is preset. Currently that sensor in the automation example will send a new notification on every snapshot that double-take finds.
That idea with entity state change to None after timout have even one more friend to use in HA:
https://www.home-assistant.io/blog/#zones-now-have-a-state
If you only have one camera you can use the same logic just do
trigger.to_state.state.attributes.idand same for thefrom_state
So: '{{ trigger.to_state.state.attributes.id != trigger.to_state.state.attributes.id }}' & '{{ trigger.from_state.state.attributes.id != trigger.from_state.state.attributes.id }}'
That does not work. The automation does not get triggered
Your comparisons don't make sense, you're comparing the same things.
trigger:
- platform: state
entity_id: sensor.double_take_person1
- platform: state
entity_id: sensor.double_take_person2
condition:
- condition: template
value_template: "{{ trigger.to_state.attributes.id != trigger.from_state.attributes.id }}"
- condition: template
value_template: >-
{{ trigger.to_state.attributes.match.name == "person1" or
trigger.to_state.attributes.match.name == "person2" }}
action:
- service: notify.mobile_app_telephone_person1
data:
message: |-
{% if trigger.to_state.attributes.match is defined %}
{{trigger.to_state.attributes.match.name | title }} is at the door @ {{trigger.to_state.attributes.match.confidence}} %
{% endif %}