Commit graph

1572 commits

Author SHA1 Message Date
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
Nils Bergmann
08497db358
Extend ZHA thermostat local temperature calibration range for Sonoff TRVZB (#109691)
* Extend thermostat local temperature calibration range

* Extend thermostat local temperature calibration range only for TRVZB

* Change _attr_native_min_value and _attr_native_max_value back to -2.5 and 2.5

* Adjust _attr_native_step for TRVZB to 0.2

* Implement requested changes

* Fix platform for MULTI_MATCH

* Implement requested changes

* Implement requested changes
2024-02-27 08:32:23 -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
4ea1c5cc3c
Add support for importing integrations in the executor (#111336)
* Add support for pre-imports at setup time

alternative solution to #111331

* refactor

* refactor

* refactor

* mark >1.0s integrations

* no point in executor if already loaded

* no point in executor if already loaded

* cleanup

* cleanup

* two more

* one more

* analytics loads a lot more integrations

* cloud

* debug

* psutil, hardwre

* try zha

* Update homeassistant/setup.py

* await

* comments

* coverage

* coverage

* coverage

* move logic to loader

* move logic to loader

* preserve comments
2024-02-26 14:49:43 -05:00
David F. Mulcahey
5d4dc63118
Bump ZHA dependencies (#111227) 2024-02-23 17:57:39 -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
David F. Mulcahey
6bdb3357fa
Remove ZHA storage file cleanup logic (#111088) 2024-02-21 22:02:41 +01:00
TimL
c8bf589384
Auto detect ZHA SMLIGHT SLZB-07 dongle (#110982) 2024-02-21 21:39:16 +01:00
Franck Nijhof
1c55ba0cb2
Use covariant for fire event data type (#110843) 2024-02-18 13:21:55 +01: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
puddly
26e6bc8a6a
Bump ZHA dependency zigpy to 0.62.3 (#109848) 2024-02-07 06:22:54 +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
61ce328ce1
Fix docstring length in ZHA sensor class (#109774)
Fix ZHA sensor docstring length
2024-02-06 03:00:45 +01: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
G Johansson
16b20403e6
Add migrated climate feature flags to zha (#109443) 2024-02-03 03:06:55 +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
Caius-Bonus
3b7ec8ed2c
Use EnumSensor instead of custom formatter() in ZHA Sensor entities (#109218)
use EnumSensor for SonofPresenceSensorIlluminationStatus and AqaraPetFeederLastFeedingSource
2024-01-31 11:53:10 -05:00
David F. Mulcahey
ac8f555a70
Add additional entities for the Aqara E1 curtain motor to ZHA (#108243)
* aqara curtain motor opened by hand binary sensor

add icon and translation key for identify button

remove previous inversion entity

add window covering type sensor and aqara curtain motor sensors

add aqara curtain motor hook lock switch

add aqara curtain motor attributes zcl_init_attrs

add aqara curtain motor zcl_init_attrs

translations

* update translation string

* review comments

* use enum sensor after rebase

* remove button change
2024-01-30 22:40:33 -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
TheJulianJES
1aa9807e26
Fix "deprecated" typo in ZHA smartenergy comment (#109173)
* Fix "deprecated" typo in ZHA smartenergy comment

* Fix in both places
2024-01-31 00:07:59 +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
puddly
7fbfd44636
Filter ZHA light group color modes (#108861)
Ensure ZHA light color modes have proper defaults and are filtered
2024-01-30 15:14:03 -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
G Johansson
b4c0e52ebd
Add TURN_ON/OFF ClimateEntityFeature for ZHA (#108978) 2024-01-30 17:57:11 +01: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
puddly
b9f48f62de
Bump ZHA dependency zigpy to 0.60.7 (#109082) 2024-01-29 23:59:56 +01:00
David F. Mulcahey
c3222ef733
Fix statuses for ZHA attribute reporting configuration event (#108532)
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
2024-01-28 19:28:06 +01:00
David F. Mulcahey
7069fb9508
Add model check to ZHA Sonoff manufacturer specific cluster handler (#108947) 2024-01-27 10:40:23 -05: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
David F. Mulcahey
74a60929e4
Use Zigpy definition objects in ZHA cluster handlers (#108383)
* use zigpy def objects in ZHA cluster handlers

* shorten with direct imports

* shorten with rename due to clash
2024-01-25 08:47:26 -05:00
TheJulianJES
4138b5c308
Reduce log level for creating ZHA cluster handler (#108809) 2024-01-25 08:45:11 -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
Peter Hall
701404fa0b
Add ZHA entities for snzb06p (#107379)
* Updating zha component to add entities for snzb06p

Sonoff snzb06p presence detector needs some custom entities.

* Updating ZCL_INIT_ATTRS for sonoff specific attrs

* updating cluster name due to change in quirk
2024-01-23 08:31:32 -05:00
Florian Kisser
b5bb97c856
Fix zha illuminance measured value mapping (#108547) 2024-01-20 20:37:13 -05: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
puddly
3ae858e3bf
Bump ZHA dependency zigpy to 0.60.6 (#108266)
Bump zigpy to 0.60.6
2024-01-17 18:34:10 -05:00
Joakim Plate
c827bba780
Let zigpy decide on default manufacturer id (#108257)
* zha: let cluster set default manufacturer id

* zha: allow forcing manufacturer id off
2024-01-17 15:42:20 -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
Dorian Benech
2584de6324
Add TICMeter Energy Metering sensors (#107956) 2024-01-13 16:53:53 -05: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
Marc Mueller
c1faafc6a0
Add decorator typing [zha] (#107599) 2024-01-12 11:42:10 +01:00
David F. Mulcahey
2ed9397611
Fix assertion error when unloading ZHA with pollable entities (#107311) 2024-01-05 16:53:43 -05:00