mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Initialize xiaomi aqara binary sensor state (#68791)
This commit is contained in:
parent
9b05a1264a
commit
ea2c3e3310
@ -464,6 +464,11 @@ class XiaomiVibration(XiaomiBinarySensor):
|
|||||||
attrs.update(super().extra_state_attributes)
|
attrs.update(super().extra_state_attributes)
|
||||||
return attrs
|
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):
|
def parse_data(self, data, raw_data):
|
||||||
"""Parse data sent by gateway."""
|
"""Parse data sent by gateway."""
|
||||||
value = data.get(self._data_key)
|
value = data.get(self._data_key)
|
||||||
@ -499,6 +504,11 @@ class XiaomiButton(XiaomiBinarySensor):
|
|||||||
attrs.update(super().extra_state_attributes)
|
attrs.update(super().extra_state_attributes)
|
||||||
return attrs
|
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):
|
def parse_data(self, data, raw_data):
|
||||||
"""Parse data sent by gateway."""
|
"""Parse data sent by gateway."""
|
||||||
value = data.get(self._data_key)
|
value = data.get(self._data_key)
|
||||||
@ -545,7 +555,6 @@ class XiaomiCube(XiaomiBinarySensor):
|
|||||||
"""Initialize the Xiaomi Cube."""
|
"""Initialize the Xiaomi Cube."""
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._last_action = None
|
self._last_action = None
|
||||||
self._state = False
|
|
||||||
if "proto" not in device or int(device["proto"][0:1]) == 1:
|
if "proto" not in device or int(device["proto"][0:1]) == 1:
|
||||||
data_key = "status"
|
data_key = "status"
|
||||||
else:
|
else:
|
||||||
@ -559,6 +568,11 @@ class XiaomiCube(XiaomiBinarySensor):
|
|||||||
attrs.update(super().extra_state_attributes)
|
attrs.update(super().extra_state_attributes)
|
||||||
return attrs
|
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):
|
def parse_data(self, data, raw_data):
|
||||||
"""Parse data sent by gateway."""
|
"""Parse data sent by gateway."""
|
||||||
if self._data_key in data:
|
if self._data_key in data:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user