Commit Graph

39 Commits (0293315b23cf15e148bc45e8fc99f8773879e5d0)

Author SHA1 Message Date
J. Nick Koston 481de8cdc9
Ensure config entry operations are always holding the lock (#117214)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2024-05-12 08:20:08 +09:00
Marc Mueller 87165c0d6e
Add empty line after module docstring [tests t-z] (#112712) 2024-03-08 14:44:56 +01:00
puddly 2e4df6d2f2
Open a ZHA repair when network settings change (#99482) 2023-10-09 15:01:05 +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 22c5071270
Initialize ZHA device database before connecting to the radio (#98082)
* Create ZHA entities before attempting to connect to the coordinator

* Delete the ZHA gateway object when unloading the config entry

* Only load ZHA groups if the coordinator device info is known offline

* Do not create a coordinator ZHA device until it is ready

* [WIP] begin fixing unit tests

* [WIP] Fix existing unit tests (one failure left)

* Fix remaining unit test
2023-08-31 12:09:46 -04:00
puddly f9ac1f3839
Add a channel changing API to ZHA (#92076)
* Expose channel changing over the websocket API

* Expose channel changing as a service

* Type annotate some existing unit test fixtures

* Add unit tests

* Rename `api.change_channel` to `api.async_change_channel`

* Expand on channel migration in the service description

* Remove channel changing service, we only really need the websocket API

* Update homeassistant/components/zha/websocket_api.py

* Black

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-04-27 11:04:22 -04:00
puddly 72414a5864
Load quirks in ZHA unit tests (#91779) 2023-04-21 08:24:39 +02:00
puddly d0a492644d
Correctly load ZHA settings from API when integration is not running (#90476)
Correctly load settings from the zigpy database when ZHA is not running
2023-03-29 17:24:26 -04:00
epenet 5f3868b141
Add missing type hints to tests (#90218)
* Add type hints to tests

* Revert gree as handled in #90222
2023-03-24 19:34:01 -07:00
puddly c581116c82
ZHA network settings API (#88564)
* Rename `zha.api` to `zha.websocket_api`

* Implement a ZHA network settings API

* Use the enum name as the radio type

* Don't filter out ignored config entries

* [WIP] Start unit tests

* Add unit tests

* Rename ZHA websocket API module in `.coveragerc`

* Rename `api` to `websocket_api`

* Increase test coverage to 100%
2023-03-22 11:15:46 -04: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
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
David F. Mulcahey ebffe0f33b
Fix ZHA configuration APIs (#81874)
* Fix ZHA configuration loading and saving issues

* add tests
2022-11-13 08:30:16 -05:00
puddly 4b24370549
ZHA Yellow config flow fixes (#77603) 2022-08-31 11:21:37 -04:00
puddly 8e2f0497ce
ZHA network backup and restore API (#75791)
* Implement WS API endpoints for zigpy backups

* Implement backup restoration

* Display error messages caused by invalid backup JSON

* Indicate to the frontend when a backup is incomplete

* Perform a coordinator backup before HA performs a backup

* Fix `backup.async_post_backup` docstring

* Rename `data` to `backup` in restore command

* Add unit tests for new websocket APIs

* Unit test backup platform

* Move code to overwrite EZSP EUI64 into ZHA

* Include the radio type in the network settings API response
2022-07-28 11:24:31 -04:00
J. Nick Koston 4bc5d7bfed
Speed up zha tests (#73627) 2022-06-17 11:41:10 -05: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 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
Alexei Chetroi 505dd500cb
Bump up ZHA dependencies (#53472)
* Bump up ZHA dependencies

* Fix ZHA WS API tests
2021-07-25 22:09:40 -04:00
tkdrob 3baeed3684
Clean up constants (#47323) 2021-03-05 19:08:04 +01:00
Franck Nijhof 65cf2fcb6f
Drop asynctest (#44746) 2021-01-01 22:31:56 +01: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
Alexei Chetroi 47286fbe2a
Refactor permit services to allow joining using install codes (#40652)
* Update zha.permit schema to support install code

* Move install code to core helpers

* QR code converter for enbrighten

* Fix schemas

* Update test for permit service

* Refactor zha.permit to accept install codes

* Test zha.permit from QR code

* Fix regex for Embrighten QR code

* Add regex for Aqara QR codes

* Add Consciot regex for QR code

* Reuse test params for WS tests

* ZHA WS permit command with install code

* Tests for zha.permit WS service

* Refactor zha.permit and zha.remove service to use ATTR_IEEE for the address

* Make pylint happy

* Deprecate only ieee_address param for now
2020-09-28 20:55:08 -04:00
Alexei Chetroi 1bdbe90d2a
Prevent double ZHA channel initialization (#36554)
* Preven double channel initialization.

* Use a setter for setting ZHA device availability.
2020-06-08 08:54:52 -04:00
David F. Mulcahey 8279efc164
Group by endpoints and not by devices for ZHA Zigbee groups (#34583)
* start implementation
* handle members correctly
* fix group member info
* align groupable devices with group members
* handle group endpoint adding and removing
* update add group
* update group and group member
* update create group
* remove domain check
* update test
* remove temporary 2nd groupable device api
* update test
* rename validator - review comment
* fix test that was never running
* additional testing
* fix coordinator descriptors
* remove check that was done twice
* update test
* Use AsyncMock()
Co-authored-by: Alexei Chetroi <lexoid@gmail.com>
2020-05-04 15:19:53 -04:00
Alexei Chetroi 52fe1328f6
ZHA tests refactoring (#31744)
* Refactor ZHA fixtures.
Patch Zigpy radio libs instead of ZHA when setting up fixtures.
Use new fixtures for binary_sensor.zha platform.

* Update ZHA api tests.
* Update ZHA channels and discovery tests.
* Update ZHA cover tests.
* Update device action/trigger tests.
* Update device_tracker.zha platform tests.
* Update fan.zha platform tests.
* Update ZHA gateway tests.
* Update lock.zha platform tests.
* Update switch.zha platform tests.
* Update sensor.zha platform tests.
* Update light.zha platform tests.
* Use MockConfigEntry.
* Address PR comments.
2020-02-12 16:12:14 -05:00
Alexei Chetroi 28eeed1db3
ZHA tests refactoring (#31682)
* Fixtures for restoring/joning a device.

* binary_sensor.zha tests.

* cover.zha platform tests.

* device_tracker.zha platform tests.

* fan.zha platform tests.

* switch.zha platform tests.

* Update light.zha platform tests.

* Update sensor.zha platform tests.

* ZHA api tests refactoring.

* Update lock.zha platform tests.

* Update ZHA gateway tests.

* Update zha device action tests.

* Update zha device trigger tests.

* Cleanup.
2020-02-09 21:45:35 -05:00
David F. Mulcahey 1222aa8c56 Add ZHA group API (#29641)
* add skeleton to retrieve zigbee groups
* get single group
* add a group
* return group members with group
* add comment
* fix group members
* add function to add device to group
* add group members
* add remove from group method
* add api to remove members from group
* add remove groups method
* clean up group add and remove
* fix remove group
* fix remove groups
* add api to get only groupable devices
* change var init
* add tests
* address review comment
2019-12-09 14:50:04 -05:00
Alexei Chetroi fe7c45b363
Move remaining of ZHA imports to top level. (#28071)
* Move ZHA import to top level.
* ZHA tests: move imports to top level.
2019-10-21 19:30:56 -04:00
David F. Mulcahey 6f2ac705eb
Add web socket API command to get a single ZHA device (#26196)
* get single device web socket command

* test get single device

* add not found error

* fix handling when device doesn't exist

* add test for zha device not found
2019-08-26 09:54:19 -04:00
Alexei Chetroi 77e4ff94fd ZHA code cleanup. (#25644)
* isort ZHA imports.

* Sort zha channel registry.

* Sort ZHA core registry.

* Sort ZHA core consts.
2019-08-02 06:05:23 -04:00
Paulus Schoutsen 4de97abc3a Black 2019-07-31 12:25:30 -07:00
David F. Mulcahey 300384410f
Refactor ZHA gateway into modules and add admin protections to API (#22023)
* refactor

* cleanup

* fix tests

* admin all the things
2019-03-14 10:20:25 -04:00
David F. Mulcahey 901b2b4ba3
new websocket api way (#21533) 2019-02-28 19:32:41 -05:00
David F. Mulcahey 3f9e6a7064 Add power source to device and clean up zha listeners (#21174)
check available and add comments

ensure order on API test
2019-02-18 16:55:41 +01:00
David F. Mulcahey 80442e655d
Update ZHA API to be device oriented (#20990)
* update cluster API

* swap to device focused API

* update test
2019-02-12 15:05:02 -05:00
David F. Mulcahey 868820c424
add device info API (#20950) 2019-02-11 14:38:04 -05:00
David F. Mulcahey 326010629c
Add some api tests for ZHA (#20909)
* start API tests

* blank lines
2019-02-10 06:29:36 -05:00