core: ValueError: Timeout value out of range - python3.12 issue - downgrade to 2024.2.4 fixes the issue
The problem
After updating to 2024.2.5 there are various python errors with the modbus intergration
My automation is sending modbus write registers to 2 solar inverters and both are failing after 2024.2.5
I can confirm after downgrading to 2024.2.4 the automations now work
What version of Home Assistant Core has the issue?
2024.2.5
What was the last working version of Home Assistant Core?
2024.2.4
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
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/automation/init.py”, line 666, in async_trigger
return await self.action_script.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 1600, in async_run
return await asyncio.shield(run.async_run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 435, in async_run
await self._async_step(log_exceptions=False)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 487, in _async_step
self._handle_exception(
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 512, in _handle_exception
raise exception
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 485, in _async_step
await getattr(self, handler)()
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 723, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 685, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/core.py”, line 2319, in async_call
response_data = await coro
^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/core.py”, line 2356, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/modbus/modbus.py”, line 184, in async_write_register
await hub.async_pb_call(
File “/usr/src/homeassistant/homeassistant/components/modbus/modbus.py”, line 485, in async_pb_call
result = await self.hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/modbus/modbus.py”, line 448, in pb_call
result: ModbusResponse = entry.func(address, value, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/pymodbus/client/mixin.py”, line 150, in write_register
return self.execute(
^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/pymodbus/client/base.py”, line 407, in execute
if not self.connect():
^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/pymodbus/client/tcp.py”, line 166, in connect
self.socket = socket.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/socket.py”, line 834, in create_connection
sock.settimeout(timeout)
ValueError: Timeout value out of range
Example YAML snippet
alias: 3.3 Dynamic Inverter Power - Custom Intergration - Gen24
description: Negtive FIT solar will match consumption of house and battery
trigger:
- platform: time_pattern
enabled: false
seconds: /2
- platform: state
entity_id:
- sensor.v5_scaled_power_custom_intergration
enabled: true
condition:
- condition: state
entity_id: binary_sensor.amber_grid_price_negative
state: "off"
- condition: state
entity_id: sun.sun
state: above_horizon
- condition: state
entity_id: binary_sensor.amber_feedin_price_negative
state: "on"
enabled: true
- condition: time
after: "09:30:00"
enabled: true
- condition: state
entity_id: binary_sensor.tesla_wall_connector_contactor_closed
state: "off"
enabled: true
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.amber_feedin_price_negative
state: "on"
- condition: state
entity_id: binary_sensor.daily_export_limit_reached
state: "on"
enabled: true
enabled: false
- condition: state
entity_id: input_boolean.new_solar_logic
state: "on"
action:
- alias: Set scaling factor 0-10000 being max
service: modbus.write_register
data:
hub: MBFronius_Gen24
address: 40232
slave: 1
value: "{{ states('sensor.v5_scaled_power_custom_intergration') | int }}"
- service: modbus.write_register
data:
address: 40233
unit: 1
value: 0
hub: MBFronius_Gen24
alias: Move to new power factor immediately
- service: modbus.write_register
data:
address: 40234
unit: 1
value: 0
hub: MBFronius_Gen24
alias: Set revert time to 0 - Stay at set power
- service: modbus.write_register
data:
address: 40235
unit: 1
value: 0
hub: MBFronius_Gen24
alias: Move to new power setpoint immediately
- service: modbus.write_register
data:
address: 40236
unit: 1
value: 1
hub: MBFronius_Gen24
alias: Enable throttle control - required for command to work
- service: modbus.write_register
data:
address: 40237
unit: 1
value: 1
hub: MBFronius_Gen24
enabled: false
mode: single
Anything in the logs that might be useful for us?
Modbus connections definded in my configuration.yaml
modbus:
- type: tcp
host: 192.168.1.143
port: 502
name: "MBFronius_Primo"
timeout: 5
- type: tcp
host: 192.168.1.231
port: 502
name: "MBFronius_Gen24"
timeout: 5
Referenced sensor in the automation (which does have values ranging from 1 - 10000
v5_scaled_power_custom_intergration:
friendly_name: "Inverter Scaled Power V5 Custom Integration"
value_template: "{{ ((states('sensor.house_power_value_divided_by_2_max5200_v4_custom_integration') | float) * 10000 / 5000) | round(0, 'floor') }}"
Additional information
as mentioned downgrading to 2024.2.4 fixes this issue
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Comments: 23 (11 by maintainers)
@janiversen @TETZUO Thanks, so I was stupid. Added a dummy entity looking for a random address and now it works again. Thanks
I use the modbus integration only for writing a value through automation/service as i get the return value through the SMA integration. I now added a dummy sensor too, it feels a bit stupid that i just spend hours searching as the error is just “unknown error” and was about to pull my hair out 😉 Ifinally found this entry. Thanks @Bucky2k for confirming it works and pointing me in the right direction.