Commit Graph

56 Commits (7e11fec761dcdc108cd8e355c4f19d1a79d50270)

Author SHA1 Message Date
Sid 3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Sid d5f883fbf0
Unignore Ruff PLR in tests (#114470)
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
2024-04-01 11:11:59 +02:00
Marc Mueller a29dc86f62
Fix ruff error (#114364) 2024-03-28 10:31:42 +01:00
David F. Mulcahey c518acfef3
Defensively validate ZHA quirks v2 supplied entity metadata (#112643) 2024-03-27 17:48:43 +01:00
Joost Lekkerkerker 6bb4e7d62c
Bump ruff to 0.3.4 (#112690)
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-26 00:02:16 +01:00
Joost Lekkerkerker cddce0ce0d
Enable more SIM ruff rules (#113015)
* SIM101 SIM103

* SIM107 SIM109

* SIM110

* SIM112 SIM113

* SIM115

* SIM116

* Fix

* Fix

* Fix
2024-03-10 23:20:37 -04:00
Marc Mueller 87165c0d6e
Add empty line after module docstring [tests t-z] (#112712) 2024-03-08 14:44:56 +01: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 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
Joakim Plate 29e8814d1b
Add translation entiry support (zha) (#101909)
* zha: Add translation to binary sensors

* Add some small test for name

* Add translations for sensors

* Correct some tests

* Adjust summation key

* Add translation keys for button

* Add translation keys to climate

* Add translation keys for cover

* Add translation keys to fan

* Add translations to light

* Add translations for lock

* Add translation keys to number

* Add translationk keys to select

* Add translations for switch entities

* Add translation to alarm control panel

* Map to some more standard device classes

* Use shorter references

* Remove explicit name from identify button

* Correct tests

* Correction after rebase
2023-10-17 21:59:49 +02:00
puddly cbb28b6943
Migrate internal ZHA data to a dataclasses (#100127)
* Cache device triggers on startup

* reorg zha init

* don't reuse gateway

* don't nuke yaml configuration

* review comments

* Add unit tests

* Do not cache device and entity registries

* [WIP] Wrap ZHA data in a dataclass

* [WIP] Get unit tests passing

* Use a helper function for getting the gateway object to fix annotations

* Remove `bridge_id`

* Fix typing issues with entity references in group websocket info

* Use `Platform` instead of `str` for entity platform matching

* Use `get_zha_gateway` in a few more places

* Fix flaky unit test

* Use `slots` for ZHA data

Co-authored-by: J. Nick Koston <nick@koston.org>

---------

Co-authored-by: David F. Mulcahey <david.mulcahey@icloud.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2023-09-11 21:39:33 +02:00
puddly 22dfa8797f
Bump ZHA dependencies (#93989)
* Make `find_entity_id` synchronous

* Remove `tries`

* Use new `attribute_updated` event signature

* Validate attributes before creating entities

* Avoid swallowing exceptions when opening covers

* Bump ZHA dependencies

* Add a matcher for Sinope water leak sensors using a non-standard ZCL attribute

* Ensure handler matching is strict, not multi

* Add type annotations for newly-updated functions
2023-06-14 21:42:31 -04:00
puddly b03c429db7
Revert "Increase Zigbee command retries (#93877)" (#94123) 2023-06-06 17:44:29 +02:00
puddly b9ec3a8af8
Increase Zigbee command retries (#93877)
* Enable retries for requests

* Update unit tests

* Account for fewer group retries in unit tests
2023-05-31 20:08:18 -04:00
puddly 6842cdcb65
Clean up default ZHA entity names (#91841)
* Always use `Light` for lights, including subclasses

* Clean up other platforms

* Add a unit test to ensure all future entity classes have names

* Remove stale `_name`

* Address review feedback and rename `Open` to `Opening`
2023-04-25 19:51:39 -04:00
puddly 72414a5864
Load quirks in ZHA unit tests (#91779) 2023-04-21 08:24:39 +02:00
epenet 1797dca0b8
Fix lingering timer in ZHA tests (#91688)
* Fix lingering timer in ZHA discovery tests

* Add type hints

* Also update gateway tests
2023-04-19 13:00:25 -04:00
David F. Mulcahey 9c784ac622
Refactor ZHA (#91476)
* rename channel -> cluster handler

* remove refs to channels and create endpoint class

* remove remaining references to channels

* fix filter

* take in latest changes from #91403

* missed one

* missed a reference
2023-04-19 10:47:07 -04:00
epenet 9762b684c2
Adjust entity registry access in tests (3) (#88964) 2023-03-01 16:04:40 +01:00
epenet 7427d4f323
Add type hints to integration tests (zha) (#88309) 2023-02-17 18:54:26 +01:00
Franck Nijhof ed79265843
Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet 4142f0d15d
Add return type to tests without arguments (#87613)
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Franck Nijhof e50a531cd9
Code styling tweaks to the tests - Part 2 (#86662)
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
2023-01-26 01:23:53 +01:00
TheJulianJES f740312247
Fix some typos in ZHA comments (#84881)
* Fix copy paste errors

* Fix "setup/set up" usage

* Fix typo

* Fix comment

* Fix copy paste errors

* Remove space at end of comment

* Remove double word

* Fix copy paste errors

* Fix typos

* Apply review suggestion

* Upper-case zha (to ZHA) everywhere

* Review: fix "over rules"

* Review: most/more
2023-01-02 00:20:59 -05:00
puddly 73e26b71b1
Migrate ZHA lighting to use newer zigpy ZCL request syntax (#77676)
* Migrate unit test to use more command definition constants

* Use keyword argument syntax for sending ZCL requests

* Ensure all ZHA unit tests pass
2022-09-01 15:32:32 -04:00
David F. Mulcahey 6f28e4bfee
Migrate ZHA to new entity naming standard (#74846) 2022-07-10 13:17:59 -07:00
David F. Mulcahey 57c94c0350
Add additional configuration entities for ZHA lights (#70597)
* Add more configuration entities for ZHA lights

* fix typing circular imports

* enhance filter in entity factory

* fix read attribute chunking

* add test

* add exception test
2022-05-16 13:04:32 -04:00
David F. Mulcahey 9b8d217b0e
Implement support for start_up_on_off in ZHA (#70110)
* Implement support for start_up_on_off

fix discovery issues

remove cover change

* add tests
2022-04-24 12:50:06 -04:00
puddly 0f6296e4b5
Bump zigpy to 0.44.1 and zha-quirks to 0.0.69 (#68921)
* Make unit tests pass

* Flip response type check to not rely on it being a list
https://github.com/zigpy/zigpy/pull/716#issuecomment-1025236190

* Bump zigpy and quirks versions to ZCLR8 releases

* Fix renamed zigpy cluster attributes

* Handle the default response for ZLL `get_group_identifiers`

* Add more error context to `stage failed` errors

* Fix unit test returning lists as ZCL request responses

* Always load quirks when testing ZHA

* Bump zha-quirks to 0.0.69
2022-03-31 11:26:27 -04:00
Alexei Chetroi b54f2c9487
Don't throw when a Zigbee device has an unknown ZCL cluster (#62964)
* Fix channel name for clusters with None ep_attribute

* Correctly generate entity name based on channel names
2021-12-28 21:04:11 -05:00
David F. Mulcahey 0062676f61
Add lqi and rssi sensors back to ZHA (#62716)
* update device list

* Only 1 identify button per device

* Add LQI and RSSI sensors to ZHA

* refactor entity creation filter

* update device list and update discover test

* fix reference

* code reduction

* walrus

* parens

* simplify
2021-12-24 16:48:02 -05:00
David F. Mulcahey 41531b528e
Add identify buttons to ZHA devices (#61495)
* Identify buttons

* clean up and add test

* use Platform

* update device list

* Only 1 identify button per device

* cleanup press until the need arises for the branch

* make imports relative
2021-12-23 17:52:42 -05:00
Alexei Chetroi 997809c6c4
Refactor ZHA entity matching process (#60063)
* Group multi-matches by channels

* Group multi-matched by explicit groups

* Registryless AnalogInput and PowerConfiguration

* Refactor single cluster sensor registry

* Refactor single cluster cover and lock registry

* Refactor single cluster binary_sensor registry

* Pylint
2021-12-12 07:52:49 -05:00
David F. Mulcahey a17031630f
Use Platform enum in ZHA (#61016) 2021-12-11 11:06:39 -05:00
Alexei Chetroi dbba2c4afe
Add "Summation Delivered" Sensor for SmartEnergy metering ZHA channel (#56666) 2021-09-29 09:35:20 -07:00
Alexei Chetroi c6888e4faf
Refactor ZHA tests (#55844)
* Replace ZHA tests FakeDevice

* Refactor ZHA tests to use zigpy devices and endpoints

* Use common consts for zigpy device mocks

Use the same dict key names for device signature mocks as zha quirks.

* Use const for test device list

* Update tests/components/zha/common.py
2021-09-06 19:00:06 -04:00
Ville Skyttä 470f2dd73f
Upgrade pyupgrade to 2.21.2, apply its changes (#52987) 2021-07-19 10:46:09 +02:00
Franck Nijhof ad13a9295e
Merge multiple context managers in tests (#48146) 2021-03-27 09:17:15 +01:00
Erik Montnemery b3fecb1c95
Update tests t-z to use async_get() instead of async_get_registry() (#47655) 2021-03-09 14:25:03 +01:00
Quentame 198ecb0945
Uniformize platform setup (#47101)
* A platform is not a component

* Fix dynalite

* SUPPORTED_PLATFORMS --> PLATFORMS

* In tests

* In tests 2

* Fix SmartThings

* Fix ZHA test

* Fix Z-Wave

* Revert Z-Wave

* Use PLATFORMS const in ambient_station

* Fix ihc comment
2021-03-02 21:43:59 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01:00
Alexei Chetroi 8868028dcd
Bump up ZHA dependencies (#42679)
* Bump up ZHA dependencies

* Fix tests because of zigpy request signature change
2020-11-01 11:05:55 -05:00
Samantha a8b68dc4f9
Add Neighbors & Endpoint Names to zha/devices reply (#40748)
* Add Neighbors & Endpoint Names to zha/devices reply.

* Remove unused const

* Add tests & correct const name.

* Change tests to use corresponding enum device_type
2020-09-29 15:25:05 -04:00
Franck Nijhof 1c2ebdf307
Upgrade black to 20.8b1 (#39287) 2020-08-27 13:56:20 +02:00
J. Nick Koston ab6d6ac1ce
Reduce time to run zha discover tests (#37424)
Most of the time was registering services and patching
the clusters which are never calls in these tests
2020-07-03 12:57:04 -05:00
Paulus Schoutsen ec47216388
Use built-in test helpers on 3.8 (#34901) 2020-04-30 13:29:50 -07:00
David F. Mulcahey c1962a4895
Read min and max mireds from ZHA lights (#33983)
* implement min and max mireds

* remove unnecessary else

* additional light test

* add test to appease the codecov god

* change defaults
2020-04-10 23:19:17 -04:00
Franck Nijhof 03dd92d51b
Use set literals in tests (#33669) 2020-04-05 02:20:09 +02:00
Alexei Chetroi 991afccbd4
Refactor ZHA EventChannels (#32709)
* Refactor EventChannels.

* Rename EventRelayChannel.

* Fully rename EventRelayChannel.

- update docstrings
- rename all references from "relay" to "client"

* Remove CHANNEL_NAME.

* Update stale docstring.
2020-03-21 19:59:32 -04:00