jesserizzo / envoy_reader

MIT License
37 stars 26 forks source link

Exception is seen in HA when using Envoy with <3.9 firmware and monitoring inverters #60

Closed gtdiehl closed 3 years ago

gtdiehl commented 3 years ago

If an Envoy is discovered in Home Assistant and the user does not specify monitored_conditions or does specific inverters for monitored_conditions than an exception is seen in the Home Assistant log:

Inverter data gathering for Envoys running <3.9 firmware is not supported, though Home Assistant should fail gracefully.

020-12-28 15:15:36 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform enphase_envoy
Traceback (most recent call last):
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/Users/greg/Documents/GitHub/core/homeassistant/components/enphase_envoy/sensor.py", line 186, in state
    value = self.coordinator.data.get("inverters_production").get(
AttributeError: 'str' object has no attribute 'get'
2020-12-28 15:15:36 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up enphase_envoy platform for sensor
Traceback (most recent call last):
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity_platform.py", line 207, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/Users/greg/Documents/GitHub/core/homeassistant/components/enphase_envoy/sensor.py", line 186, in state
    value = self.coordinator.data.get("inverters_production").get(
AttributeError: 'str' object has no attribute 'get'

This is due to the envoy_reader library returning a text string and Home Assistant tries to parse the string a do a dictionary look up based on that value.