Im trying to define an MQTT sensor with attributes, but I cannot get it to work using value templates. I would realy appreciate some help pointing me in the right direction.
So what I would like to do is converting an MQTT response into one entity with multiple attributes.
So for instance when
MQTT Topic is X/Y/Z
MQTT value is {“A”=“a”, “B”:“b” ,“C”:“c”, “D”:“d”, “E”:“e”},
I would like to create an entity A with attributes B=b, C=c, D=d and E=e
So now I’m puzzling around in the MQTT sensor docs, producing code like below, but without succes.
That won’t work. You can’t create a sensor with just attributes.
Make up your mind
First it was
MQTT value is A = {“B”:“b” ,“C”:“c”, “D”:“d”, “E”:“e”} (which is invalid json)
then
{“A”=“a”, “B”:“b” ,“C”:“c”, “D”:“d”, “E”:“e”}, (still invalid json)
then
{“B”:“b” ,“C”:“c”, “D”:“d”, “E”:“e”} (valid json, but without main working state_topic you will never get a working sensor)
Hi Francis, I did make up my mind, but may be failed in presenting it well.
I’m trying to understand how I can make attributes for a sensor from an MQTT message containing a json. Both the sensor value and the attributes must come from the json.
So for the previously send screenshot for instance, the sensor value could be B and the attributes C, D and E. I know I can define the sensor values with the value_template instruction, but I would like to know how i can make attributes for the rest of the values.
Sorry for annoying you with an unclear question.
PPee