MQTT with external broker

I have switched from ioBroker (which I used 8 years) to Home Assistant. So I’m new to it. HA is running in an LXC container. Currently, I’m struggling a bit with MQTT. I have an external broker in the LAN that provides all the topics. Essentially, I’m focusing on the topics from my OpenWB (wallbox, this is already working in HA) and my Victron battery inverter.

I have loaded the MQTT integration in HA. The “online” topic is also received by my broker, which I verified using MQTT Explorer. All other device values are also present there and are being updated.

Now I’d like to integrate the MQTT values as sensors and switches, among other things. It worked with OpenWB. Now it’s Victron’s turn. I followed this guide (excluding the MQTT part):
Complete Setup Guide - ESS Multiplus Control via MQTT.

The sensors, etc., are now visible in the overview, but unfortunately, no values are being received. I’ve adjusted the unique number of the Victron and the VEBUS number to match my system.

How can I check what’s causing this issue? In the log, I only find this note:

Logger: homeassistant.components.mqtt.models
Quelle: components/mqtt/models.py:366
Integration: MQTT (Dokumentation, Probleme)
Erstmals aufgetreten: 10:55:34 (4 Vorkommnisse)
Zuletzt protokolliert: 10:56:00

Exception raised while updating state of sensor.dc_load, topic: 'victron/N/e45f01b71ced/system/0/Batteries' with payload: b'{"value":[{"active_battery_service":true,"current":0.5,"id":"com.victronenergy.vebus.ttyUSB0","instance":288,"name":"MultiPlus-II 48/5000/70-50","power":53,"soc":80.0,"state":1,"voltage":53.459999084472656}]}'
Exception raised while updating state of sensor.battery_soc, topic: 'victron/N/e45f01b71ced/system/0/Batteries' with payload: b'{"value":[{"active_battery_service":true,"current":0.5,"id":"com.victronenergy.vebus.ttyUSB0","instance":288,"name":"MultiPlus-II 48/5000/70-50","power":53,"soc":80.0,"state":1,"voltage":53.459999084472656}]}'
Exception raised while updating state of sensor.ac_load, topic: 'victron/N/e45f01b71ced/vebus/288/Ac/Out/P' with payload: b'{"value":0}'
Exception raised while updating state of sensor.system_temperature, topic: 'victron/N/e45f01b71ced/vebus/288/Dc/0/Temperature' with payload: b'{"value":null}'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 640, in state
    numerical_value = float(value)  # type:ignore[arg-type]
ValueError: could not convert string to float: '{ { value_json.value[0].power|float(0)|round(0) }}'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 366, in process_write_state_requests
    entity.async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in async_write_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1029, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 642, in state
    raise ValueError(
    ...<5 lines>...
    ) from err
ValueError: Sensor sensor.dc_load has device class 'power', state class 'None' unit 'W' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '{ { value_json.value[0].power|float(0)|round(0) }}' (<class 'str'>)

Thanks a lot!

There is a superfluous blank between your double opening brackets.

1 Like

thanks. now it is working. sorry for this mistake. I’m new at ha.