MQTT sensor and binary sensor with voltage level

Hi there,

just joined the group of users to this great project.

I have implemented MQTT sensor and binary sensor, but would like them to support the knowledge of batterylevel… how is it possible to add this attribute.
The topic can be the same - just a different message that could be {“voltage” : 3.3}

Any ideas?
Regards

You could do it that way, if your sensor also uses json format. I would just include the battery level in every message it sends by {"your_sensor": "on", "voltage" : 3.3}

Or alternatively, send a message with a different topic for the battery level without json formatting in the message.

Yeah, but does that not mean another sensor?
For mqtt sensor it seems there is only one message/value

I’m sorry but I misread your original question. All my battery levels are in separate sensors. I don’t know how to add an attribute to a sensor.

From what I can see, you have to create template sensor from the attribute in order to use the value anyway, so I don’t see a great advantage in doing it.

No, you are right, but then a custom mqtt binary and sensor might be the way to go.

Anyone with that experience?