Commit Graph

303 Commits (22bfb99db415a6747e056df80cee3efbe3e5fa68)

Author SHA1 Message Date
Erik Montnemery cc564026fa
Move EntityCategory to homeassistant.const (#87792)
* Move EntityCategory to homeassistant.const

* Fix more imports
2023-02-09 20:15:37 +01:00
epenet 278050a73f
Add type hints to integration tests (t-z) (#87707) 2023-02-08 19:10:53 +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 1409b89af3
Sync input_select & select (#87255) 2023-02-03 15:43:17 +01:00
Franck Nijhof 5e81d28116
Update black to 23.1.0 (#87188) 2023-02-02 18:35:24 +01:00
puddly 8337d4613e
ZHA config flow cleanup (#86742)
fixes undefined
2023-01-30 22:21:34 +01:00
Franck Nijhof a79885ceaf
Enable Ruff SIM117 (#86783) 2023-01-27 11:52:49 +01:00
Franck Nijhof 62dcbe5258
Enable Ruff PT001 (#86730) 2023-01-26 18:05:05 +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 0cf676d501
Remove unnecessary ZHA AnalogInput sensors for Xiaomi plugs (#86261)
* Remove unnecessary ZHA AnalogInput sensors for Xiaomi plugs

* Remove AnalogInput entities from test
2023-01-25 06:17:33 -05:00
Marc Mueller 00e5f23249
Update Union typing (zha) [Py310] (#86453) 2023-01-23 14:46:40 +01:00
TheJulianJES 6582ee3591
Use ExecuteIfOff on color cluster for supported bulbs with ZHA (#84874)
* Add options and execute_if_off_supported properties to Color channel

* Initialize "options" attribute on Color channel (allowing cache)

* Implement execute_if_off_supported for ZHA lights

* Make sure that color_channel exists, before checking execute_if_off_supported

* Replace "color_channel is not None" check with simplified "if color_channel"

* Make "test_number" test expect "options" for init attribute

* Add test_on_with_off_color test to test old and new behavior

* Experimental code to also support "execute_if_off" for groups if all members support it

* Remove support for groups for now

Group support will likely be added in a separate PR. For now, the old/standard behavior is used for groups.
2023-01-23 07:58:18 -05:00
Erik Montnemery 1e2f00e186
Improve device automation validation (#86143) 2023-01-21 00:44:17 +01:00
Franck Nijhof 79b52a2b41
Stricter pylint message control (#86154) 2023-01-20 13:47:55 +01:00
TheJulianJES 9f0bed0f0c
Implement "group members assume state" option for ZHA (#84938)
* Initial "group members assume state" implementation for ZHA

* Remove left-over debug flag (where polling was disabled)

* Implement _send_member_assume_state_event() method and also use after turn_off

* Only assume updated arguments from service call to group

* Make code more readable and change checks slightly

* Move "send member assume state" events to LightGroup on/off calls

* Include new config option in tests

* Check that member is available before updating to assumed state

* Lower "update group from child delay" for debouncer to basically 0 when using assumed member state

* Allow "child to group" updates regardless of config option

This is not needed, as group members will not update their state, as long as they're transitioning. (If a group transitions, it also sets its members to transitioning mode)

This fixes multiple issues. Previously, the state of a group was completely wrong when:
- turn on group with 10 second transition
- turn on members individually
- turn off members individually
- group state would not update correctly

* Move "default update group from child delay" constant

* Change to new constant name in test

* Also update fan test to new constant name

* Decrease "update group from child delay" to 10ms

In my testing, 0.0 also works without any issues and correctly de-bounces child updates when using the "assume state option".
This is just for avoiding multiple state changes when changing the group -> children issue individual updates.
With 2 children in a group and delay 0, both child updates only cause one group re-calculation and state change.

0.01 (10ms) should be plenty for very slow systems to de-bounce the update (and in the worst case, it'll cause just another state change but nothing breaks)

* Also implement "assuming state" for effect

Not sure if anybody even uses this, but this one is a bit special because the effect is always deactivated if it's not provided in the light.turn_on call.

* Move shortened delay for "assuming members" to a constant

* Add basic test to verify that group members assume on/off state

* Move _assume_group_state function declaration out of async_added_to_hass

* Fix rare edge-case when rapidly toggling lights and light groups at the same time

This prevents an issue where either the group transition would unset the transition flag or the single light would unset the group transition status midst-transition.

Note: When a new individual transition is started, we want to unset the group flag, as we actually cancel that transition.

* Check that effect list exists, add return type

* Re-trigger CI due to timeout

* Increase ASSUME_UPDATE_GROUP_FROM_CHILD_DELAY slightly

The debouncer is used when updating group member states either by assuming them (in which case we want to barely have any delay), or between the time we get the results back from polling (where we want a slightly longer time).
As it's not easily possible to distinguish if a group member was updated via assuming the state of the group or by the polling that follows, 50 ms seems to be a good middle point.

* Add debug print for when updating group state

* Fix issues with "off brightness" when switching between group/members

This fixes a bunch of issues with "off brightness" and passes it down to the members correctly.
For example, if a light group is turned off with a transition (so bulbs get their level set to 1), this will also set the "off brightness" of all individual bulbs to the last level that they were at.

(It really fixes a lot of issues when using the "member assume group state" option. It's not really possible to fix them without that.)

Furthermore, issues where polling was previously needed to get the correct state after "playing with transitions", should now get be resolved and get correct state when using the "members assume group state" option.

Note: The only case which still can't be fixed is the following:
If individual lights have off_with_transition set, but not the group, and the group is then turned on without a level, individual lights might fall back to brightness level 1 (<- at least now shows correctly in UI even before polling).
Since all lights might need different brightness levels to be turned on, we can't use one group call. But making individual calls when turning on a ZHA group would cause a lot of traffic and thereby be counter-productive.
In this case, light.turn_on should just be called with a level (or individual calls to the lights should be made).

Another thing that was changed is to reset off_with_transition/off_brightness for a LightGroup when a member is turned on (even if the LightGroup wasn't turned on using its turn_on method).
off_with_transition/off_brightness for individual bulbs is now also turned off when a light is detected to be on during polling.

Lastly, the waiting for polled attributes could previously cause "invalid state" to be set (so mid-transition levels).
This could happen when group and members are repeatedly toggled at similar times. These "invalid states" could cause wrong "off brightness" levels if transitions are also used.
To fix this, we check after waiting for the polled attributes in async_get_state to see if a transition has started in the meanwhile. If so, the values can be discarded. A new poll will happen later and if using the "members assume group state" config option, the values should already be correct before the polling.

* Enable "group members assume state" config option by default

The config tests are also updated to expect the config option be enabled by default.

For all tests, the config option is generally disabled though:
There are only two group related tests. The one that tests this new feature overrides the config option to be enabled anyway.
The other tests works in a similar way but also "sends" attribute reports, so we want to disable the feature for that test.
(It would also run with it enabled (if the correct CHILD_UPDATE value is patched), but then it would test the same stuff as the other test, hence we're disabling the config option for that test.)
2023-01-16 10:48:18 -05:00
Paul Bottein c3e27f6812
Add tier summation delivered for Lixee Zlinky TIC (#82602)
* Add tier summation delivered for zlinky

* Improve name case

* Add other tiers and register tier

* Fix smartenergy sensor update

* Account for new reporting configuration in unit tests

* Use cluster ID attributes instead of hardcoding the values

* Use tier names instead of the numeric constants for formatter

* Revert active register tier delivered

* Fix tests

Co-authored-by: puddly <32534428+puddly@users.noreply.github.com>
2023-01-16 10:33:18 -05:00
Michael 9828b2d13f
Replace the usage of unit constants by enumerations in Tests [v-z] (#85938)
replace unit conts by enums v-z
2023-01-15 20:14:02 +02:00
puddly 757e4cf9e1
Retry ZHA config entry setup when `ENETUNREACH` is caught (#84615)
* The config entry is not ready on `ENETUNREACH`

* Use new `TransientConnectionError` from zigpy
2023-01-07 10:46:33 +01:00
puddly 015281078a
Bump ZHA dependencies (#85355)
* Bump ZHA dependencies

* Deprecated `foundation.Command` -> `foundation.GeneralCommand`
2023-01-06 23:01:36 -05: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
Maciej Bieniek a8f09b4063
Round illuminance value in ZHA integration (#84500) 2022-12-23 13:24:15 +01:00
Erik Montnemery a6217ca9b9
Improve error message when an automation fails to validate (#83977) 2022-12-21 23:20:50 +01:00
Erik Montnemery 774ebc760c
Ignore certain device trigger validation errors (#83972) 2022-12-14 16:41:11 +01:00
puddly 7f96fbb035
Bump ZHA dependencies (#82999) 2022-11-30 20:56:07 +01:00
Erik Montnemery b7652c78ee
Add options flow to enable multiprotocol support on sky connect (#82525) 2022-11-29 16:34:55 -05:00
Marc Mueller 63d519c1a8
Spelling updates (#82867) 2022-11-28 16:51:43 +01:00
Erik Montnemery be7e76f302
Migrate ZHA when enabling multi-PAN support on HA Yellow (#82213)
* Migrate ZHA when enabling multi-PAN support on HA Yellow

* Refactor BaseZhaFlow.async_step_maybe_confirm_ezsp_restore

* Change data passed to ZHA to initiate migration

* Catch errors during ZHA migration

* Fix ZhaMigrationHelper.async_prepare_yellow_migration return value

* Improve test coverage

* Improve test coverage

* Fix spelling

* Rename some none HA yellow specifics

* Rename again

* Increase number of migration retries + refactor

* Suppress OperationNotAllowed when reloading

* Adjust tests
2022-11-22 11:17:23 +01:00
puddly dfed57ed4d
Bump ZHA dependencies (#82509)
* Bump ZHA dependencies

* Use the corrected `TypeValue` keyword argument name in unit tests
2022-11-21 19:39:34 -05:00
Erik Montnemery bb64b39d0e
Minor refactor of zha config flow (#82200)
* Minor refactor of zha config flow

* Move ZhaRadioManager to a separate module
2022-11-16 17:13:23 +01: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 74357bef15
Use a unique ID for the Yellow ZHA hardware discovery (#81523)
* Set unique ID for hardware discovery

* Use the provided `name` for discovered hardware
2022-11-07 11:28:28 -05:00
David F. Mulcahey d1fd141e8c
Bump ZHA quirks and associated changes (#81587) 2022-11-07 12:28:59 +01:00
David F. Mulcahey 83c6a7e18b
Fix invalid min and max color temp in bad ZHA light devices (#81604)
* Fix ZHA default color temps

* update test
2022-11-05 08:40:28 -04:00
puddly b8edc86500
Handle sending ZCL commands with empty bitmap options (#81051)
Handle sending commands with empty bitmaps
2022-10-26 21:29:48 -04:00
Julian Löhr 6795627734
Add ZHA StartUpColorTemperature configuration entity (#80853)
* Add ZHA start up color temperature entity

* Use device reported min max values

* Add color number test

* Fix code style
2022-10-23 18:46:47 -04:00
TheJulianJES b4a203c3c7
Add friendly name to ZHA identify button (#80446) 2022-10-16 19:57:24 -04:00
David F. Mulcahey d75e449c52
Add ability to convert ZCL schemas to vol schemas to ZHA (#79908)
* try serializing cluster command schemas

* use min and max value from zigpy type

* different type assignments

* initial command execution changes

* cleanup

* cleanup and typing

* typing

* typing

* add tests

* mypy

* handle raw values too

* check for None responses

* make backwards compatible

* update yaml for svc change
2022-10-14 08:15:10 -04:00
David F. Mulcahey 20d71a869e
Add friendly entity names for ZHA sensors (#80035)
* Add friendly entity names for ZHA sensors

* lowercase 2nd word
2022-10-10 15:40:42 -04:00
TheJulianJES 3126762707
Add friendly name to ZHA config entities (#79926)
* Add friendly name to ZHA config entities

* Follow HA capitalization conventions

* Change from "Start-up level" to "Start-up current level"

* Remove siren select friendly names (temporarily)

* Change tests to expect new entity ids

* Re-add siren select friendly names

* Change siren tests to expect new entity ids
2022-10-09 09:11:42 -04:00
puddly 2dab9073fe
ZHA radio migration: reset the old adapter (#79663) 2022-10-06 14:02:24 -04:00
David F. Mulcahey 2ed48a9b28
Add configuration entities and device actions for Inovelli Blue Series switch to ZHA (#79106)
* Add Inovelli configutation entities to ZHA

* add device actions

* fix attribute name collision

* add device action tests

* disable remote protection per Inovelli request

* expect_reply to false

* update test for expect_reply change

* inovelli feedback

* translation keys and strings

* clean up numbers

* prevent double events

* remove individual LED defaults per inovelli

* redundant check

* update test
2022-09-28 14:22:39 -04:00
epenet 0d696b84b2
Cleanup root component imports in tests (#78893) 2022-09-21 06:57:41 -10:00
epenet 4f31f28e67
Cleanup SourceType in tests (#78809) 2022-09-20 10:50:07 -04:00
epenet 25b1dfb53a
Cleanup EntityCategory in tests (#78808) 2022-09-20 10:49:44 -04:00
epenet 7bc2712142
Adjust root-import in tests (#78761)
* Adjust root-import in tests

* Adjust diagnostics

* Adjust button

* Adjust select

* Adjust device_tracker

* Adjust camera

* Adjust humidifier

* Adjust media_source

* Adjust update

* Adjust siren

* Adjust number

* Adjust alarm_control_panel

* Adjust notify

* Adjust sensor

* Adjust switch

* Revert anthemav

* Don't adjust demo humidifier
2022-09-19 15:22:23 +02:00
epenet e9f55f4e54
Apply hass-relative-import to tests (s-z) (#78733) 2022-09-19 09:51:31 +02:00
David F. Mulcahey 9d47160e68
Fix sengled bulbs in ZHA (#78315)
* Fix sengled bulbs in ZHA

* fix tests

* update discovery data
2022-09-12 15:37:11 -04:00
puddly f19af72895
Bump ZHA dependencies (#78201) 2022-09-10 13:56:01 -04:00
puddly 4076f8b94e
Fix ZHA lighting initial hue/saturation attribute read (#77727)
* Handle the case of `current_hue` being `None`

* WIP unit tests
2022-09-07 11:10:24 -04: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