mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Simplify data_key for a stable unique_id because the order of the dict will not be preserved (Closes: #13522) (#19766)
This commit is contained in:
parent
3c465434cd
commit
8b232e7ce6
@ -18,9 +18,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
model = device['model']
|
model = device['model']
|
||||||
if model == 'curtain':
|
if model == 'curtain':
|
||||||
devices.append(XiaomiGenericCover(device, "Curtain",
|
devices.append(XiaomiGenericCover(device, "Curtain",
|
||||||
{'status': 'status',
|
'status', gateway))
|
||||||
'pos': 'curtain_level'},
|
|
||||||
gateway))
|
|
||||||
add_entities(devices)
|
add_entities(devices)
|
||||||
|
|
||||||
|
|
||||||
@ -45,20 +43,20 @@ class XiaomiGenericCover(XiaomiDevice, CoverDevice):
|
|||||||
|
|
||||||
def close_cover(self, **kwargs):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
self._write_to_hub(self._sid, **{self._data_key['status']: 'close'})
|
self._write_to_hub(self._sid, **{self._data_key: 'close'})
|
||||||
|
|
||||||
def open_cover(self, **kwargs):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
self._write_to_hub(self._sid, **{self._data_key['status']: 'open'})
|
self._write_to_hub(self._sid, **{self._data_key: 'open'})
|
||||||
|
|
||||||
def stop_cover(self, **kwargs):
|
def stop_cover(self, **kwargs):
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
self._write_to_hub(self._sid, **{self._data_key['status']: 'stop'})
|
self._write_to_hub(self._sid, **{self._data_key: 'stop'})
|
||||||
|
|
||||||
def set_cover_position(self, **kwargs):
|
def set_cover_position(self, **kwargs):
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
position = kwargs.get(ATTR_POSITION)
|
position = kwargs.get(ATTR_POSITION)
|
||||||
self._write_to_hub(self._sid, **{self._data_key['pos']: str(position)})
|
self._write_to_hub(self._sid, **{ATTR_CURTAIN_LEVEL: str(position)})
|
||||||
|
|
||||||
def parse_data(self, data, raw_data):
|
def parse_data(self, data, raw_data):
|
||||||
"""Parse data sent by gateway."""
|
"""Parse data sent by gateway."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user