Closed dfoley4 closed 3 months ago
Enable debug and review the trace please. Guide here; https://github.com/SgtBatten/HA_blueprints/blob/main/Frigate%20Camera%20Notifications/Guide%3A%20Debug%20Option.md
I think I've found the issue location. Here Here's a relevant debug log:
Frigate Notification () DEBUG (in loop): Info: Last Zones: ['garage', 'driveway-near'], Current zones: ['garage', 'driveway-near', 'driveway-far'], sublabel: None, iOS sound: yes due critical notifications, Android Sound: disabled by alert once, Triggers: New Snapshot: False, Presence Changed: False, stationary moved: False, entered zones changed: False, sublabel changed: False, Conditions: Loitering: 0 or Presence Entity not home: OFF - PASS, zone filter TEST: ON - PASS, multi-zone filter: ON - PASS, state filter TEST: OFF - PASS image: "/api/frigate/notifications/1710810480.311976-l43p5t/thumbnail.jpg"
Note that even though Last Zones
has fewer items than Current zones
, entered zones changed
is still reporting false.
I messed around in the template engine to see what the issue was, and I think it's just some bad syntax on the conditionals. Below gave me the results I'd expect:
{% set zones = ['driveway-near', 'driveway-far'] %}
{% set last_zones = ['garage', 'driveway-near'] %}
{% set entered_zones = ['garage', 'driveway-near', 'driveway-far'] %}
{% set filtered_last_zones = zones|select('in', last_zones)|list %}
{% set filtered_entered_zones = zones|select('in', entered_zones)|list %}
{{ zones|length > 0 and (filtered_entered_zones|length > 0 and filtered_entered_zones|length != filtered_last_zones|length) }}
Essentially, I don't think and not
is behaving the way you're expecting it to.
I'm happy to fork and see if my solution fixes the issue in practice.
Are you using the stable or beta, your automation suggests beta but you are looking at the stable code. A lot has been worked on in the beta, especially with fine tuning the debug outputs for zones. Note that the debug outputs can simply be wrong as many of them are not the exact tests of the conditions themselves due to changes over time.
Please confirm exactly what you are using.
Morning,
You are correct, this automation is running on the beta release. I'll post a trace this afternoon.
Of note, I updated my zones on frigate by removing and replacing the coordinates and now a few notifications have gone through with this automation. Not sure what might've been the problem but I'll update here if I can figure out what was going on.
Thanks!
I've done pretty heavy testing with zones on the beta because I know the stable isn't perfect. I thought I had it nailed down pretty well.
Regarding your pull request. I only do edits to he beta. Then merge them over to the stable manually once satisfied. I've got a hell of a lot of changes to bring over when I get time
Essentially, I don't think
and not
is behaving the way you're expecting it to. I'm happy to fork and see if my solution fixes the issue in practice.
Hi @djak250
I didn't realise you were not the original issue opener.
Please see here in the beta this is already improved similar to what you have discovered in stable i believe
entered_zones_changed: "{{ zones|length > 0 and (zones|select('in', enteredzones)|list|length > zones|select('in', last_zones)|list|length) }}"
Sorry. Yeah it's working in the beta. You can ignore my pr.
I'm going to go ahead and close this issue, looks like everything is working as advertised in the beta. Thanks @SgtBatten !
Description
I have zone filters enabled for my garage camera but instead of triggering for my desired zones, it filters out all notifications. Any ideas on how to get it to function properly? I want to get notifications if there's a car in the driveway but not for one in the road but I don't want to filter out all road cars from recordings.
Version
0.12.0.3
Automation Config
Frigate Config
Any other relevant information
No response