Hi all,
I am trying to create a binary sensor from a mqtt topic
the topic message is a json formated text.
What am i doing wrong here? Please advice
{
"fileName": "e:\\my\\desktop\\default_123.jpg",
"baseName": "default_123.jpg",
"summary": "Person (90%); Person (84%); Person (72%); Eve (72%); Nick (68%); Mitchell (74%); Sander (67%); Potted Plant (79%)",
"state": "on",
"analysisDurationMS": 1658,
"time": "2021-04-06T20:53:20.6519257+02:00",
"camera": "Default",
"predictions": [
{
"label": "Person",
"detail": "",
"userID": "",
"confidence": 90.498084,
"y_min": 196,
"x_min": 698,
"y_max": 869,
"x_max": 1174,
"server": "Deepstack_Objects:192.168.178.11:80"
},
{
"label": "Person",
"detail": "",
"userID": "",
"confidence": 83.931416,
"y_min": 422,
"x_min": 343,
"y_max": 874,
"x_max": 622,
"server": "Deepstack_Objects:192.168.178.11:80"
},
{
"label": "Person",
"detail": "",
"userID": "",
"confidence": 71.93728700000001,
"y_min": 223,
"x_min": 542,
"y_max": 871,
"x_max": 869,
"server": "Deepstack_Objects:192.168.178.11:80"
},
{
"label": "Eve",
"detail": "",
"userID": "",
"confidence": 72.01924,
"y_min": 159,
"x_min": 462,
"y_max": 296,
"x_max": 561,
"server": "Deepstack_Faces:192.168.178.11:80"
},
{
"label": "Nick",
"detail": "",
"userID": "",
"confidence": 68.0404,
"y_min": 463,
"x_min": 386,
"y_max": 583,
"x_max": 489,
"server": "Deepstack_Faces:192.168.178.11:80"
},
{
"label": "Mitchel",
"detail": "",
"userID": "",
"confidence": 74.34667,
"y_min": 328,
"x_min": 644,
"y_max": 461,
"x_max": 749,
"server": "Deepstack_Faces:192.168.178.11:80"
},
{
"label": "Sander",
"detail": "",
"userID": "",
"confidence": 67.338735,
"y_min": 341,
"x_min": 903,
"y_max": 554,
"x_max": 1062,
"server": "Deepstack_Faces:192.168.178.11:80"
},
{
"label": "Potted Plant",
"detail": "",
"userID": "",
"confidence": 79.16054,
"y_min": 1,
"x_min": 0,
"y_max": 603,
"x_max": 400,
"server": "Deepstack_Objects:192.168.178.11:80"
}
]
} %}
- platform: mqtt
name: "Sander is Home"
state_topic: "ai/Default/motion/"
value_template: >
{% set ns = namespace(found = false) %}
{% for match in camera_json.predictions %}
{% if match.label == 'Sander' and match.confidence >=10 %}
{% set ns.found = true %}
ON
{% endif %}
{% endfor %}
off_delay: 5
device_class: motion
payload_on: "ON"