Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shelly available check when device is not initialized #124182

Merged
merged 6 commits into from
Aug 22, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Aug 18, 2024

Proposed change

available needs to check for device.initialized or if the device is sleepy as calls to status will raise NotInitialized which results in many un-retrieved 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

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

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
```
@home-assistant
Copy link

Hey there @balloob, @bieniu, @thecode, @chemelli74, mind taking a look at this pull request as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of shelly can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign shelly Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@bdraco
Copy link
Member Author

bdraco commented Aug 18, 2024

Tested with a pro4pm and gen4 ht

@bdraco bdraco added this to the 2024.8.3 milestone Aug 19, 2024
@bdraco bdraco marked this pull request as ready for review August 19, 2024 13:24
@thecode thecode merged commit df82567 into dev Aug 22, 2024
26 checks passed
@thecode thecode deleted the fix_missing_available_check branch August 22, 2024 13:14
raman325 added a commit to raman325/home-assistant that referenced this pull request Aug 22, 2024
* dev: (31 commits)
  Use identity checks for ESPHome Enums (home-assistant#124334)
  Bump yalexs to 8.1.4 (home-assistant#124425)
  Refactor targets for zwave_js services (home-assistant#115734)
  Check minimum amount of integrations for a brand (home-assistant#124310)
  Reduce ESPHome entity state write overhead (home-assistant#124329)
  Cleanup redundant fixtures and move all other hassio addon fixtures to be shared (home-assistant#124437)
  Bump ruff to 0.6.2 (home-assistant#124433)
  Fix Import ReceivePayloadType (home-assistant#124431)
  Allow to set options for an MQTT enum sensor (home-assistant#123248)
  Add LawnMowerActivity.RETURNING to Lawn Mower (home-assistant#124261)
  Add zip to template engine (home-assistant#122460)
  Shutdown database engine before waiting for executor shutdown (home-assistant#117339)
  Add Bang & Olufsen websocket testing (home-assistant#123075)
  Wrap OSError in loader.load_yaml (home-assistant#124406)
  Improve Bang olufsen test typing and parameter order (home-assistant#124419)
  Add supported features for iZone (home-assistant#124416)
  Automatically generate Amazon Polly list of voices and regions (home-assistant#119198)
  Fix shelly available check when device is not initialized (home-assistant#124182)
  Drop ignore-missing-annotations from pylint tests (home-assistant#120302)
  Improve type hints in lcn tests (home-assistant#124415)
  ...
aceindy added a commit to aceindy/core that referenced this pull request Aug 23, 2024
* Add support for whole apsystems ez1 series (home-assistant#123356)

* Add support for whole apsystems ez1 series by configuring the max_output at setup to match the value by the inverter

* Check Max output for apsystems on startup, not setup

* Move max output check into coordinator

* Raise UpdateFailed on error in apsystems

* Prepare `otbr.silabs_multiprotocol` for multiple config entries (home-assistant#124219)

* Prepare otbr.silabs_multiprotocol for multiple config entries

* Simplify

* Bump apsystems-ez1 to 2.2.1 (home-assistant#124243)

* Update apsystems library

* Bump apsystems library to 2.2.1

* Use library fork for ViCare integration (home-assistant#124107)

* switch dependency to fork

* Update manifest.json

* Update requirements_all.txt

* Update requirements_test_all.txt

* Bump aiowithings to 3.0.3 (home-assistant#124154)

* Bump ruff to 0.6.1 (home-assistant#124250)

* Bump ruff to 0.6.0

* Bump ruff to 0.6.1

* Bump nice-go to 0.2.1 (home-assistant#124238)

* Bump nice-go to 0.2.0

* Bump nice-go to 0.2.1

* Use PEP 695 for decorator typing with type aliases in esphome (home-assistant#124234)

* Add switch platform to Nice G.O. (home-assistant#124237)

* Add switch platform to Nice G.O.

* Replace cover with switch in switch.py

* Use  icon translations

* Fix tests

* Use constants in test_switch.py

* Use ATTR_ENTITY_ID

* Add missing hass type hint in component tests (r) (home-assistant#124231)

* Add entity deduplication by assist device ID in conversation agent (home-assistant#123957)

* Add entities deduplication by assist device ID in default conversation agent

* Updated test.

* Add entity matching to intent_script (home-assistant#120973)

* Skip interfaces without mac in enigma2 device_info (home-assistant#124249)

* Add event platform to Nice G.O. (home-assistant#124253)

* Add event platform to Nice G.O.

* Add icon for barrier obstructed event

* Better assertions

* More test improvements

* Handle WebSocket client disconnect during prepare (home-assistant#124173)

* Bump aiohttp to 3.10.5 (home-assistant#124254)

* Bump aioshelly to 11.2.4 (home-assistant#124080)

* Add handling for `RoborockTooFrequentCodeRequests` for roborock integration (home-assistant#123759)

* Add handling for RoborockTooFrequentCodeRequests

* Add tests for coverage

* Bump nice-go to 0.3.0 (home-assistant#124262)

* Add Uplink info to UniFi Device tracker attributes (home-assistant#123032)

Add device uplink mac sensor

* Use HassKey in otbr (home-assistant#124240)

* Bump python-roborock to 2.6.0 (home-assistant#124268)

* Update opentherm_gw.binary_sensor to use entity_description (home-assistant#121969)

* Update opentherm_gw.binary_sensor to use entity_description

* Move binary_sensor related code to binary_sensor.py
Move common entity code to entity.py

* Remove unused logger from binary_sensor.py

* Add type hints
Address feedback

* Improve otbr error handling (home-assistant#124277)

* Deduplicate otbr tests (home-assistant#124270)

* New Integration: SMLIGHT SLZB-06 Adapters Integration (home-assistant#118675)

* Initial SMLIGHT integration

Signed-off-by: Tim Lunn <tl@smlight.tech>

* Generated content

Signed-off-by: Tim Lunn <tl@smlight.tech>

* Cleanup LOGGING

* Use runtime data

* Call super first

* coordinator instance attributes

* Move coordinatorEntity and attr to base class

* cleanup sensors

* update strings to use sentence case

* Improve reauth flow on incorrect credentials

* Use fixture for config_flow tests and test to completion

* Split uptime hndling into a new uptime sensor entity

* Drop server side events and internet callback

will bring this back with binary sensor Platform

* consolidate coordinator setup

* entity always include connections

* get_hostname tweak

* Add tests for init, coordinator and sensor

* Use custom type SmConfigEntry

* update sensor snapshot

* Drop reauth flow for later PR

* Use _async_setup for initial setup

* drop internet to be set later

* sensor fixes

* config flow re

* typing fixes

* Bump pysmlight dependency to 0.0.12

* dont trigger invalid auth message when first loading auth step

* Merge uptime sensors back into main sensor class

* clarify uptime handling

* Apply suggestions from code review

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* address review comments

* pass host as parameter to the dataCoordinator

* drop uptime sensors for a later PR

* update sensor test snapshot

* move coordinator unique_id to _async_setup

* fix CI

* Apply suggestions from code review

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* drop invalid_auth test tag

* use snapshot_platform, update fixtures

* Finish all tests with abort or create entry

* drop coordinator tests and remove hostname support

* add test for update failure on connection error

* use freezer for update_failed test

* fix pysmlight imports

---------

Signed-off-by: Tim Lunn <tl@smlight.tech>
Co-authored-by: Tim Lunn <tim@feathertop.org>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Add additional tests for Matter update entity (home-assistant#122575)

* Add additional tests for Matter update entity

Extend test coverage for Matter update entity. This includes tests for
error handling and state store/restore.

* Improve test descriptions

* Add restore test only (using mock_restore_cache_with_extra_data)

* Fix test_update_state_save_and_restore test

* Use homeassistant constants

* Use update component constants

* Use freezer to skip time for device update check

We check device updates every 12h currently. Use the freezer to skip
time.

Still add a test which uses the service call to make sure this works
too.

* Improve type hints in homekit and homekit_controller tests (home-assistant#124213)

Add missing hass type hint in homekit and homekit_controller tests

* Add missing hass type hint in component tests (n) (home-assistant#124225)

* Add missing hass type hint in component tests (p) (home-assistant#124227)

* Add missing hass type hint in component tests (s) (home-assistant#124272)

* Add missing hass type hint in component tests (u) (home-assistant#124275)

* Add missing hass type hint in component tests (v) (home-assistant#124281)

* Add missing hass type hint in component tests (w) (home-assistant#124284)

* Add missing hass type hint in component tests (x) (home-assistant#124285)

* Add missing hass type hint in component tests (y) (home-assistant#124286)

* Add missing hass type hint in component tests (t) (home-assistant#124274)

* Update opentherm_gw.sensor to use entity_description (home-assistant#124283)

* Disable expensive pskc computation in all otbr tests (home-assistant#124292)

* Disable expensive pskc computation in all otbr tests

* Update tests and fixtures which patched compute_pskc

* Deduplicate OTBR test fixtures (home-assistant#124293)

* Subscribe per component for MQTT discovery (home-assistant#119974)

* Subscribe per component for MQTT discovery

* Use single assignment

* Handle wildcard subscriptions first

* Split subsRecription handling, update helper

* Fix help_all_subscribe_calls

* Fix import

* Fix test

* Update import order

* Undo move self._last_subscribe

* Recover removed test

* Revert not needed changes to binary_sensor platform tests

* Revert line removal

* Rework interation of discovery topics

* Reduce

* Add comment

* Move comment

* Chain subscriptions

* Add Sonos tests for media_player play Sonos Playlist and improve error handling (home-assistant#124126)

* initial commit

* initial commit

* initial commit

* updates

* add json fixture

* use match on pytest.raises

* Bump yalexs to 8.1.2 (home-assistant#124303)

* Add missing strings for riemann options flow (home-assistant#124317)

* Bump habluetooth to 3.3.2 (home-assistant#124321)

* Improve Bang & Olufsen notification type comparison (home-assistant#123067)

* Change notification comparison

* Use try_parse_enum to determine notification type

* Add custom panel for LCN configuration (home-assistant#108664)

* Add LCN panel using lcn-frontend module

* Move panel from sidebar to integration configuration

* Change OptionFlow to reconfigure step

* Change OptionFlow to reconfigure step

* Remove deprecation warning

* Fix docstring

* Add tests for lcn websockets

* Remove deepcopy

* Bump lcn-frontend to 0.1.3

* Add tests for lcn websockets

* Remove websocket command lcn/hosts

* Websocket scan tests cover modules not stored in config_entry

* Add comment to mock of hass.http

* Add a decorater to ensure the config_entry exists and return it

* Use entry_id instead of host_id

* Bump lcn-frontend to 0.1.5

* Use auto_id for websocket client send_json

* Create issues on yaml import errors

* Remove low level key deprecation warnings

* Method renaming

* Change issue id in issue creation

* Update tests for issue creation

* blebox: use blebox_uniapi.cover.BleboxCoverState enum members instead of plain integers (home-assistant#124302)

* blebox: use blebox_uniapi.cover.BleboxCoverState enum members instead of plain integers

* Apply suggestion from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Extend blebox shutterbox tilt support (home-assistant#110547)

* blebox: extend shutterbox tilt support

* feat: add test for new open/close tilt code in blebox covers

* blebox: resign from using future compat branch for cover open/close tilt

* Update homeassistant/components/blebox/cover.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* blebox: revert changes to BLEBOX_TO_HASS_COVER_STATES

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix state name for binary_sensor Power from clear/detected to on/off (home-assistant#116994)

Fixed state name for binary_sensor Power from clear/detected to on/off

* Add tests for IronOS integration (home-assistant#123078)

Add tests

* Add test cases for ViCare entities (home-assistant#122983)

* add test case

* add test case

* add test case

* add test case

* add test case

* add test case

* remove commented code

* test only fan platform

* add test case

* remove fan mock

* Disable Habitica deprecated entities by default (home-assistant#123522)

Deprecated sensor task entites disable by default

* Change POWER_VOLT_AMPERE_REACTIVE to UnitOfReactivePower (home-assistant#117153)

* Refactoring: exchange POWER_VOLT_AMPERE_REACTIVE with UnitOfReactivePower

* updated iotawatt and mysensors from VOLT_AMPERE_REACTIVE to UnitOfReactivePower.VOLT_AMPERE_REACTIVE

* deprecation period for POWER_VOLT_AMPERE_REACTIVE changed to one year.

* POWER_VOLT_AMPERE_REACTIVE changed to UnitOfReactivePower in blebox integration

* Update homeassistant/const.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Fix Weatherflow Cloud lightning (home-assistant#124082)

* Adding a error condition and a fix for missing lightning epoch values

* adding parentheses around the lambda

* Updating PR

* removed the dumb test

* Updated tests to support good stuff

* Updated snapshots

* Rename OpenThermGatewayDevice to OpenThermGatewayHub (home-assistant#124361)

* Rename OpenThermGatewayDevice to OpenThermGatewayHub
Update references accordingly

* Update tests

* Bump async-interrupt to 1.2.0 (home-assistant#124360)

changelog: bdraco/async_interrupt@v1.1.2...v1.2.0

* Remove unneeded check for Bang & Olufsen events and device update (home-assistant#124363)

Remove unneeded check for device and HomeAssistant availability

* Convert Bang & Olufsen testing logging patches to caplog (home-assistant#124366)

* Convert logging patches to caplog

* Remove unnecessary caplog log level handling

* Fix Spotify Media Browsing fails for new config entries (home-assistant#124368)

* initial commit

* tests

* tests

* update tests

* update tests

* update tests

* Add Aranet Radon Plus support (home-assistant#124197)

added aranet radon plus support

* update ttn_client - fix crash with SenseCAP devices (home-assistant#124370)

update ttn_client

* Add DROP Alert product support (home-assistant#117867)

* Add DROP Alert product support

* Add DROP Alert to sensor selftest

* Fix Alert sensor naming ambiguity

* Reorder a constant

* Alphabetize strings

* Remove unnecessary translation key

* Add tests for Bring integration (home-assistant#123087)

* Add tests to bring integration

* use more parametrization

* json fixture loading, move notification tests

* Improve config flow type hints (part 1) (home-assistant#124343)

* Improve config flow type hints

* Revert sms

* Improve config flow type hints (part 4) (home-assistant#124348)

* Bump dbus-fast to 2.23.0 (home-assistant#124384)

* Bump python-holidays to 0.55 (home-assistant#124314)

* Bump github/codeql-action from 3.26.2 to 3.26.4 (home-assistant#124390)

* Bump home-assistant/builder from 2024.08.1 to 2024.08.2 (home-assistant#124341)

* Fix typo in Alexa resources docstring (home-assistant#124388)

Fixed typo in Alexa resources docstring

* Install and start Mosquitto MQTT broker add on from MQTT config flow (home-assistant#124106)

* Opt in to install Mosquitto broker add-on in MQTT config flow

* rephrase

* Tests with supervisor and running add-on

* Complete tests for success flows

* Also set up entry in success flow

* Use realistic names for addon and broker

* Finetuning and fail test cases

* Spelling

* Improve translation strings

* Update addon docstr

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Raise AddonError if add-on does not start

* Only show the option to use the add-on

* Simplify flow, rework and cleanup

* Revert unrelated cleanup, process suggestion

* Move ADDON_SLUG const to addon module

* Move fixture to component level

* Move back supervisor fixture

* Move addon_setup_time_fixture and superfixe to config flow model tests

* Refactor hassio fixture

* Rename helpers as they are no fixtures, remove fixture from their names

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Use setup_test_component_platform in Climate tests (home-assistant#123941)

* Use setup_test_component_platform in Climate tests

* Rename mock integration helper

* Change name to register_test_integration

* Change name in tests

* Fix ruff format

* Fix lingering mqtt unload entry test (home-assistant#124392)

* Bump pysmlight to 0.0.13 (home-assistant#124398)

Better handle socket uptime disconnected
Raise auth error on get/post requests that fail

* Handle !include without arguments in configuration.yaml (home-assistant#124399)

* Prevent !include without arguments in configuration.yaml from crashing core

* Add test

* Revert UnitOfReactivePower change from iotawatt (home-assistant#124393)

Revert "Change POWER_VOLT_AMPERE_REACTIVE to UnitOfReactivePower (home-assistant#117153)"

This reverts commit 3e53cc1.

* Improve type hints in lcn tests (home-assistant#124415)

* Drop ignore-missing-annotations from pylint tests (home-assistant#120302)

* Fix shelly available check when device is not initialized (home-assistant#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

* Automatically generate Amazon Polly list of voices and regions (home-assistant#119198)

* Automatically generate list of voices and regions. Requires AWS credentials.

* add missing commit

* replace pydantic with dataclass

* dictionary values are strings or list of strings

* also generated set of supported engines

* use sets for amazon polly parameters

* move default for readability

* Add supported features for iZone (home-assistant#124416)

* Fix for home-assistant#123462

* Set outside of constructor

* Improve Bang olufsen test typing and parameter order (home-assistant#124419)

* Add proper media_player typing to tests

* Add proper typing to init tests

* Add proper typing to config_flow tests

* Fix order of parameters of tests

* Add more typing
Reorder parameters

* Wrap OSError in loader.load_yaml (home-assistant#124406)

* Add Bang & Olufsen websocket testing (home-assistant#123075)

* Add websocket.py testing
Convert media_player testing dispatch events to the proper websocket events

* Fix WebSocket testing by using callbacks

* Add typing

* Add caplog checking
Check dispatch events directly
Check event bus directly
Avoid using internals

* Fix event and / dispatch callbacks not necessarily being checked

* Remove unnecessary caplog log level handling

* Shutdown database engine before waiting for executor shutdown (home-assistant#117339)

* Close database connection before stopping the executor

related issue home-assistant#117004

* Close database connection before waiting for database executor to finish

related issue home-assistant#117004

* fix test

* fix

* drop unused arg

* Revert "drop unused arg"

This reverts commit 8a9fe6a.

* docstring

* comment

* Add zip to template engine (home-assistant#122460)

* add zip to template engine

* fix doc strings

* Add LawnMowerActivity.RETURNING to Lawn Mower (home-assistant#124261)

* Add returning activity state

* update tests

* update tests

* set can return to returning state

* update MQTT tests

* update mqtt back to docked

* fix up other tests that I broke again

* re-add mower_can_dock

* Allow to set options for an MQTT enum sensor (home-assistant#123248)

* Add options attribute support for MQTT sensor

* Add comment

* Fix Import ReceivePayloadType (home-assistant#124431)

* Fix Import ReceivePayloadType

* Do not assert export `ReceivePayloadType` on mqtt integration level as helper should be used.

* Bump ruff to 0.6.2 (home-assistant#124433)

* Cleanup redundant fixtures and move all other hassio addon fixtures to be shared (home-assistant#124437)

* Reduce ESPHome entity state write overhead (home-assistant#124329)

* Check minimum amount of integrations for a brand (home-assistant#124310)

* Refactor targets for zwave_js services (home-assistant#115734)

* Let labels be used as targets for zwave_js services

* add coverage

* Fix test bug and switch from targets to fields

* Remove label addition

* Remove labels from service descriptions

* Remove labels from strings

* More changes

* Bump yalexs to 8.1.4 (home-assistant#124425)

changelog: bdraco/yalexs@v8.1.2...v8.1.4

* Use identity checks for ESPHome Enums (home-assistant#124334)

Enums are singletons and should use is to compare.

The valve platform was updated but cover and lock were missed.

* Replace statistics _get_unit_class function with a dict lookup (home-assistant#124452)

* Fix `zwave_js` `services.yaml` schema (home-assistant#124455)

Fix zwave_Js services.yaml schema

* Refactor bsblan coordinator (home-assistant#124308)

* chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability

* feat: Add BSBLan integration models

This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information.

* refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type

* chore: Remove unused Sensor import in BSBLan models

* feat: Refactor BSBLanEntity to use CoordinatorEntity

The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability.

* refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator

* refactor: Update BSBLANClimate class to use DataUpdateCoordinator

Refactor the BSBLANClimate class to use the Coordinator of the entity

* refactor: Update tests to use the new structure

* fix coverage

 it should be the same as before

* refactor: moved dataclass BSBLanCoordinatorData

* use the data class inside init

* refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator

* refactor: use BSBLanData from init

* remove entry data from diagnostics

* fix: add random interval back

* refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics

* revert back to original except dataclass import

* revert: Add MAC address back to device info in BSBLanEntity

* Reolink add 100% coverage of number platform (home-assistant#124465)

* Add 100% number test coverage

* review comments

* fix styling

* re-add AsyncMock for chime

* Bump opower to 0.7.0 (home-assistant#124475)

* Bump aiohue to version 4.7.3 (home-assistant#124436)

---------

Signed-off-by: Tim Lunn <tl@smlight.tech>
Co-authored-by: Marlon <git@mawoka.eu>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com>
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: IceBotYT <34712694+IceBotYT@users.noreply.github.com>
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
Co-authored-by: Andrii Mitnovych <10116550+formatBCE@users.noreply.github.com>
Co-authored-by: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Yuxin Wang <yuxinwang.dev@gmail.com>
Co-authored-by: Ian <ViViDboarder@gmail.com>
Co-authored-by: Allen Porter <allen@thebends.org>
Co-authored-by: mvn23 <schopdiedwaas@gmail.com>
Co-authored-by: TimL <tl@smlight.tech>
Co-authored-by: Tim Lunn <tim@feathertop.org>
Co-authored-by: Stefan Agner <stefan@agner.ch>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: Pete Sage <76050312+PeteRager@users.noreply.github.com>
Co-authored-by: karwosts <32912880+karwosts@users.noreply.github.com>
Co-authored-by: Markus Jacobsen <markusjacobsen@hotmail.com>
Co-authored-by: Andre Lengwenus <alengwenus@gmail.com>
Co-authored-by: Michał Jaworski <mjaworski@opera.com>
Co-authored-by: Joram <10565565+JoramQ@users.noreply.github.com>
Co-authored-by: Mr. Bubbles <manni@zapto.de>
Co-authored-by: Christian Neumeier <47736781+NECH2004@users.noreply.github.com>
Co-authored-by: Jeef <jeeftor@users.noreply.github.com>
Co-authored-by: Anrijs <Anrijs@users.noreply.github.com>
Co-authored-by: Angel Nunez Mencias <git@angelnu.com>
Co-authored-by: Patrick Frazer <pfrazer@chandlersystemsinc.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: spongebobberts <133538584+spongebobberts@users.noreply.github.com>
Co-authored-by: Jakob Schlyter <jakob@kirei.se>
Co-authored-by: Penny Wood <Swamp-Ig@users.noreply.github.com>
Co-authored-by: Petro31 <35082313+Petro31@users.noreply.github.com>
Co-authored-by: Michael Arthur <mikey0000@users.noreply.github.com>
Co-authored-by: Raman Gupta <7243222+raman325@users.noreply.github.com>
Co-authored-by: Willem-Jan van Rootselaar <liudgervr@gmail.com>
Co-authored-by: starkillerOG <starkiller.og@gmail.com>
Co-authored-by: tronikos <tronikos@users.noreply.github.com>
Co-authored-by: Ino Dekker <idekker@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants