* 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
* 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
* Close database connection before stopping the executor
related issue #117004
* Close database connection before waiting for database executor to finish
related issue #117004
* fix test
* fix
* drop unused arg
* Revert "drop unused arg"
This reverts commit 8a9fe6a24a.
* docstring
* comment
* 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
* 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
* 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
* 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>
* 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
* 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>
* 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
* 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>
* 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.
* 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 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
* Addition of a reload service to manually retrieve the status of the devices.
* Removal of reload_state service replaced by the homeassistant.update_entity supported service
* remove api update to v1.2.1 for another PR
* Review corrections
* Review corrections
* feat: add reconfigure
* feat: add reconfigure step
* fix: don't abort unique on reconfigure
* fix: add success string
* fix: improve reconfigure
* fix: entry will never be none
* fix: update ip in abort
* fix: check unique id on reconfigure
* feat: add test in case of new device
* fix: fail reconfigure if mac changes
* fix: abort instead of form
* feat: use is, dont mock config flow
* fix: implement comments
* Add support for Fujitsu HVAC devices
* Add the entity code to .coveragerc
* Only include code that can fail in the try/except block
Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com>
* Remove empty keys from manifest
* Remove VERSION as it's already the default
* Remve the get_devices function and use asyncio.gather to parallelize dev updates
* Move initial step to a function
* Let KeyError bubble up. If we are passed an invalid mode it's probably worth raising an exception.
* Await the gather
* Use the async version of the refresh_auth call
* Use the serial number as unique id
* Use HA constant for precision
* Use dev instead of self._dev
* Move to property decorated methods
* Remove bidict dependency
* Setup one config entry for our api credentials instead of per device
* Remove bidict from requirements
* Signout and remove our api object on unload
* Use app credentials from ayla_iot_unofficial
* Use entry_id as a key to store our API object
* Delete unused code
* Create reverse mappings from forward mapping instead of hardcoding them
* Clean up the property methods
* Only import part of config_entries we are using
* Implement suggested changes
* Fix tests to use new API consts
* Add support for reauth
* Use a coordinator instead of doing per-entity refresh
* Auto is equivalent to HEAT_COOL not AUTO
* Add ON and OFF to list of supported features
* Use the mock_setup_entry fixture for the reauth tests
* Parametrize testing of config flow exceptions
* Only wrap fallable code in try/except
* Add tests for coordinator
* Use self.coordinator_context instead of self._dev.device_serial_number
* Move timeout to ayla_iot_unofficial
* Add description for is_europe field
* Bump version of ayla-iot-unofficial
* Remove turn_on/turn_off warning
* Move coordinator creating to __init__
* Add the type of coordinator to the CoordiatorEntity
* Update docstring for FujitsuHVACDevice constructor
* Fix missed self._dev to dev
* Abort instead of showing the form again with an error when usernames are different
* Remove useless argument
* Fix tests
* Implement some suggestions
* Use a device property the maps to the coordinator data
* Fix api sign out when unloading the entry
* Address comments
* Fix device lookup
* Move API sign in to coordinator setup
* Get rid of FujitsuHVACConfigData
* Fix async_setup_entry signature
* Fix mock_ayla_api
* Cleanup common errors
* Add test to check that re adding the same account fails
* Also patch new_ayla_api in __init__.py
* Create a fixture to generate test devices
* Add a setup_integration function that does the setup for a mock config entry
* Rework unit tests for the coordinator
* Fix typos
* Use hass session
* Rework reauth config flow to only modify password
* Update name to be more use-friendly
* Fix wrong type for entry in async_unload_entry
* Let TimeoutError bubble up as teh base class handles it
* Make the mock ayla api return some devices by default
* Move test to test_climate.py
* Move tests to test_init.py
* Remove reauth flow
* Remove useless mock setup
* Make our mock devices look real
* Fix tests
* Rename fujitsu_hvac to fujitsu_fglair and rename the integration to FGLair
* Add the Fujitsu brand
* Add a helper function to generate an entity_id from a device
* Use entity_id to remove hardcoded entity ids
* Add a test to increase code coverage
---------
Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Joostlek <joostlek@outlook.com>
* Support harvey brand
* Update tests
* Moved the brand selection step to the same step as credentials
* Update tests/components/aquacell/test_init.py
---------
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* Add temperature sensors for device
* Move to single line
* Use right reference
* Always return a value
* Update tests
* Use slugify for id name
* Return default value if not present
* Make _device_temperature return value
* Add default value if temperatures is None
* Set value to go over all code paths
* Add test for no matching temperatures
* make first part deterministic
* Add statistics import to Ista EcoTrend integration
* Use decorator for fixtures
* define recorder as after_dependency
* Increase test coverage
* remember initial statistic_id
* fix type checking
* Publish raw rendered mqtt payload as raw for mqtt publish action
* Move check out of try block
* Only try to eval `bytes` is payload starts with supported string
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Improve docst
* Add `evaluate_bytes` option to publish action
* Rename to `evaluate_payload`
* Update homeassistant/components/mqtt/strings.json
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Extend test to assert literal_eval is called or not
---------
Co-authored-by: Erik Montnemery <erik@montnemery.com>
* Do a sanity check of schema passed to EntityPlatform.async_register_entity_service
* Only attempt to check schema of Schema
* Handle All/Any wrapped in schema
* Clarify comment
* Apply suggestions from code review
Co-authored-by: Robert Resch <robert@resch.dev>
---------
Co-authored-by: Robert Resch <robert@resch.dev>
* Add config flow to select platform in Template
* Remove device id duplicate in schema
* Add config flow for number platform in Template
* Remove mode
* Add tests
* Fix entity test
* Format
* Fix sensor tests
* Fix sensor tests
* Fix sensor tests
* Add init tests
* Change service info
* Rename test_sensor parameters
* Removce ConfigEntryState.LOADED assertion
* Remove platforms parameter from setup_platform
* Rename setup_platform to setup_integration
* Fixture for blind_type and mock_config_entry
* Use mock for MotionDevice
* Use mock for MotionDevice
* Add type hint
* Use Mock instead of patch
* Use mock_config_entry fixture
* Move constants to init
* Fix entity_id name
* Use fixture
* Use fixtures instead of constants
* Use display_name fixture
* Rename mac to mac_code
* Remove one patch
* Use fixtures for mock_config_entry
* Apply suggestion
* Replace patch with mock
* Replace patch with mock
* Replace patch with mock
* Fix
* Use pytest.mark.usefixtures if parameter not used
* Base mac code on address
* Remove if statement from entity test
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
* fix yamaha remove info logging
* ruff
* fix yamnaha supress rxv.find UnicodeDecodeError
* fix formatting
* make more realistic
* make more realistic and use parms
* add value error after more feedback
* ruff format
* Update homeassistant/components/yamaha/media_player.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* remove unused method
* add more debugging
* Increase discovery timeout add more debug allow config to overrite dicovery for name
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Raise on database error in recorder.migration._drop_foreign_key_constraints
* Fix test
* Fix test
* Revert "Fix test"
This reverts commit 940b8cb506e912826d43d09d7697c10888bdf685.
* Update test
* Improve test coverage
* Disable test for SQLite