I have been able to add a few MQTT sensors to my Home Assistant instance but I’m having issues with one motion sensor. All of my sensors except the motion sensor send individual topics back to the MQTT broker. With each of those topics I am able to add them to the YAML file without issue and they work as expected (see green box within the below screenshot). When the motion sensor sends its data back to the MQTT broker it does so with all the individual topics in a single line under “status” (see red box within the below screenshot. How do I go about splitting off each topic from the status line within the YAML file so I can use each within Home Assistant?
I can’t see the screenshot (corporate firewall blocking it). Can you either paste it as formatted text (preferred) or drag and drop the image into a post?
That MQTT topic is returning JSON instead of a simple true/false string. You need to add a value_template line to tell it to look for the true/false string in the motion part of the JSON string.
That means the template is always reporting OFF and never ON. In this case it may be due to how true is interpreted. Currently it’s being handled as a string value but it may in fact be understood as a boolean value. It’s easy to confirm test that hypothesis.
Replace the existing value_template with this:
value_template: "{{ 'ON' if value_json.motion else 'OFF' }}"