Skip to content

Commit

Permalink
Simplify data_key for a stable unique_id because the order of the dic…
Browse files Browse the repository at this point in the history
…t will not be preserved (Closes: #13522) (#19766)
  • Loading branch information
syssi committed Jan 7, 2019
1 parent 3c46543 commit 8b232e7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions homeassistant/components/cover/xiaomi_aqara.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -45,20 +43,20 @@ def is_closed(self):

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."""
Expand Down

0 comments on commit 8b232e7

Please sign in to comment.