I’ve been running PIR sensors from the previous “platform MQTT” section for a long time.
This is successfully migrated to the new MQTT config section, adding a “sensor”
Next step: I’d like the sensor to match a correct device_class.
The MQTT value is:
{
"status": "No Motion",
"battery": "9",
"rssi": "5"
}
For example.
In the MQTT config section I have a working RSSI value returned:
sensor:
- name: "RSSI_PIR_Bijkeuken"
state_topic: "homeassistant/visonic/E3ACAB"
value_template: '{{ value_json.rssi }}'
Now I’ve also added a “binary_sensor” in the mqtt config, which doesn’t work:
binary_sensor:
- name: "PIR_Living"
state_topic: "homeassistant/visonic/E3ARE2"
device_class: Motion
value_template: "{% if value_json.status == 'No Motion' %} false {% elif value_json.status == 'Motion' %} true {% endif %}"
The binary sensor does show up as entity, with the status ‘unknown’.
I’ve been going around in circles and grew a few gray in the process.
What am I missing?
When this step works, I want to add multiple json attributes to 1 device.
Not sure yet how to proceed, but I found a direction with: json_attributes_topic
If you have any direction on this path, I’m all ears.