wlcrs / huawei_solar

Home Assistant integration for Huawei Solar inverters via Modbus
GNU Affero General Public License v3.0
550 stars 88 forks source link

[Bug]: AttributeError: 'NoneType' object has no attribute 'platform_name' #564

Closed fth1963 closed 10 months ago

fth1963 commented 10 months ago

Describe the issue

All data shown as "Unavailable" even after multiple HA restarts. Has been running without issues for several months. No config changes of any kind for months. Core: 2023.12.3 Supervisor: 2023.12.0 Operating System: 11.2 UI: 20231208.2

Bescribe your Huawei Solar Setup

Inverter Type: Huawier Solar SUN2000-10KTL-M1 Inverter Firmware version:V100R001C00SPC153 SDongle present: yes type: SDongleA-05 Power meter present: three phase Battery: None Battery Firmware version: n/a

How do you connect to the inverter?

Via the SDongle, wired connection

Upload your Diagnostics File

Drag & Drop your Diagnostics File here.{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.12.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "aarch64", "timezone": "Europe/Copenhagen", "os_name": "Linux", "os_version": "6.1.58-haos-raspi", "supervisor": "2023.12.0", "host_os": "Home Assistant OS 11.2", "docker_version": "24.0.7", "chassis": "embedded", "run_as_root": true }, "custom_components": { "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "hikvision_next": { "version": "1.0.10", "requirements": [ "xmltodict==0.13.0", "hikvisionapi==0.3.2", "requests-toolbelt==0.10.1" ] }, "dwains_dashboard": { "version": "3.6.0", "requirements": [] }, "energidataservice": { "version": "1.4.3", "requirements": [ "async-retrying-ng==0.1.3", "CurrencyConverter==0.17.13" ] }, "easee": { "version": "0.9.55", "requirements": [ "pyeasee==0.7.55" ] }, "fusion_solar": { "version": "3.0.0", "requirements": [] }, "nordpool": { "version": "0.0.14", "requirements": [ "nordpool>=0.2", "backoff" ] }, "ble_monitor": { "version": "12.7.1", "requirements": [ "pycryptodomex>=3.18.0", "janus>=1.0.0", "aioblescan>=0.2.14", "btsocket>=0.2.0", "pyric>=0.1.6.3" ] }, "huawei_solar": { "version": "1.2.9", "requirements": [ "huawei-solar==2.2.9" ] }, "mbapi2020": { "version": "0.9.8", "requirements": [ "protobuf>=3.19.1" ] } }, "integration_manifest": { "domain": "huawei_solar", "name": "Huawei Solar", "after_dependencies": [ "usb" ], "config_flow": true, "documentation": "https://github.com/wlcrs/huawei_solar/wiki", "issue_tracker": "https://github.com/wlcrs/huawei_solar/issues", "requirements": [ "huawei-solar==2.2.9" ], "codeowners": [ "@wlcrs" ], "iot_class": "local_polling", "version": "1.2.9", "loggers": [ "huawei_solar", "pymodbus" ], "is_built_in": false }, "data": { "config_entry_data": { "host": "192.168.20.150", "port": 502, "slave_ids": [ 1, 16 ], "enable_parameter_configuration": true, "username": null, "password": null }, "slave_0": { "model_name": "SUN2000-10KTL-M1\u0000\u0000\u0000\u0000SUN2000-12", "pv_string_count": 2, "has_optimizers": 12, "battery_type": 0, "battery_1_type": 0, "battery_2_type": 0, "power_meter_type": 1, "supports_capacity_control": false }, "slave_0_data": { "input_power": [ 0, "W" ], "line_voltage_A_B": [ 396.6, "V" ], "line_voltage_B_C": [ 396.0, "V" ], "line_voltage_C_A": [ 395.6, "V" ], "phase_A_voltage": [ 229.2, "V" ], "phase_B_voltage": [ 228.5, "V" ], "phase_C_voltage": [ 228.3, "V" ], "phase_A_current": [ 0.0, "A" ], "phase_B_current": [ 0.0, "A" ], "phase_C_current": [ 0.0, "A" ], "day_active_power_peak": [ 46, "W" ], "active_power": [ 0, "W" ], "reactive_power": [ 0, "VA" ], "power_factor": [ 0.0, null ], "grid_frequency": [ 49.96, "Hz" ], "efficiency": [ null, "%" ], "internal_temperature": [ 30.1, "\u00b0C" ], "insulation_resistance": [ 30.0, "MOhm" ], "device_status": [ "Shutdown: command", null ], "fault_code": [ 0, null ], "startup_time": [ "2023-12-21T08:21:12+00:00", null ], "shutdown_time": [ "2023-12-21T08:38:59+00:00", null ], "accumulated_yield_energy": [ 11382.75, "kWh" ], "daily_yield_energy": [ 0.01, "kWh" ], "state_1": [ [ "Normal stop", "Shutdown" ], null ], "state_2": [ [ "Locked", "PV connected", "DSP data collection" ], null ], "state_3": [ [ "On-grid", "Off-grid switch disabled" ], null ], "alarm_1": [ [], null ], "alarm_2": [ [], null ], "alarm_3": [ [], null ], "pv_01_voltage": [ 185.6, "V" ], "pv_01_current": [ 0.0, "A" ], "pv_02_voltage": [ 456.3, "V" ], "pv_02_current": [ 0.0, "A" ], "nb_online_optimizers": [ 12, null ], "meter_status": [ 1, null ], "grid_A_voltage": [ 231.3, "V" ], "grid_B_voltage": [ 230.5, "V" ], "grid_C_voltage": [ 229.3, "V" ], "active_grid_A_current": [ -2.59, "I" ], "active_grid_B_current": [ -1.02, "I" ], "active_grid_C_current": [ -1.44, "I" ], "power_meter_active_power": [ -835, "W" ], "power_meter_reactive_power": [ 69, "Var" ], "active_grid_power_factor": [ -0.717, null ], "active_grid_frequency": [ 49.93, "Hz" ], "grid_exported_energy": [ 16578.0, "kWh" ], "grid_accumulated_energy": [ 5588.97, "kWh" ], "grid_accumulated_reactive_power": [ 0.0, "kVarh" ], "meter_type": [ 1, null ], "active_grid_A_B_voltage": [ 399.8, "V" ], "active_grid_B_C_voltage": [ 398.2, "V" ], "active_grid_C_A_voltage": [ 398.8, "V" ], "active_grid_A_power": [ -450, "W" ], "active_grid_B_power": [ -206, "W" ], "active_grid_C_power": [ -178, "W" ] }, "slave_0_config_data": {}, "slave_16": { "model_name": "SUN2000-6KTL-M1\u0000GIN300-6KTL-M1", "pv_string_count": 2, "has_optimizers": 0, "battery_type": 0, "battery_1_type": 0, "battery_2_type": 0, "power_meter_type": null, "supports_capacity_control": false }, "slave_16_data": { "input_power": [ 0, "W" ], "line_voltage_A_B": [ 400.0, "V" ], "line_voltage_B_C": [ 398.9, "V" ], "line_voltage_C_A": [ 399.3, "V" ], "phase_A_voltage": [ 231.3, "V" ], "phase_B_voltage": [ 230.8, "V" ], "phase_C_voltage": [ 229.8, "V" ], "phase_A_current": [ 0.0, "A" ], "phase_B_current": [ 0.0, "A" ], "phase_C_current": [ 0.0, "A" ], "day_active_power_peak": [ 0, "W" ], "active_power": [ 0, "W" ], "reactive_power": [ 0, "VA" ], "power_factor": [ 0.0, null ], "grid_frequency": [ 49.95, "Hz" ], "efficiency": [ null, "%" ], "internal_temperature": [ 23.5, "\u00b0C" ], "insulation_resistance": [ null, "MOhm" ], "device_status": [ "Standby: detecting irradiation", null ], "fault_code": [ 0, null ], "startup_time": [ "2023-12-20T07:53:47+00:00", null ], "shutdown_time": [ "2023-12-20T14:34:51+00:00", null ], "accumulated_yield_energy": [ 5974.37, "kWh" ], "daily_yield_energy": [ 0.0, "kWh" ], "state_1": [ [ "Standby" ], null ], "state_2": [ [ "Locked", "PV connected", "DSP data collection" ], null ], "state_3": [ [ "On-grid", "Off-grid switch disabled" ], null ], "alarm_1": [ [], null ], "alarm_2": [ [], null ], "alarm_3": [ [], null ], "pv_01_voltage": [ 186.5, "V" ], "pv_01_current": [ 0.0, "A" ], "pv_02_voltage": [ 268.0, "V" ], "pv_02_current": [ 0.0, "A" ] }, "slave_16_config_data": {} } }

Upload your relevant debug logs

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:361
Integration: Sensor (documentation, issues)
First occurred: 08.51.45 (3 occurrences)
Last logged: 09.54.57

Error while setting up huawei_solar platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/huawei_solar/sensor.py", line 735, in async_setup_entry
    entity.add_name_suffix(f" #{idx+1}")
  File "/config/custom_components/huawei_solar/__init__.py", line 461, in add_name_suffix
    self._attr_name = f"{self.name}{suffix}"
                         ^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 477, in name
    return self._name_internal(None, {})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 438, in _name_internal
    and (name_translation_key := self._name_translation_key)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/backports/functools.py", line 70, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 424, in _name_translation_key
    f"component.{platform.platform_name}.entity.{platform.domain}"
                 ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'platform_name'
--- also this:
Logger: huawei_solar.huawei_solar
Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:348
First occurred: 09.59.52 (55 occurrences)
Last logged: 15.04.41

Modbus client is not connected to the inverter.
NoneType: None

Please confirm the following:

wlcrs commented 10 months ago

Duplicate of #558 . I've promoted the beta to a proper release to prevent more people from getting this issue.