Display array of cell voltages from MQTT

Hello, I’m just getting into HA, and MQTT for that matter :slight_smile:

I have 2 Bluetti AC300’s with 2 battery packs each. Each pack contains a number of battery cells. I recently discovered this bluetti_mqtt package (GitHub - warhammerkid/bluetti_mqtt: MQTT interface for Bluetti power stations), along with this HA addon to bring the plugin into HA (https://github.com/SSMCD/bluetti2mqtt). So far, so good. I can see a ton of data in lovelace.

One thing I noticed is that in HA (lovelace card), each battery pack level is shown as a percentage. When I use MQTT Explorer addon, I can see there is actually more data about each cell voltage in each pack. It’s in a json array, which looks like:

Topic: bluetti/state/[DEVICE NAME]/pack_details1

pack_details1 = {
  "percent":100,
  "voltages":[3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.34,3.35,3.34,3.34,3.35]
}

I’ve been reading the docs on HA/MQTT, as well as this forum (and google), but can’t see a way to list the 16 individual cell voltages from the array. So far, with the above software, I haven’t had to create any MQTT devices manually (like add them to a config) as they were all autodiscovered due to the bluetti_mqtt python script. Ideally I’d have all 16 voltages broken out and displayed, but am unsure how to go about accomplishing this. This is a known issue with the package but the author doesn’t seem to want to add the cell details as he thinks it won’t be useful to many people (Add ability too see cell voltage. · Issue #54 · warhammerkid/bluetti_mqtt · GitHub).

I’m not automatically configuring this in Home Assistant because it doesn’t seem useful to most users, but you can add your own sensor if you’d like this information.

Would someone be willing to give a hand or some pointers on the “but you can add your own sensor” part? I’ve been trying to hack this for 2 days and just not getting anywhere. I just can’t find anything in the docs dealing with arrays like this. They all seem to deal with single entities.

mqtt:
  sensor:
    - name: "Cell 1 Voltage"
      state_topic: "bluetti/state/[DEVICE NAME]/pack_details1"
      unit_of_measurement: "V"
      device_class: "voltage"
      state_class: "measurement" # only if you want long term statistics 
      value_template: "{{ value_json.voltages[0] }}"
   - name: "Cell 2 Voltage"
      state_topic: "bluetti/state/[DEVICE NAME]/pack_details1"
      unit_of_measurement: "V"
      device_class: "voltage"
      state_class: "measurement" # only if you want long term statistics 
      value_template: "{{ value_json.voltages[1] }}"
   - name: "Cell 3 Voltage"
      state_topic: "bluetti/state/[DEVICE NAME]/pack_details1"
      unit_of_measurement: "V"
      device_class: "voltage"
      state_class: "measurement" # only if you want long term statistics 
      value_template: "{{ value_json.voltages[2] }}"
   - name: "Cell 4 etc...

Thank you @tom_l , that’s very helpful. So I take it there’s no way to automatically do that for each item in the array? Each device can have up to (4) 3kWh battery packs attached (each with 16 cells), so that’s 64 entries x 2 devices for a total of 128 sensor entries.

Only if the developer wants to, which it appears they do not.

It worked great, thank you! Now to build the display in lovelace.

Hello I have ac300 too, have raspberry pi with home assistant, but no luck to integrate to home asisdtant