* 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
* Delay ZHA group updates to ensure all members are updated first
After turning off a group, when the first device reports "off", the
other devices may still be "on". If HA processes the group state update
quickly enough, the group will see that some devices are on, so the
state of the group will revert back to "on", and then "off" when the
remaining devices all report "off". That would cause the UI toggle to go
back and forward quickly, and automations that trigger with "state: on"
to fire when the user turns the group off.
This PR fixes that by delaying the group state update, giving time for
all the devices to report their states first.
* Fix zha group tests
* Reorder sleeping.
* Update tests/components/zha/common.py
Co-authored-by: Alexei Chetroi <lexoid@gmail.com>
* add flag to prevent sending an on command
* fix condition
* add constant for default transition
* make groups work with new force on flag
* reorder light entity creation
* rearrange logic
* update test
* remove failed attempt at group light flag
* fix flag
* 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>
* start of fan groups
* update fan classes
* update group entity domains
* add set speed
* update discovery for multiple entities for groups
* add fan group entity tests
* cleanup const
* cleanup entity_domain usage
* remove bad super call
* remove bad update line
* fix set speed on fan group
* change comparison
* pythonic list
* discovery guards
* Update homeassistant/components/zha/core/discovery.py
Co-Authored-By: Alexei Chetroi <lexoid@gmail.com>
Co-authored-by: Alexei Chetroi <lexoid@gmail.com>
* split entity into base and entity
* add initial light group support
* add dispatching of groups to light
* added zha group object
* add group event listener
* add and remove group members
* get group by name
* fix rebase
* fix rebase
* use group_id for unique_id
* get entities from registry
* use group name
* update entity domain
* update zha storage to handle groups
* dispatch group entities
* update light group
* fix group remove and dispatch light group entities
* allow picking the domain for group entities
* beginning - auto determine entity domain
* move methods to helpers so they can be shared
* fix rebase
* remove double init groups... again
* cleanup startup
* use asyncio create task
* group entity discovery
* add logging and fix group name
* add logging and update group after probe if needed
* test add group via gateway
* add method to get group entity ids
* update storage
* test get group by name
* update storage on remove
* test group with single member
* add light group tests
* test some light group logic
* type hints
* fix tests and cleanup
* revert init changes except for create task
* remove group entity domain changing for now
* add missing import
* tricky code saving
* review comments
* clean up class defs
* cleanup
* fix rebase because I cant read
* make pylint happy
* cleanup timer handle when device is removed
* separate unavailable times for mains vs battery
* better name
* remove light refresh handle when removing light
* remove unused parallel updates
* don't steal HA const for different purpose
* don't flood network every hour for lights
* update test to test both intervals
* add test for light refresh interval
* fix tests
* update test
* put parallel updates back for now...
* fix async_schedule_update_ha_state usage
* review comment
* review comment
* update test - review conversation
* review comments
* await count not call count
* flip some state
* Use light's on_level in ZHA to turn on at the correct brightness
Previously, if the light is turned off with a time transition, the
brightness level stored in the light will be 1. The next time the light
is turned on with no explicit brightness, it will be at 1.
This is solved by storing the current brightness in on_level before
turning off, and then using that when turning on (by calling the
onOff cluster 'on' command).
* store off light level locally to avoid wearing device's flash memory
* store off brightness in HA attributes
* improve set/clear of off_brightness
* fix device_state_attributes; clear off_brightness when light goes on
* fix tests
* Add support for DoorLock cluster
* Add test for zha lock
* Change lock_state report to REPORT_CONFIG_IMMEDIATE
* Update channel command wrapper to return the entire result
This allows for return values other than result[1]
* Fix tests
* Fix lint
* Update DoorLock test to work with updated zigpy schema
* Fix lint
* Fix unlock test
* Refactor async_turn_on() for ZHA Light.
Use "move_to_level_with_on_off" if brightness or transition attributes
are present in the service call data, otherwise issue "On" Zigbee
command.
Allow brightness of 0 for service call -- effectively turning the light
off.
Send color commands only after the light was turned on.
* Fix zha.light tests.