hass-core/homeassistant/components/shelly
J. Nick Koston df82567356
Fix shelly available check when device is not initialized (#124182)
* Fix shelly available check when device is not initialized

available needs to check for device.initialized or if the device
is sleepy as calls to status will raise NotInitialized which results
in many unretrieved exceptions while writing state

fixes
```
2024-08-18 09:33:03.757 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 453, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/shelly/entity.py", line 374, in _update_callback
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 293, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/shelly/binary_sensor.py", line 331, in is_on
    return bool(self.attribute_value)
                ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 545, in attribute_value
    self._last_value = self.sub_status
                       ^^^^^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 534, in sub_status
    return self.status[self.entity_description.sub_key]
           ^^^^^^^^^^^
  File "/config/custom_components/shelly/entity.py", line 364, in status
    return cast(dict, self.coordinator.device.status[self.key])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/rpc_device/device.py", line 390, in status
    raise NotInitialized
aioshelly.exceptions.NotInitialized
```

* tweak

* cover

* fix

* cover

* fixes
2024-08-22 16:14:45 +03:00
..
bluetooth
__init__.py Add support for Shelly enum virtual component (#121997) 2024-07-18 17:55:14 +03:00
binary_sensor.py Add shelly overcurrent sensor for switches (#122494) 2024-07-25 21:22:18 +03:00
button.py
climate.py Fix implicit-return in shelly (#122926) 2024-07-31 14:54:52 +02:00
config_flow.py Ignore Shelly IPv6 address in zeroconf (#123081) 2024-08-02 21:56:49 +03:00
const.py Add support for Shelly enum virtual component (#121997) 2024-07-18 17:55:14 +03:00
coordinator.py Fix shelly available check when device is not initialized (#124182) 2024-08-22 16:14:45 +03:00
cover.py
device_trigger.py
diagnostics.py Add last_error reporting to Shelly diagnostics (#120595) 2024-06-26 21:35:23 +03:00
entity.py Fix shelly available check when device is not initialized (#124182) 2024-08-22 16:14:45 +03:00
event.py
icons.json
light.py
logbook.py
manifest.json Bump aioshelly to 11.2.4 (#124080) 2024-08-19 19:13:35 -05:00
number.py Add support for Shelly number virtual component (#121894) 2024-07-15 22:26:12 +02:00
select.py Add support for Shelly enum virtual component (#121997) 2024-07-18 17:55:14 +03:00
sensor.py Add missing sensors for Shelly Plus RGBW PM (#123589) 2024-08-18 12:58:51 +03:00
strings.json Ignore Shelly IPv6 address in zeroconf (#123081) 2024-08-02 21:56:49 +03:00
switch.py Add support for Shelly virtual boolean component (#119932) 2024-07-10 23:51:51 +02:00
text.py Add support for Shelly text virtual component (#121735) 2024-07-12 12:58:21 +02:00
update.py
utils.py Add support for Shelly enum virtual component (#121997) 2024-07-18 17:55:14 +03:00
valve.py Remove the switch entity for Shelly Gas Valve (#119817) 2024-06-17 19:17:06 +02:00