Initialize xiaomi aqara binary sensor state (#68791)
This commit is contained in:
parent
9b05a1264a
commit
ea2c3e3310
1 changed files with 15 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue