But also; if you could define a single sensor for each object, instead of 5 or 6 - then I think things would be a lot tidier. It’s fine if you only have several such devices, but I intend to have up to 15 of these things. In that scenario, 75 sensors might be excessive
Understood, though attributes are not really first-class objects and if the values are important, you’ll likely find yourself fighting with HA. I’m not 100% sure, but I don’t think that you can fire automations based on changes in the state of attributes vs. the state of the entity. And if you want to look at the history, or feed the data into some other database (like in my case, InfluxDB).
All in all, I think that adding more entities isn’t really a huge heavyweight thing if you’re going to use them somehow and need to extract their values.
The example sensor below shows a configuration example which uses JSON in the state topic to add extra attributes. It also makes use of the availability topic. Attributes can then be extracted in Templates;
Example to extract data from the sensor below '{{ states.sensor.bs_client_name.attributes.ClientName }}'
Within HA I can define a sensor like so
sensor rfbridgeResult:
- platform: mqtt
name: “RFBridgeResult”
state_topic: “tele/sonoffRFridge/RESULT”
value_template: ‘{{ value_json.RfReceived.RfKey }}’
expire_after: 20
json_attributes:
- RfReceived
The value template works fine but where im struggling is to sort out the other attributes
if I use the above json_attributes section then the attributes is a single object with the JSON string.
I thought i could use
json_attributes:
-RfReceived.Sync
This results in a sensor called ‘sensor.bedroom_light’. The attributes defined under json_attributes are gleaned using templates like (case sensitive):
{{ states.sensor.bedroom_light.attributes.Vcc }}
Without the json_attributes entry, the values all seem to be lumped in as the ‘state’ and I cannot access them programatically within Home Assistant. So re-reading your post - I think the value_template: ‘{{ value_json }}’ part should free things up so that everything tasmota sends is accessible.