Reading data from a BMS and I’ve manually configured a couple of the entities for testing. They receive the value of the cell or pack in the UI but it only briefly flashes the value and reverts to 0. What am I missing? Maybe QOS?
Every time a message comes in on the topic you put in state_topic it tries to set the value of the sensor by executing your value_template against it. So when this message come in on data/bms/gauge:
{
"meter": "bms",
"cell1": 3348,
"cell2": 3351
}
Then sensor.battCell1 gets value 3348. But sensor.packVolt becomes unknown and raises an error because that message does not have a volts field.
And then when this message comes in on that topic:
Then the opposite occurs. Now sensor.packVolt has value 26.54 but sensor.battCell1 become unknown and raises an error since that message has no cell1 field.
Since those messages have totally different schemas you should send them to different topics. If that’s not possible it’s going to be challenging to work with them in HA. You’ll need to do something like what I outlined here instead of a normal Mqtt sensor:
Yea if it must send that all to the same topic then I’d look at my trigger template sensor suggestion in my link above. I imagine you’ll find that easier then trying to use an Mqtt sensor here as you can filter out which messages set the state in the trigger.