Fix service device refresh calling state update (#30920)

This commit is contained in:
Robert Svensson
2020-01-18 00:33:46 +01:00
committed by Paulus Schoutsen
parent 7b29a498c6
commit c9db21ffac
8 changed files with 44 additions and 27 deletions

View File

@@ -97,11 +97,13 @@ class DeconzSensor(DeconzDevice):
"""Representation of a deCONZ sensor."""
@callback
def async_update_callback(self, force_update=False):
def async_update_callback(self, force_update=False, ignore_update=False):
"""Update the sensor's state."""
changed = set(self._device.changed_keys)
if ignore_update:
return
keys = {"on", "reachable", "state"}
if force_update or any(key in changed for key in keys):
if force_update or self._device.changed_keys.intersection(keys):
self.async_schedule_update_ha_state()
@property
@@ -155,11 +157,13 @@ class DeconzBattery(DeconzDevice):
"""Battery class for when a device is only represented as an event."""
@callback
def async_update_callback(self, force_update=False):
def async_update_callback(self, force_update=False, ignore_update=False):
"""Update the battery's state, if needed."""
changed = set(self._device.changed_keys)
if ignore_update:
return
keys = {"battery", "reachable"}
if force_update or any(key in changed for key in keys):
if force_update or self._device.changed_keys.intersection(keys):
self.async_schedule_update_ha_state()
@property
@@ -217,7 +221,7 @@ class DeconzSensorStateTracker:
self.sensor = None
@callback
def async_update_callback(self):
def async_update_callback(self, ignore_update=False):
"""Sensor state updated."""
if "battery" in self.sensor.changed_keys:
async_dispatcher_send(