Set homekit alarm/sensor/switch/cover state as soon as possible (#34245)
* Set homekit alarm/sensor/switch state as soon as possible This change is part of a multi-part effort to fix the HomeKit event storms on startup. Previously we would set the states after HomeKit had started up which meant that when the controller client connected it would request the states and get a list of default states so all the initial states would always be wrong. The defaults states generally went unnoticed because we set the state of each HomeKit device soon after which would result in an event storm in the log that looked like the following for every client and every device: Sending event to client: ('192.168.x.x', 58410) Sending event to client: ('192.168.x.x', 53399) Sending event to client: ('192.168.x.x', 53399) To solve this, we now set the state right away when we create the entity in HomeKit, so it is correct on initial sync, which avoids the event storm. Additionally, we now check all states values before sending an update to HomeKit to ensure we do not send events when nothing has changed. * pylint * Fix event storm in covers as well * fix refactoring error in security system * cover positions, now with constants
This commit is contained in:
parent
188f3e35fd
commit
d6a47cb3e0
6 changed files with 146 additions and 80 deletions
|
@ -190,3 +190,8 @@ HK_DOOR_CLOSED = 1
|
|||
HK_DOOR_OPENING = 2
|
||||
HK_DOOR_CLOSING = 3
|
||||
HK_DOOR_STOPPED = 4
|
||||
|
||||
# ### Position State ####
|
||||
HK_POSITION_GOING_TO_MIN = 0
|
||||
HK_POSITION_GOING_TO_MAX = 1
|
||||
HK_POSITION_STOPPED = 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue