Electrodacus SBMS0 - need help pulling MQTT values

I have tried various methods from the forum, but without any success.
When I subscribe to the topic from the HA, I get the data
This is one of my configuration attempts for “soc” value, but I would like to pull the data from other nested attributes like “cellsMV”.

# SBMS
mqtt:
  sensor:
  - name: "SBMS"
    state_topic: 'homeassistant/sensor/solar/sbms/'
    value_template: '{{ value_json.soc }}'
    json_attributes_topic: 'sbms'
    unit_of_measurement: '%'

This is the mqtt json message:

{
    "time": {
        "year": 0,
        "month": 1,
        "day": 1,
        "hour": 0,
        "minute": 11,
        "second": 38
    },
    "soc": 49,
    "cellsMV": [
        3223,
        3223,
        0,
        0,
        0,
        0,
        3223,
        3219
    ],
    "tempInt": 22.7,
    "tempExt": 21.8,
    "currentMA": {
        "battery": -48,
        "pv1": 0,
        "pv2": 0,
        "extLoad": 0
    },
    "ad2": 0,
    "ad3": 0,
    "ad4": 0,
    "heat1": 0,
    "heat2": 0,
    "flags": {
        "OV": false,
        "OVLK": false,
        "UV": false,
        "UVLK": false,
        "IOT": false,
        "COC": false,
        "DOC": false,
        "DSC": false,
        "CELF": false,
        "OPEN": false,
        "LVC": false,
        "ECCF": false,
        "CFET": true,
        "EOC": false,
        "DFET": true,
        "delta": 4
    }
}

For the first value:

value_template: '{{ value_json.cellsMV[0] }}'

The second

value_template: '{{ value_json.cellsMV[1] }}'

The third

value_template: '{{ value_json.cellsMV[2] }}'

Etc…

Thanks Tom for such a quick response, but I am not even able to get the values for unnested attributes like SOC, let allone cellsMV.

I just tried these two without success. Each time I have restarted the HA.

# SBMS
mqtt:
  sensor:
  - name: "SBMS"
    state_topic: 'homeassistant/sensor/solar/sbms/'
    value_template: '{{ value_json.cellsMV[0] }}'
    json_attributes_topic: 'sbms'
    unit_of_measurement: '%'
# SBMS
mqtt:
  sensor:
  - name: "SBMS"
    state_topic: 'homeassistant/sensor/solar/sbms/'
    value_template: '{{ value_json.cellsMV[0] }}'

What errors do you see in System → Logs.

Well, seams nothing related to it. Other mqtt integrations works.
Also, I understood if the mqtt topic has prefix “homeassistant” it should be autodiscovered, but that is also not the case.

2023-01-22 14:31:36.556 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration alexa_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.560 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration circadian_lighting which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.563 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hass_agent_mediaplayer which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.565 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration garbage_collection which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.567 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration waste_collection_schedule which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.570 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration rpi_gpio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.572 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration asusrouter which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.574 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration watchman which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.577 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.579 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hass_agent_notifier which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.581 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration alarmo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.583 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration thermal_comfort which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:31:36.585 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration scheduler which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-22 14:32:02.365 ERROR (MainThread) [homeassistant.components.tankerkoenig] The 'tankerkoenig' option near /config/configuration.yaml:2 has been removed, please remove it from your configuration
2023-01-22 14:32:05.242 WARNING (MainThread) [homeassistant.config_entries] Config entry 'EPSON XP-352 355 Series' for ipp integration not ready yet: Invalid response from API: Error occurred while communicating with IPP server.; Retrying in background
2023-01-22 14:32:05.462 WARNING (SyncWorker_0) [homeassistant.components.tankerkoenig] Found more than 10 stations to check. This might invalidate your api-key on the long run. Try using a smaller radius
2023-01-22 14:32:08.394 ERROR (MainThread) [homeassistant.components.binary_sensor] Platform tankerkoenig does not generate unique IDs. ID 173daa10-3967-462a-a464-d751725eadcc_status already exists - ignoring binary_sensor.avia_lachgartenweg_9_status
2023-01-22 14:32:08.412 ERROR (MainThread) [homeassistant.components.sensor] Platform tankerkoenig does not generate unique IDs. ID 173daa10-3967-462a-a464-d751725eadcc_e5 already exists - ignoring sensor.avia_lachgartenweg_9_super
2023-01-22 14:32:11.834 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for windriktmod2 @ 192.168.50.228: Error connecting to ('192.168.50.228', 6053): [Errno 113] Connect call failed ('192.168.50.228', 6053)
2023-01-22 14:32:11.839 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for sonoffr2 @ 192.168.50.70: Error connecting to ('192.168.50.70', 6053): [Errno 113] Connect call failed ('192.168.50.70', 6053)
2023-01-22 14:32:11.978 WARNING (MainThread) [homeassistant.config_entries] Config entry 'LG webOS TV 4690' for homekit_controller integration not ready yet: Timeout while waiting for connection to device 192.168.50.42:39501; Retrying in background
2023-01-22 14:32:12.128 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for power-monitor2 @ 192.168.50.215: Error connecting to ('192.168.50.215', 6053): [Errno 113] Connect call failed ('192.168.50.215', 6053)
2023-01-22 14:32:50.336 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: asusrouter
2023-01-22 14:33:50.428 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: asusrouter
2023-01-22 14:34:50.524 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: asusrouter
2023-01-22 14:35:03.057 WARNING (MainThread) [homeassistant.config_entries] Config entry '192.168.50.1' for asusrouter integration not ready yet: ('[Errno 104] Connection reset by peer', None); Retrying in background
2023-01-22 14:35:13.477 WARNING (MainThread) [aiohue.util] Received unexpected bridge id: 93eadbeef13
2023-01-22 14:35:13.588 WARNING (MainThread) [aiohue.util] Received unexpected bridge id: 93eadbeef13
2023-01-22 14:35:13.701 WARNING (MainThread) [aiohue.util] Received unexpected bridge id: 93eadbeef13
2023-01-22 14:35:13.720 WARNING (MainThread) [aiohue.util] Received unexpected bridge id: 93eadbeef13
2023-01-22 14:35:13.764 WARNING (MainThread) [aiohue.util] Received unexpected bridge id: 93eadbeef13

