I’ve tried and have spent enough time trying similar things people have done to no avail for what I am trying to do. I use Double Take for facial recognition and it uses MQTT to communicate with HA and what I want to do is create an automation that TTS plays the name of the person who has been identified over some speakers. So far, I can get it going for specific person, but I don’t want to have to add people over and over. I wanted to use templating to have it insert person’s name based off of the data that is in MQTT.
It is in two places. A topic named after person is one of them, but I couldn’t figure out how to use that or create a sensor based off the name of a topic, only data inside of it. It’s also in a topic named after the camera that spotted them. With multiple cameras, I preferred the idea of using the topic that is created with their name, but if I can at least get it down to a particular camera, better than where I am now. Inside the camera topic, here is the data below. Same kind of data is in person’s name topic, but if I had to use the data inside the topic instead of the topic itself, then it my as well be in the camera topic that I get it from. I mostly was getting “UndefinedError: ‘value_json’ is undefined” using the template testing part of HA. Sensor itself had nothing in that I created.
That is a topic example of a person when they have been identified. All other identified people would have a topic created inside of the topic “double-take/matches/”. I would prefer to use the subtopic created inside of the “double-take/matches/” topic as part of the template, that way when I have automation use TTS to read their name, I could type in some code that uses their name as what to say, which would be the “john-doe” subtopic for example, anything inside the “double-take/matches/” topic.
double-take/cameras/example_camera is another topic that has the name inside of the payload, but preferably I would do the first way as it is applicable to any camera.
Thanks. The result just says what is after the “double-take/matches/”. I don’t know how to change any of that to make it says what is actually after the real MQTT topic that starts with “double-take/matches/”.
Current automation is this while testing with one particular name. The last part is there to name the camera the identified person was spotted in front of. I would need to adapt it so that it pulls the camera name from the right person. The “state” of that entity that Double Take creates is always the latest camera they were spotted in front of, which is why that works for that.
alias: Double Take Test
description: ""
trigger:
- platform: mqtt
topic: double-take/matches/john-doe
condition: []
action:
- service: tts.google_translate_say
data:
entity_id: media_player.example_speaker
message: >-
Attention: John Doe detected on the {{
states('sensor.double_take_john_doe') | replace("_", " ") |
title }}
mode: single
Awesome! Thanks, figured out how to put that into TTS action. Last bit to this since I also need to adapt the camera name and since the camera name is in the payload of the trigger topic as you can see from the first post, it looks like I can pull that out. I just couldn’t figure out how to pull it out with any info I found on this.