Commit Graph

431 Commits (2c06d4fcb9f9591710188d597c926e72bd385c50)

Author SHA1 Message Date
Marc Mueller 87165c0d6e
Add empty line after module docstring [tests t-z] (#112712) 2024-03-08 14:44:56 +01:00
J. Nick Koston f3a9756f81
Avoid waiting for integration platforms in the parent integration (#112467) 2024-03-05 21:16:42 -10:00
David F. Mulcahey f9e00ed45b
Fix ZHA groups page (#112140)
* Fix ZHA groups page

* test
2024-03-03 19:17:02 -05:00
David F. Mulcahey 73b6e2bac8
Add support for ZHA entities exposed by Zigpy quirks (#111176)
* Add counter entities to the ZHA coordinator device

* rework to prepare for non coordinator device counters

* Initial scaffolding to support quirks v2 entities

* update for zigpy changes

* add assertion error message

* clean up test

* update group entity discovery kwargs

* constants and clearer names

* apply custom device configuration

* quirks switches

* quirks select entities

* quirks sensor entities

* update discovery

* move call to super

* add complex quirks v2 discovery test

* remove duplicate replaces

* add quirks v2 button entity support

* add quirks v2 binary sensor entity support

* fix exception in counter entitiy discovery

* oops

* update formatting

* support custom on and off values

* logging

* don't filter out entities quirks says should be created

* fix type alias warnings

* sync up with zigpy changes and additions

* add a binary sensor test

* button coverage

* switch coverage

* initial select coverage

* number coverage

* sensor coverage

* update discovery after rebase

* coverage

* single line

* line lengths

* fix double underscore

* review comments

* set category from quirks in base entity

* line lengths

* move comment

* imports

* simplify

* simplify
2024-02-29 10:38:21 -05:00
puddly 4ec75d6ca7
Use new zigpy OTA providers for ZHA (#111159)
* Use `None` instead of `"unknown"` when the current version is unknown

* Only use the current file version from the OTA notification

* Use `sw_version`, if available, and update `current_file_version`

* Assume the current version is the latest version

* Fix lint errors

* Use `image` instead of `firmware`

* Include a changelog if updates expose it

* Clear latest firmware only after updating the installed version

* Bump minimum zigpy version to 0.63.0

* Create a data update coordinator to consolidate updates

* Fix overridden `async_update`

* Fix most unit tests

* Simplify `test_devices` to fix current tests

* Use a dict comprehension for creating mocked entities

* Fix unit tests (thanks @dmulcahey!)

* Update the currently installed version on cluster attribute update

* Drop `PARALLEL_UPDATES` now that we use an update coordinator

* Drop `_reset_progress`, it is already handled by the update component

* Do not update the progress if we are not supposed to be updating

* Ignore latest version (e.g. if device attrs changed) if zigpy rejects it

* Clean up handling of command id in `Ota.cluster_command`

* Start progress at 1%: 0 and False are considered equal and are filtered!

Use `ceil` instead of remapping 1-100

* The installed version will be auto-updated when the upgrade succeeds

* Avoid 1 as well, it collides with `True`

* Bump zigpy to (unreleased) 0.63.2

* Fix unit tests

* Fix existing unit tests

Send both event types

Globally enable sending both event types

* Remove unnecessary branches

* Test ignoring invalid progress callbacks

* Test updating a device with a no longer compatible firmware
2024-02-28 14:38:04 -05:00
David F. Mulcahey 5d1b78a29d
Add device list to ZHA config entry diagnostics (#111549)
* Add device list to ZHA  config entry diagnostics

* add logical type
2024-02-27 06:44:26 -05:00
J. Nick Koston 4624c859e1
Use discovery flow helper for hardware integrations (#111437)
* Use discovery flow helper for hardware integrations

The discovery flow helper defers loading discovered integrations until after startup
to improve startup reliability.

* Use discovery flow helper for hardware integrations

The discovery flow helper defers loading discovered integrations until after startup
to improve startup reliability. Since hardware was not listed in as a
discovery integration, the notification for new discoveries was missing.
2024-02-26 12:04:33 -05:00
David F. Mulcahey d485e8967b
Add device counter entities to ZHA (#111175)
* Add counter entities to the ZHA coordinator device

* rework to prepare for non coordinator device counters

* counter entity test

* update log lines

* disable by default
2024-02-23 13:22:47 -05:00
J. Nick Koston 59066c1770
Migrate zha to use Debouncer.async_schedule_call (#111103) 2024-02-23 07:28:23 -10:00
J. Nick Koston 7dcf2e94b4
Migrate zha to use async_update_entry to alter config entries (#110402) 2024-02-12 21:24:56 +01:00
J. Nick Koston f6d4617c7a
Avoid directly changing config entry state in tests (part 2) (#110115)
followup to #110048 for more places
2024-02-10 07:20:15 +01:00
puddly a533fa222e
Bump ZHA dependencies (#109770)
* Bump ZHA dependencies

* Bump universal-silabs-flasher to 0.0.18

* Flip `Server_to_Client` enum in ZHA unit test

* Bump zigpy to 0.62.2
2024-02-06 09:40:29 -05:00
TheJulianJES 965f31a9e0
Fix ZHA creating unnecessary "summ received" entity after upgrade (#109268)
* Do not create `current_summ_received` entity until initialized once

* Update zha_devices_list.py to not expect summation received entities

The attribute isn't initialized for these devices in the test (which our check now expects it to be), hence we need to remove them from this list.

* Update sensor tests to have initial state for current_summ_received entity

The attribute needs to be initialized for it to be created which we do by plugging the attribute read.
The test expects the initial state to be "unknown", but hence we plugged the attribute (to create the entity), the state is whatever we plug the attribute read as.

* Update sensor tests to expect not updating current_summ_received entity if it doesn't exist
2024-02-05 19:12:56 -05:00
Marc Mueller 8b0c9d3d18
Use builtin TimeoutError [t-z] (#109683) 2024-02-05 12:20:36 +01:00
TheJulianJES c355dd77a4
Fix ZHA update entity not updating installed version (#109260) 2024-02-01 08:26:39 +01:00
Paul Strawder f4a2d7c612
Add ZHA support for Bosch Twinguard and siren install QR codes (#107460)
* Enable Bosch Outdoor Siren and Bosch Twinguard QR Codes

These devices contain inside their QR code device specific link keys instead of installation codes. Normally, the link key is generated from the installation code, but in this case we can directly pass the provided link key from QR code to zigpy application controller.

* Replace ZHA deprecated permit_with_key by permit_with_link_key

Convert installation code directly to link key

* Update tests

* formatting
2024-01-31 12:02:34 -05:00
David F. Mulcahey 3115af1041
Add update platform to ZHA (bumps zigpy to 0.61.0) (#107612)
* stub out zha update entity

* update matcher

* updates based on assumptions / conversation

* hook into current installed version

* post rebase cleanup

* incorporate zigpy changes

* fix async_setup_entry

* fix sw_version

* make ota work with config diagnostic match

* fix version format

* sync up with latest Zigpy changes

* fix name attribute

* disable ota providers for tests

* update device list

* review comment

* add current_file_version to Ota ZCL_INIT_ATTRS

* updates to update and start tests

* get installed version from restore data

* better version handling

* remove done todo notes

* reorganize test

* move image notify to cluster handler

* add test for manual update check

* firmware update success test

* coverage

* use zigpy defs

* clean up after rebase

* bump Zigpy

* cleanup from review comments

* fix busted F string

* fix empty error

* move inside check

* guard zigbee network from bulk check for updates
2024-01-30 22:34:48 -05:00
Caius-Bonus a7a41e54f6
Add ZHA ZCL thermostat entities (#106563) 2024-01-31 03:26:19 +01:00
Jack 2909e1c4fe
Fix ZHA handling of power factor ElectricalMeasurement attribute sensor (#107641)
* Correct handling of power_factor ElectricalMeasurement attribute

The Zigbee Cluster Library defines PowerFactor as an int8 with value supported from -100 to 100.

Currently the zha sensor handler attempts to apply the ac_power_divisor and ac_power_multiplier formatters against the attribute value, the spec outlines that this should not be the case.

The impact of the current code is that quirks not using the default values of 1 are multiplying/dividing
power and power factor values prior to updating the cluster attribute.

This results in either a non-conformant power_factor e.g. the value was multiplied by 10 so that an ac_power_divider of 10 could be used, or the power readings sacrificing a point of measurement for lower readings.

Two quirks currently use this workaround:
 * ts0601_din_power.py
 * ts0601_rcbo.py

* Update ZHA Metering formatter to perform None check on _div_mul_prefix

To address feedback:
https://github.com/home-assistant/core/pull/107641#discussion_r1447547054

* _div_mul_prefix needs self reference

* Simplify None check for _div_mul_prefix

Co-authored-by: Joakim Plate <elupus@ecce.se>

* Updates to formatting and CI test typing fix

* Use ' | ' in place of Union

* Add tests for power_factor sensor

---------

Co-authored-by: Joakim Plate <elupus@ecce.se>
2024-01-30 23:11:18 +01:00
TheJulianJES 0b09ffbcde
Bump zha-quirks to 0.0.110 (#109161)
* Bump zha-quirks to 0.0.110

* Reflect removal of `IasWd` cluster for Heiman sensor in tests
2024-01-30 16:39:59 -05:00
puddly 758e7489f1
Fix ZHA cover inversion handling missing attributes (#109151)
* Allow `window_covering_type` to be `None`

* Create a `window_covering_mode` attribute and simplify inversion switch

* Revert "Create a `window_covering_mode` attribute and simplify inversion switch"

This reverts commit 048d649b4d.

* check both config status and mode

* coverage

---------

Co-authored-by: David Mulcahey <david.mulcahey@icloud.com>
2024-01-30 15:51:38 -05:00
Jack 4ec3a17ed0
Add missing ZHA metering device types (#109126)
* Update smartenergy.py metering_device_type enums

* Added missing enum 127

* Enum 127 is also electric metering type

* Meter type constants and status enums in smartenergy cluster handler

Addresses 
https://github.com/home-assistant/core/pull/109126#discussion_r1471383887

Whilst I have the code open I've also added status handlers for the non-electrical meter types.

* New tests for different metering device type statuses
2024-01-30 15:09:15 -05:00
David F. Mulcahey 92795fecf5
Clean up ZHA cover entity and add support for inverting cover entities derived from the window covering cluster (#108238) 2024-01-30 13:59:00 +01:00
David F. Mulcahey 950660b953
Reorganize ZHA device availability code (#108856)
* Correct ZHA device availability at startup

* don't set available property from gateway

* cleanup
2024-01-27 07:17:05 -05:00
David F. Mulcahey 3f31a76692
Apply consistent naming to ZHA cluster handler implementations (#108851)
* Apply consistent naming to ZHA cluster handler implentations

* remove import alias

* remove if statement around assert in test
2024-01-25 20:09:38 -05:00
Jack af1ba4b22f
Add ZHA metering summation received sensor (#107576)
* Add sensor for exposing Summation Received from Metering cluster

* Ruff format

* Test updates for new sensor

* Update test_sensor.py to support summation_received

* Correct report_count for smart meterning and some pylint warning fixes
2024-01-24 07:56:49 -05:00
puddly 22eed5419e
Reduce log level of ZHA endpoint handler init (#108749)
* Reduce the log level of endpoint handler init failure to debug

* Reduce log level in unit test
2024-01-23 21:04:59 -05:00
Florian Kisser b5bb97c856
Fix zha illuminance measured value mapping (#108547) 2024-01-20 20:37:13 -05:00
J. Nick Koston c399cab427
Small speed up to checking core state (#107845) 2024-01-18 08:41:32 -10:00
puddly 867caab70a
Speed up ZHA initialization and improve startup responsiveness (#108103)
* Limit concurrency of startup traffic to allow for interactive usage

* Drop `retryable_req`, we already have request retrying

* Oops, `min` -> `max`

* Add a comment describing why `async_initialize` is not concurrent

* Fix existing unit tests

* Break out fetching mains state into its own function to unit test
2024-01-17 18:36:28 -05:00
Jan-Philipp Benecke 10014838ef
Dynamically map state class, device class and UoM in ZHA smart energy metering sensor (#107685)
* Dynamically map state class, device class and UoM in ZHA smart energy metering sensor

* Fix some state & device classes and add scaling

* Fix added imperial gallons tests

* Use entity description instead of custom class & add one entity to tests

* Apply code review suggestion

* Scale only when needed

* Revert "Scale only when needed"

This reverts commit a9e0403402.

* Avoid second lookup of entity description

* Change test to not mix sensor types
2024-01-17 00:40:00 +01:00
puddly b0adaece25
Reload ZHA only a single time when the connection is lost multiple times (#107963)
* Reload only a single time when the connection is lost multiple times

* Ignore when reset task finishes, allow only one reset per `ZHAGateway`
2024-01-13 16:32:25 -05:00
puddly 98c41f7398
Bump ZHA dependencies (#106756)
* Bump ZHA dependencies

* Revert "Remove bellows thread, as it has been removed upstream"

This reverts commit c28053f4bf.
2023-12-31 04:54:09 -05:00
Caius-Bonus 37707edc47
Match ZHA Custom ClusterHandler on a Custom Cluster using a unique id for the quirk (#101709)
* initial

* fix tests

* match on specific name and quirk name

* fix tests

* fix tests

* store cluster handlers in only one place

* edit tests

* use correct device for quirk id

* change quirk id

* fix tests

* even if there is a quirk id, it doesn't have to have a specific cluster handler

* add tests

* rename quirk_id

* add tests

* fix tests

* fix tests

* use quirk id from zha_quirks
2023-12-27 11:48:30 -05:00
David F. Mulcahey 817c71747f
Delay all ZHA polling until initialization of entities has completed (#105814)
* Don't update entities until they are initialized

* fix hass reference

* only establish polling once

* fix log level and small cleanup

* start device availability checks after full initialization of network

* add logging

* clean up sensor polling and class hierarchy

* don't attempt restore sensor cleanup in this PR

* put check back

* fix race condition and remove parallel updates

* add sensor polling test

* cleanup switch polling and add a test

* clean up and actually fix race condition

* update light forced refresh

* only use flag

* unused flag

* reduce diff size

* collapse
2023-12-27 10:25:41 -05:00
G Johansson 83f4d3af5c
Implement mode validation in Climate entity component (#105745)
* Implement mode validation in Climate entity component

* Fix some tests

* more tests

* Fix translations

* fix deconz tests

* Fix switcher_kis tests

* not None

* Fix homematicip_cloud test

* Always validate

* Fix shelly

* reverse logic in validation

* modes_str

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-27 14:51:39 +01:00
Erik Montnemery 3a744d374b
Add support for caching entity properties (#100601) 2023-12-22 09:02:55 -10:00
Ville Skyttä 24b1e01d71
Update Ruff to 0.1.8, avoid linter/formatter conflicts (#106080)
* Disable Ruff rules that may conflict with the formatter

* Upgrade Ruff to 0.1.8

- https://github.com/astral-sh/ruff/releases/tag/v0.1.7
- https://github.com/astral-sh/ruff/releases/tag/v0.1.8

* Format with Ruff 0.1.8
2023-12-20 23:55:09 +01:00
puddly 4e9b9add29
Bump ZHA dependencies (#105661) 2023-12-13 17:06:46 +01:00
puddly e475829ce6
Reload ZHA integration on any error, not just recoverable ones (#105659) 2023-12-13 16:24:26 +01:00
Joakim Plate bb0d082b25
Correctly report unavailable battery for value 255 of percentage (#104566)
* Ignore unavailable battery level for zha

* Adjust unavailable test
2023-12-11 19:17:06 +01:00
Jan Bouwhuis 953a212dd6
Use ServiceValidationError for invalid fan preset_mode and move check to fan entity component (#104560)
* Use ServiceValidationError for fan preset_mode

* Use _valid_preset_mode_or_raise to raise

* Move preset_mode validation to entity component

* Fix bond fan and comments

* Fixes baf, fjaraskupan and template

* More integration adjustments

* Add custom components mock and test code

* Make NotValidPresetModeError subclass

* Update homeassistant/components/fan/strings.json

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Keep bond has_action validation

* Move demo test asserts outside context block

* Follow up comment

* Update homeassistant/components/fan/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Fix demo tests

* Remove pylint disable

* Remove unreachable code

* Update homeassistant/components/fan/__init__.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Use NotValidPresetModeError, Final methods

* Address comments

* Correct docst

* Follow up comments

* Update homeassistant/components/fan/__init__.py

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-11-29 13:56:51 +01:00
puddly bd8f01bd35
Bump ZHA dependencies (#104335) 2023-11-29 11:30:15 +01:00
TheJulianJES 2663a4d617
Bump zha-quirks to 0.0.107 (#104683) 2023-11-29 09:19:02 +01:00
TheJulianJES a996a51aa9
Add "Jasco Products" manufacturer to ZHA `ForceOnLight` (#104089)
* Add "Jasco Products" manufacturer to ZHA `ForceOnLight`

* Change tests to expect `ForceOnLight` for "Jasco Products" lights
2023-11-16 15:24:32 -05:00
TheJulianJES ac0c1d12c3
Add test checking ZHA light restores with `None` attributes (#102806)
* Add ZHA test checking light restores with None attributes

* Move shared `core_rs` fixture to `conftest.py`

* Remove special `color_mode` case, use `parametrize` for expected state

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2023-11-15 10:45:35 +01:00
tronikos 6294339944
Improve ZHA King of Fans (#101859) 2023-10-25 05:56:08 +02:00
TheJulianJES fd8fdba7e8
Replace ZHA quirk class matching with quirk ID matching (#102482)
* Use fixed quirk IDs for matching instead of quirk class

* Change tests for quirk id (WIP)

* Do not default `quirk_id` to `quirk_class`

* Implement test for checking if quirk ID exists

* Change `quirk_id` for test slightly (underscore instead of dot)
2023-10-24 17:18:10 -04:00
Tomáš Bedřich d25b4aae14
Add ZHA cover tilt (#102072)
* cover tilt reimplementation

* rework tilt test

* Fix ZHA cover tests

* Match ZHA cover tilt code-style with the rest

* Increase coverage for ZHA cover, optimize update

---------

Co-authored-by: josef109 <josefglaze@gmail.com>
2023-10-24 15:40:41 -04:00
puddly 8a79870e3a
Clean up stale ZHA database listener when reconnecting to radio (#101850) 2023-10-20 08:48:33 +02:00