CJNE / ha-sunspec

Home Assistant customcomponent for SunSpec modbus devices
MIT License
63 stars 14 forks source link

keep entities when they vanish from SMA TriPower X12 inverters #202

Open SteffenViperKoch opened 11 months ago

SteffenViperKoch commented 11 months ago

Is your feature request related to a problem? Please describe. SMA Sunny TriPower X12 inverters power down their internal CPU after solar production stops. So the integrations loses their entities and HomeAssistant shows them missing instead of just no value

Describe the solution you'd like I'd like to see the entities stay "alive" just without a value (if that's possible) or just with 0 value

Describe alternatives you've considered n/a

Additional context n/a

reeeeevls commented 9 months ago

I have the same problem. Does your entities show up the next time the sun is shining? Mine are lost since I "reconfigure" SunSpec.

pandersin commented 6 months ago

Same problem with SMA TriPower STP50-41. Entities do show up in the morning if the HA has not restarted during the night.

matze338 commented 6 months ago

In the night, the entities goes unavailable. I also got some warnings and errors in the log:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.sunspec
Source: custom_components/sunspec/__init__.py:154
Integration: SunSpec (documentation, issues)
First occurred: 18:08:08 (1365 occurrences)
Last logged: 20:03:03

Modbus exception 4: addr: 40096 count: 123
Logger: homeassistant.helpers.event
Source: helpers/event.py:296
First occurred: 18:14:33 (1 occurrences)
Last logged: 18:14:33

Error while dispatching event for sensor.sunspec_dermeasureac_total_energy_injected to <Job track state_changed event {'sensor.sunspec_dermeasureac_total_energy_injected'} HassJobType.Callback <bound method TrackTemplateResultInfo._refresh of <TrackTemplateResultInfo {Template<template=({{ states('sensor.sunspec_dermeasureac_total_energy_injected') }}) renders=366>: <RenderInfo Template<template=({{ states('sensor.sunspec_dermeasureac_total_energy_injected') }}) renders=366> all_states=False all_states_lifecycle=False domains=frozenset() domains_lifecycle=frozenset() entities=frozenset({'sensor.sunspec_dermeasureac_total_energy_injected'}) rate_limit=None has_time=False exception=None is_static=False>}>>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 669, 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/src/homeassistant/homeassistant/helpers/event.py", line 296, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 700, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1215, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 700, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 434, in _handle_results
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1047, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 995, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 671, in state
    raise ValueError(
ValueError: Sensor sensor.strom_produktion_energie has device class 'energy', state class 'total' unit 'Wh' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)

And

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.sunspec
Source: helpers/update_coordinator.py:345
Integration: SunSpec (documentation, issues)
First occurred: 18:14:33 (1 occurrences)
Last logged: 18:14:33

Error fetching sunspec data:

Screenshot_2024-02-09-20-08-41-740_io homeassistant companion android-edit

In the morning the integrations works again

Syonis commented 5 months ago

Same here with my Symo 7.0-3-M while the Gen24 is still available. But the reason here is, that the Symo is going down in the night and the Gen24 not. "I'd like to see the entities stay "alive" just without a value (if that's possible) or just with 0 value" That would be a nice one.

michaelpiron commented 4 months ago

Same issue here. Entities become unavailable during the night, and don't become available again the next day. Strangely enough, the total Wh counter and inverter state become available again, all the other entities remain unavailable. Hardware: SMA sunny boy SB 3000TL-21

image