Initialize xiaomi aqara binary sensor state (#68791)

This commit is contained in:
Sebastian Muszynski 2022-03-30 21:13:35 +02:00 committed by GitHub
parent 9b05a1264a
commit ea2c3e3310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -464,6 +464,11 @@ class XiaomiVibration(XiaomiBinarySensor):
attrs.update(super().extra_state_attributes)
return attrs
async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
self._state = False
def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
@ -499,6 +504,11 @@ class XiaomiButton(XiaomiBinarySensor):
attrs.update(super().extra_state_attributes)
return attrs
async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
self._state = False
def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
value = data.get(self._data_key)
@ -545,7 +555,6 @@ class XiaomiCube(XiaomiBinarySensor):
"""Initialize the Xiaomi Cube."""
self._hass = hass
self._last_action = None
self._state = False
if "proto" not in device or int(device["proto"][0:1]) == 1:
data_key = "status"
else:
@ -559,6 +568,11 @@ class XiaomiCube(XiaomiBinarySensor):
attrs.update(super().extra_state_attributes)
return attrs
async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
self._state = False
def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
if self._data_key in data: