huawei_solar: [Bug]: Integration crashes from time to time

Describe the issue

After the HA Update to 2023.07.01 i updated the huawei_solar integration to 1.2.6b8. The problem with the python libaries seems to be gone. But from time to time the integration crashes, after restarting HA Core the integration runs for several hours and crashes again. The error occurs at 2023-07-12 09:57:08.379

Bescribe your Huawei Solar Setup

Inverter Type: SUN2000-8KTL-M1 Inverter Firmware version: V100R001C00SPC153 SDongle present: yes Power meter present: three phase Battery: LUNA2000 Battery Firmware version:

How do you connect to the inverter?

Over serial, with a serial-to-USB stick

Upload your Diagnostics File

Drag & Drop your Diagnostics File here. config_entry-huawei_solar-0fb10aad00efb384d23ddc00dbc8c83f.json.txt

Upload your relevant debug logs

023-07-12 09:57:04.355 DEBUG (SyncWorker_38) [pymodbus.logging] Getting transaction 39516
2023-07-12 09:57:04.355 DEBUG (SyncWorker_38) [pymodbus.logging] Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE"
2023-07-12 09:57:08.379 INFO (MainThread) [backoff] Backing off _do_read(...) for 1.0s (TimeoutError)
2023-07-12 09:57:08.379 DEBUG (MainThread) [huawei_solar.huawei_solar] Received <class 'TimeoutError'>: backing off reading for 1.0 seconds after 1 tries
2023-07-12 09:57:08.380 DEBUG (MainThread) [pymodbus.logging] Connection lost comm due to None
2023-07-12 09:57:08.381 DEBUG (MainThread) [pymodbus.logging] Getting transaction 5256
2023-07-12 09:57:09.381 ERROR (MainThread) [huawei_solar.huawei_solar] Modbus client is not connected to the inverter.
NoneType: None
2023-07-12 09:57:09.382 INFO (MainThread) [backoff] Backing off _do_read(...) for 1.0s (huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.)
2023-07-12 09:57:09.382 DEBUG (MainThread) [huawei_solar.huawei_solar] Received <class 'huawei_solar.exceptions.ConnectionInterruptedException'>: backing off reading for 1.0 seconds after 1 tries
2023-07-12 09:57:10.384 ERROR (MainThread) [huawei_solar.huawei_solar] Modbus client is not connected to the inverter.
NoneType: None
2023-07-12 09:57:10.385 INFO (MainThread) [backoff] Backing off _do_read(...) for 2.0s (huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.)
2023-07-12 09:57:10.385 DEBUG (MainThread) [huawei_solar.huawei_solar] Received <class 'huawei_solar.exceptions.ConnectionInterruptedException'>: backing off reading for 2.0 seconds after 2 tries
2023-07-12 09:57:12.386 ERROR (MainThread) [huawei_solar.huawei_solar] Modbus client is not connected to the inverter.
NoneType: None
2023-07-12 09:57:12.387 INFO (MainThread) [backoff] Backing off _do_read(...) for 4.0s (huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.)
2023-07-12 09:57:12.387 DEBUG (MainThread) [huawei_solar.huawei_solar] Received <class 'huawei_solar.exceptions.ConnectionInterruptedException'>: backing off reading for 4.0 seconds after 3 tries
2023-07-12 09:57:16.387 ERROR (MainThread) [huawei_solar.huawei_solar] Modbus client is not connected to the inverter.
NoneType: None
2023-07-12 09:57:16.389 INFO (MainThread) [backoff] Backing off _do_read(...) for 8.0s (huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.)
2023-07-12 09:57:16.389 DEBUG (MainThread) [huawei_solar.huawei_solar] Received <class 'huawei_solar.exceptions.ConnectionInterruptedException'>: backing off reading for 8.0 seconds after 4 tries
2023-07-12 09:57:18.430 ERROR (MainThread) [custom_components.huawei_solar] Timeout fetching BT2240017925_data_update_coordinator data
2023-07-12 09:57:18.431 DEBUG (MainThread) [custom_components.huawei_solar] Finished fetching BT2240017925_data_update_coordinator data in 20.060 seconds (success: False)
2023-07-12 09:57:18.447 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{% set meter_power = states('sensor.power_meter_active_power') | float %} {% set inverter_power = states('sensor.inverter_active_power') | float %} {{ (inverter_power - meter_power )  | float(0) }}' but no default was specified') while processing template 'Template<template=({% set meter_power = states('sensor.power_meter_active_power') | float %} {% set inverter_power = states('sensor.inverter_active_power') | float %} {{ (inverter_power - meter_power )  | float(0) }}) renders=4250>' for attribute '_attr_native_value' in entity 'sensor.house_power_consumption'
2023-07-12 09:57:19.079 DEBUG (SyncWorker_25) [pymodbus.logging] Current transaction state - TRANSACTION_COMPLETE

Please confirm the following:

  • The problem is still present in the latest release of this integration.
  • I did not find an existing issue describing this problem.
  • I did upload the diagnostics-file that I could retrieve from the ‘Devices & Services Page’
  • I did upload the relevant debug logs (via ‘Enable Debug Logging’-feature or by manually configuring HA logging)

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I have the impression that the automatic reconnect feature of pyModbus is broken. I’ve added some explicit reconnects when I detect the connection fails.

Please test again with 1.2.6 beta 9.

I’ve released 1.2.6 as a stable version

P.S. Is there a way to fill the gaps in the energy dashboard? I see data in the Fusion Solar App, so ideally missing data should be downloaded from there.

If you add the “Inverter total yield” sensor to your energy dashboard as the source of solar production, then you can at least have the total amount missing to a single hour (the hour when you restart the integration), so your monthly totals can still be fine. However, no hourly data will be added since that would need you to retroactively add data to Homa Assistant recorder (not going to work unless you make some manual database hacking)