Simplify data_key for a stable unique_id because the order of the dict will not be preserved (Closes: #13522) (#19766)
parent
3453d31f01
commit
3a466195b9
|
@ -18,9 +18,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
model = device['model']
|
||||
if model == 'curtain':
|
||||
devices.append(XiaomiGenericCover(device, "Curtain",
|
||||
{'status': 'status',
|
||||
'pos': 'curtain_level'},
|
||||
gateway))
|
||||
'status', gateway))
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
|
@ -45,20 +43,20 @@ class XiaomiGenericCover(XiaomiDevice, CoverDevice):
|
|||
|
||||
def close_cover(self, **kwargs):
|
||||
"""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):
|
||||
"""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):
|
||||
"""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):
|
||||
"""Move the cover to a specific 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):
|
||||
"""Parse data sent by gateway."""
|
||||
|
|
Loading…
Reference in New Issue