Commit Graph

453 Commits (135fe26704c2fce94a85d3266919bd762e394028)

Author SHA1 Message Date
Sid 3799d20d43
Enable Ruff B905 (#114197) 2024-04-14 00:14:26 -05:00
Jan Bouwhuis be8adf9d29
Fix zha test by tweaking the log level (#115368) 2024-04-10 13:10:46 -10:00
Sid 0d66d298ec
Enable Ruff RET504 (#114528)
* Enable Ruff RET504

* fix test

* Use noqa instead of cast

* fix sonos RET504

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-06 11:07:37 +02:00
epenet 9204ccfa17
Use is in ConfigEntryState enum comparison in tests (N-Z) (#114926) 2024-04-05 17:37:00 +02:00
Joost Lekkerkerker f3ba713289
Use FlowResultType enum in config flow tests N-Z (#114682)
Use FlowResultType enum in config flow tests
2024-04-03 09:53:20 +02:00
Joost Lekkerkerker 2ef0521d3d
Use is in enum comparison in config flow tests U-Z (#114677)
* Use right enum expression U-Z

* Fix
2024-04-02 23:09:56 +02: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
Sid d846676e84
Enable first batch of Ruff RET rules (#114480)
* Enable first batch of Ruff RET rules

* disable pylint rules
2024-03-31 11:30:59 +02:00
TheJulianJES b0a1450a2b
Fix ZHA websocket API test (#114495)
* Fix result overwriting expected config

* Use `BASE_CUSTOM_CONFIGURATION` for initial/expected config
2024-03-31 00:17:09 +01:00
Marc Mueller a29dc86f62
Fix ruff error (#114364) 2024-03-28 10:31:42 +01:00
puddly fc34453caa
Support the Home Assistant Connect ZBT-1 (#114213) 2024-03-27 18:20:48 +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
Sid 00ec7f11f0
Enable Ruff rule PT007 (#113764)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
2024-03-19 09:01:07 +01:00
Sid 727581eea3
Add first batch of Ruff PT rules (#113665)
* Add first batch of Ruff PT rules

* fix weather test

* Fix pilight test

* Update test_intent.py

* Update pilight test_init.py

* Update test_init.py
2024-03-18 13:26:14 +01:00
Sid 27e844e3bf
Add ruff B005, B015, B032 and fix occurrences (#113543)
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-03-15 17:48:37 -10:00
TheJulianJES 9ec0e097ef
Remove ZHA IasZone sensor migration (#111893) 2024-03-12 18:18:20 -04: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
J. Nick Koston 7ea79148ba
Ignore logging events in zha websocket tests (#113031) 2024-03-10 13:13:26 -10:00
J. Nick Koston 65358c129a
Replace periodic tasks with background tasks (#112726)
* Phase out periodic tasks

* false by default or some tests will block forever, will need to fix each one manually

* kwarg works

* kwarg works

* kwarg works

* fixes

* fix more tests

* fix more tests

* fix lifx

* opensky

* pvpc_hourly_pricing

* adjust more

* adjust more

* smarttub

* adjust more

* adjust more

* adjust more

* adjust more

* adjust

* no eager executor

* zha

* qnap_qsw

* fix more

* fix fix

* docs

* its a wrapper now

* add more coverage

* coverage

* cover all combos

* more fixes

* more fixes

* more fixes

* remaining issues are legit bugs in tests

* make tplink test more predictable

* more fixes

* feedreader

* grind out some more

* make test race safe

* one more
2024-03-08 21:45:10 -05:00
puddly 55b2d1a00c
Disable updating ZHA coordinator path from discovery info (#112415)
* Never update the device path from config flows

* Bring coverage up to 100%

* Update tests/components/zha/test_config_flow.py

Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>

---------

Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
2024-03-08 14:33:33 -05:00
Marc Mueller 32f3f46542
Add empty line after module docstring (2) [tests.components] (#112737) 2024-03-08 19:16:21 +01:00
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