I have tried Node-Red HA addon to read the MQTT message, and it shows it in the debug window.
Is there anything else besides the custom sensor in the configuration.yaml i could check?

Could anybody shed some light on this?

Thanks, but as I have said, I have already tried that.

Problem solved. It was “/” at the end of the topic. I am not a coder, and however it is simple, very new to me, but I am really surprised nobody noticed that from the experienced users.

Hi Fibra,

I have my sbms connected to my broker and receiving data. would you mind sharing what you did next, to use this data within Home assistant.

Thanks!

If I wanted to get this “battery” data:
currentMA": {
“battery”: -48

how would the template need to be arranged, " {{ value_json.currentMA[battery] }}" ?

Thanks

Sorry for late reply. This is my mqtt.yaml

# SBMS Sensor /////////////////////////////////////////////////////////////////
  - name: "SBMS SOC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.soc }}'
    unit_of_measurement: '%'
    icon: "mdi:home-battery"

  - name: "SBMS Cell 1"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[0]}}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 2"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[1] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 3"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[2] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 4"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[3] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 5"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[4] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 6"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[5] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 7"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[6] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell 8"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.cellsMV[7] }}'
    unit_of_measurement: 'V'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Cell Delta"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.delta }}'
    unit_of_measurement: 'mV'
    icon: "mdi:battery-charging-low"
    
  - name: "SBMS Temp Int"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.tempInt }}'
    unit_of_measurement: '°C'
    icon: "mdi:thermometer"
    
  - name: "SBMS Battery Temp"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.tempExt }}'
    unit_of_measurement: '°C'
    icon: "mdi:thermometer"
    
  - name: "SBMS Battery Current"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.currentMA.battery| float / 1000  | round(2) }}'
    unit_of_measurement: 'A'
    icon: "mdi:home-battery"

  - name: "SBMS PV1 Current"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.currentMA.pv1 | float / 1000 | round(2) }}'
    unit_of_measurement: 'A'
    icon: "mdi:solar-power-variant"

  - name: "SBMS DFET"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.DFET }}'
 
  - name: "SBMS CFET"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.CFET }}'

  - name: "SBMS EOC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.EOC }}'
    
  - name: "SBMS OV"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.OV }}'
    
  - name: "SBMS UV"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.UV }}'
    
  - name: "SBMS OVLK"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.OVLK }}'
    
  - name: "SBMS UVLK"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.UVLK }}'
    
  - name: "SBMS COC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.COC }}'
    
  - name: "SBMS DOC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.DOC }}'
    
  - name: "SBMS DSC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.DSC }}'
    
  - name: "SBMS CELF"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.CELF }}'
    
  - name: "SBMS OPEN"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.OPEN }}'
    
  - name: "SBMS LVC"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.LVC }}'
    
  - name: "SBMS ECCF"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.ECCF }}'
    
  - name: "SBMS IOT"
    state_topic: 'homeassistant/sensor/solar/sbms'
    value_template: '{{ value_json.flags.IOT }}'

This is my sensors.yaml
Here I have a few calculations as those values are not sent from the SBMS.

# SBMS0 Load Current 
  - platform: template
    sensors:
      sbms_load_current_calc_3:
        value_template: "{{ states('sensor.sbms_pv1_current') | float - states('sensor.sbms_battery_current') | float }}"
        unit_of_measurement: "A"
        unique_id: sbms_load_calc
        
