Hi,
I’m trying to pull use the status of a parameter in a MQTT event, but I’m struggling. It’s the events from Frigate:
{
"before": {
"id": "1723929993.368527-ptvntr",
"camera": "dahua",
"frame_time": 1723937222.060817,
"snapshot": {
"frame_time": 1723929993.424929,
"box": [
456,
144,
854,
554
],
"area": 163180,
"region": [
164,
0,
1280,
1116
],
"score": 0.99609375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.99609375,
"false_positive": false,
"start_time": 1723929993.368527,
"end_time": null,
"score": 0.97265625,
"box": [
456,
147,
850,
553
],
"area": 159964,
"ratio": 0.9704433497536946,
"region": [
381,
75,
929,
623
],
"stationary": true,
"motionless_count": 72292,
"position_changes": 0,
"current_zones": [],
"entered_zones": [],
"has_clip": false,
"has_snapshot": false,
"attributes": {},
"current_attributes": []
},
"after": {
"id": "1723929993.368527-ptvntr",
"camera": "dahua",
"frame_time": 1723937282.209351,
"snapshot": {
"frame_time": 1723929993.424929,
"box": [
456,
144,
854,
554
],
"area": 163180,
"region": [
164,
0,
1280,
1116
],
"score": 0.99609375,
"attributes": []
},
"label": "car",
"sub_label": null,
"top_score": 0.99609375,
"false_positive": false,
"start_time": 1723929993.368527,
"end_time": null,
"score": 0.97265625,
"box": [
461,
147,
849,
553
],
"area": 157528,
"ratio": 0.9556650246305419,
"region": [
380,
75,
928,
623
],
"stationary": true,
"motionless_count": 72894,
"position_changes": 0,
"current_zones": [],
"entered_zones": [],
"has_clip": false,
"has_snapshot": false,
"attributes": {},
"current_attributes": []
},
"type": "update"
}
I’m trying to use after snapshot status. I have a sensor that displays the value which is as expected:
- sensor:
name: Dahua Snapshot Test
state_topic: "frigate/events"
value_template: |-
{% if value_json['after']['camera'] == 'dahua' %}
{{ value_json['after']['has_snapshot'] }}
{% else %}
{{ 'null' }}
{% endif %}
It returns false:
I can’t match the false with an if statement though. I’ve tried it all lowercase and with a capital F, but it just won’t match. The sensor just stays off.
- binary_sensor:
name: Dahua Snapshot Status
off_delay: 10
state_topic: "frigate/events"
value_template: "{{ 'ON' if value_json['after']['has_snapshot'] == 'false' else 'OFF' }}"