mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Fix for HomeKit controller state not updating after put (#25903)
This commit is contained in:
parent
61b687edec
commit
34cde21876
@ -273,6 +273,12 @@ class HKDevice:
|
|||||||
# connection was dropped.
|
# connection was dropped.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.process_new_events(new_values_dict)
|
||||||
|
|
||||||
|
_LOGGER.debug("Finished HomeKit controller update")
|
||||||
|
|
||||||
|
def process_new_events(self, new_values_dict):
|
||||||
|
"""Process events from accessory into HA state."""
|
||||||
self.available = True
|
self.available = True
|
||||||
|
|
||||||
for (aid, cid), value in new_values_dict.items():
|
for (aid, cid), value in new_values_dict.items():
|
||||||
@ -281,8 +287,6 @@ class HKDevice:
|
|||||||
|
|
||||||
self.hass.helpers.dispatcher.async_dispatcher_send(self.signal_state_updated)
|
self.hass.helpers.dispatcher.async_dispatcher_send(self.signal_state_updated)
|
||||||
|
|
||||||
_LOGGER.debug("Finished HomeKit controller update")
|
|
||||||
|
|
||||||
async def get_characteristics(self, *args, **kwargs):
|
async def get_characteristics(self, *args, **kwargs):
|
||||||
"""Read latest state from homekit accessory."""
|
"""Read latest state from homekit accessory."""
|
||||||
async with self.pairing_lock:
|
async with self.pairing_lock:
|
||||||
@ -298,10 +302,30 @@ class HKDevice:
|
|||||||
chars.append((row["aid"], row["iid"], row["value"]))
|
chars.append((row["aid"], row["iid"], row["value"]))
|
||||||
|
|
||||||
async with self.pairing_lock:
|
async with self.pairing_lock:
|
||||||
await self.hass.async_add_executor_job(
|
results = await self.hass.async_add_executor_job(
|
||||||
self.pairing.put_characteristics, chars
|
self.pairing.put_characteristics, chars
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Feed characteristics back into HA and update the current state
|
||||||
|
# results will only contain failures, so anythin in characteristics
|
||||||
|
# but not in results was applied successfully - we can just have HA
|
||||||
|
# reflect the change immediately.
|
||||||
|
|
||||||
|
new_entity_state = {}
|
||||||
|
for row in characteristics:
|
||||||
|
key = (row["aid"], row["iid"])
|
||||||
|
|
||||||
|
# If the key was returned by put_characteristics() then the
|
||||||
|
# change didnt work
|
||||||
|
if key in results:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Otherwise it was accepted and we can apply the change to
|
||||||
|
# our state
|
||||||
|
new_entity_state[key] = {"value": row["value"]}
|
||||||
|
|
||||||
|
self.process_new_events(new_entity_state)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""
|
"""
|
||||||
|
@ -74,6 +74,7 @@ class FakePairing:
|
|||||||
if char.iid != cid:
|
if char.iid != cid:
|
||||||
continue
|
continue
|
||||||
char.set_value(new_val)
|
char.set_value(new_val)
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class FakeController:
|
class FakeController:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user