# SBMS0 Voltage 
  - platform: template
    sensors:
      sbms_voltage_calc:
        value_template: "{{ states('sensor.sbms_cell_1') | float + states('sensor.sbms_cell_2') | float + states('sensor.sbms_cell_3') | float + states('sensor.sbms_cell_4') | float + states('sensor.sbms_cell_5') | float + states('sensor.sbms_cell_6') | float + states('sensor.sbms_cell_7') | float + states('sensor.sbms_cell_8') | float }}"
        unit_of_measurement: "V"
        unique_id: sbms_vol_calc
        
# SBMS0 Calculated PV Power
  - platform: template
    sensors:
      sbms_pv_power_calc:
        value_template: "{{ (states('sensor.sbms_pv1_current') | float * states('sensor.sbms_voltage_calc') | float) | int }}"
        unit_of_measurement: "W"
        unique_id: sbms_pv_pwr_calc
        
# SBMS0 Calculated Battery Power
  - platform: template
    sensors:
      sbms_batt_power_calc:
        value_template: "{{ (states('sensor.sbms_battery_current') | float * states('sensor.sbms_voltage_calc') | float) | int }}"
        unit_of_measurement: "W"
        unique_id: sbms_batt_pwr_calc

This might be useful too. Custom addons are needed for these.

cell voltages

Custom button card

positions:
  value: inside
  icon: 'off'
  indicator: false
  name: outside
type: custom:bar-card
width: 95%
height: 25
title: Battery Cell Voltage
entities:
  - entity: sensor.sbms_cell_1
    name: 1
  - entity: sensor.sbms_cell_2
    name: 2
  - entity: sensor.sbms_cell_3
    name: 3
  - entity: sensor.sbms_cell_4
    name: 4
  - entity: sensor.sbms_cell_5
    name: 5
  - entity: sensor.sbms_cell_6
    name: 6
  - entity: sensor.sbms_cell_7
    name: 7
  - entity: sensor.sbms_cell_8
    name: 8
color: orange
min: '2500'
max: '3650'

statuses

type: horizontal-stack
cards:
  - type: custom:button-card
    color_type: card
    entity: sensor.sbms_eoc
    state:
      - value: unavailable
        color: red
        name: UNAVAILABLE
        icon: mdi:battery-unknown
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'False'
        color: lightgray
        name: EOC
        icon: mdi:battery-charging-60
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'True'
        color: green
        name: EOC
        icon: mdi:battery-charging-100
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
  - type: custom:button-card
    color_type: card
    entity: sensor.sbms_ov
    state:
      - value: unavailable
        color: red
        name: UNAVAILABLE
        icon: mdi:battery-unknown
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'False'
        color: lightgray
        name: OV
        icon: mdi:battery-alert
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'True'
        color: red
        name: OV
        icon: mdi:battery-alert
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
            - animation: blink 2s ease infinite
  - type: custom:button-card
    color_type: card
    entity: sensor.sbms_uv
    state:
      - value: unavailable
        color: red
        name: UNAVAILABLE
        icon: mdi:battery-unknown
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'False'
        color: lightgray
        name: UV
        icon: mdi:battery-alert
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'True'
        color: red
        name: UV
        icon: mdi:battery-alert
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
            - animation: blink 2s ease infinite
  - type: custom:button-card
    color_type: card
    entity: sensor.sbms_dfet
    state:
      - value: unavailable
        color: red
        name: UNAVAILABLE
        icon: mdi:battery-unknown
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'False'
        color: red
        name: UV
        icon: mdi:battery-arrow-down
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
            - animation: blink 2s ease infinite
      - value: 'True'
        color: orange
        name: DFET
        icon: mdi:battery-arrow-down
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
  - type: custom:button-card
    color_type: card
    entity: sensor.sbms_cfet
    state:
      - value: unavailable
        color: red
        name: UNAVAILABLE
        icon: mdi:battery-unknown
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
      - value: 'False'
        color: gray
        name: CFET
        icon: mdi:battery-arrow-up
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold
            - animation: blink 2s ease infinite
      - value: 'True'
        color: orange
        name: CFET
        icon: mdi:battery-arrow-up
        styles:
          card:
            - height: 50px
            - font-size: 10px
            - font-weight: bold

Apexcharts Card

graphs

type: custom:apexcharts-card
graph_span: 24h
span:
  start: day
header:
  show: true
  title: SBMS0
  show_states: true
  colorize_states: true
apex_config:
  tickAmount: 4
  chart:
    height: 250
  stroke:
    width: 2
    curve: smooth
now:
  show: true
  color: red
series:
  - entity: sensor.sbms_pv1_current
    type: line
    name: PV
    group_by:
      func: avg
      duration: 10min
  - entity: sensor.sbms_battery_current
    type: line
    name: Battery
    group_by:
      func: avg
      duration: 10min
  - entity: sensor.sbms_load_current_calc_3
    type: line
    name: Load
    group_by:
      func: avg
      duration: 10min