Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOAD_POWER not necessary an integer. #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/switch/xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def device_state_attributes(self):
ATTR_LOAD_POWER: self._load_power,
ATTR_POWER_CONSUMED: self._power_consumed}
attrs.update(super().device_state_attributes)
return attrs
return attrs

def turn_on(self, **kwargs):
"""Turn the switch on."""
self.xiaomi_hub.write_to_hub(self._sid, self._data_key, 'on')
Expand All @@ -81,7 +82,8 @@ def turn_off(self):
self.xiaomi_hub.write_to_hub(self._sid, self._data_key, 'off')

def parse_data(self, data):
"""Parse data sent by gateway"""
"""Parse data sent by gateway"""

if IN_USE in data:
self._in_use = int(data[IN_USE])
if not self._in_use:
Expand All @@ -91,7 +93,7 @@ def parse_data(self, data):
self._power_consumed = int(data[POWER_CONSUMED])

if LOAD_POWER in data:
self._load_power = int(data[LOAD_POWER])
self._load_power = float(data[LOAD_POWER])

value = data.get(self._data_key)
if value is None:
Expand Down