I am using MQTT auto-discovery to automatically register a custom sensor system that runs on a Raspberry PI and monitors a JBD battery management system. There are 4 distinct values that I want to display in Home Assistant. I am able to (apparently) successfully register the topic homeassistant/sensor/pickle-bms-1/config using this json:
{
"state_topic": "homeassistant/sensor/pickle-bms-1/state",
"unique_id": "bms-1",
"name": "LiFePO4 North",
"dev": {
"ids": "bms-1",
"name": "LiFePO4 North",
"mf": "JBD",
"mdl": "51.2V50AH-F12YJ058",
"sn": "a5:c2:39:16:81:aa"
},
"o": {
"name": "Raspberry Pi5",
"sw": "pickle-telemetry"
},
"cmps": {
"bms-1-volts": {
"p": "sensor",
"device_class": "voltage",
"unit_of_measurement": "V",
"unique_id": "bms-1-volts",
"value_template": "{{ value_json.volts | float }}"
},
"bms-1-amps": {
"p": "sensor",
"device_class": "current",
"unit_of_measurement": "A",
"unique_id": "bms-1-amps",
"value_template": "{{ value_json.amps | float }}"
},
"bms-1-percent": {
"p": "sensor",
"device_class": "battery",
"unit_of_measurement": "%",
"unique_id": "bms-1-percent",
"value_template": "{{ value_json.percent | float }}"
},
"bms-1-temp": {
"p": "sensor",
"device_class": "temperature",
"unit_of_measurement": "\\u00b0F",
"unique_id": "bms-1-temp",
"value_template": "{{ value_json.temp | float }}"
}
}
}
However, subsequently sending this sensor state data to topic homeassistant/sensor/pickle-bms-1/state using this json isn’t working as expected or desired:
{
"volts": 51.52,
"amps": -0.02,
"percent": 21,
"temp": 86.7
}
What I see is raw JSON data, which isn’t parsed as specified by the config block value_template values:
Can anyone point out what I am doing wrong? I would be eternally grateful! Thanks…
- Michael
