I had referenced this in issue #116289 as well, but since that was closed, openi…ng as a new issue.
The Modbus connection to SMA no longer works since upgrading to 2024.4. I'm currently on 2024.5 and the issue persists.
What version of Home Assistant Core has the issue?
2024.4 onwards
What was the last working version of Home Assistant Core?
2024.3.3
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus/
Diagnostics information
No response
Example YAML snippet
```
modbus:
- name: SMA
type: tcp
host: 192.168.1.223 #fixed ip in SMA 192.168.1.223
port: 502
sensors:
- name: SMA_Power_AC
unit_of_measurement: W
slave: 3
address: 30775
data_type: int32
- name: PV Daily Yield
unit_of_measurement: kWh
slave: 3
address: 30517
scale: 0.001
precision: 3
data_type: uint64
- name: PV Total Production
unit_of_measurement: MWh
slave: 3
address: 30513
scale: 0.000001
precision: 3
data_type: uint64
- name: Grid Voltage
unit_of_measurement: V
slave: 3
address: 30783
scale: 0.01
precision: 2
data_type: uint32
- name: Grid frequency
unit_of_measurement: Hz
slave: 3
address: 30803
scale: 0.01
precision: 2
data_type: uint32
- name: SMA_temp
unit_of_measurement: °C
slave: 3
address: 30953
scale: 0.1
precision: 1
data_type: int32
- name: SMA_status
slave: 3
address: 30201
data_type: uint32
- name: SMA_grid
slave: 3
address: 30217
data_type: uint32
- name: Insulation
slave: 3
address: 30225
scale: 0.001
unit_of_measurement: kOhms
data_type: uint32
- name: SMA_Residual_current
slave: 3
address: 31247
scale: 1
unit_of_measurement: mA
data_type: int32
- name: Apparent Power
unit_of_measurement: VA
slave: 3
address: 30813
scale: 1
precision: 0
data_type: int32
- name: Reactive Power
unit_of_measurement: VAr
slave: 3
address: 30805
scale: 1
precision: 0
data_type: int32
```
Anything in the logs that might be useful for us?
```
2024-04-30 09:02:26.711 WARNING (MainThread) [pymodbus.logging] Failed to connect
2024-04-30 09:02:26.711 INFO (MainThread) [homeassistant.components.modbus.modbus] modbus SMA communication open
2024-04-30 09:02:27.372 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30775 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.372 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30517 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.373 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30513 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.373 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30783 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.381 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30803 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.381 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30953 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.381 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30201 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.381 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30217 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.381 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30225 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.382 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 31247 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.382 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30813 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
2024-04-30 09:02:27.382 DEBUG (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: SMA: Error: device: 3 address: 30805 -> Modbus Error: [Connection] Not connected[AsyncModbusTcpClient 192.168.1.223:502]
ValueError: Sensor sensor.modbus_sma_pv_power has device class 'None', state class 'None' unit 'W' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)
2024-04-30 09:02:53.982 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aac720>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_sma_pv_apparent_power has device class 'None', state class 'None' unit 'VA' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)
2024-04-30 09:02:53.990 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aac9a0>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_sma_pv_reactive_power has device class 'None', state class 'None' unit 'VAr' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)
2024-04-30 09:02:53.996 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aacc20>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_sma_pv_residual has device class 'None', state class 'None' unit 'mA' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)
2024-04-30 09:02:54.003 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aacea0>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_sma_temperature has device class 'None', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)
2024-04-30 09:02:54.008 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aad120>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'Not Measured'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_grid_frequency has device class 'None', state class 'None' unit 'Hz' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Not Measured' (<class 'str'>)
2024-04-30 09:02:54.013 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f9b85aad440>>(<Event homeassistant_start[L]>)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'Not Measured'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1322, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 41, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 491, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1075, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1261, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 837, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 439, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
raise ValueError(
ValueError: Sensor sensor.modbus_grid_voltage has device class 'None', state class 'None' unit 'V' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Not Measured' (<class 'str'>)
```
Additional information
Resetting the inverter will make the connection work for a limited time only. Couple hours at most.
_Originally posted by @SonnyBBQ in https://github.com/home-assistant/core/issues/116289#issuecomment-2084569884_