Merge pull request #5 from smaggard/add-hs200

Adding in support for the HS200 Wall switch referencing issues (#4)
This commit is contained in:
GadgetReactor 2016-10-28 11:08:42 +08:00 committed by GitHub
commit 9c39249b99

View File

@ -9,6 +9,7 @@ import codecs
import json import json
import datetime import datetime
import sys import sys
import re
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -104,7 +105,7 @@ class SmartPlug(object):
False if command is not successful or the switch doesn't support energy metering False if command is not successful or the switch doesn't support energy metering
Dict with the current readings Dict with the current readings
""" """
if self.model == 100: if self.model != 110:
return False return False
response = self._send_command('{"emeter":{"get_realtime":{}}}') response = self._send_command('{"emeter":{"get_realtime":{}}}')
@ -126,7 +127,7 @@ class SmartPlug(object):
False if command is not successful or the switch doesn't support energy metering False if command is not successful or the switch doesn't support energy metering
Dict where the keys represent the days, and the values are the aggregated statistics Dict where the keys represent the days, and the values are the aggregated statistics
""" """
if self.model == 100: if self.model != 110:
return False return False
response = self._send_command('{"emeter":{"get_daystat":{"month":' + str(month) + ',"year":' + str(year) + '}}}') response = self._send_command('{"emeter":{"get_daystat":{"month":' + str(month) + ',"year":' + str(year) + '}}}')
@ -152,7 +153,7 @@ class SmartPlug(object):
False if command is not successful or the switch doesn't support energy metering False if command is not successful or the switch doesn't support energy metering
Dict - the keys represent the months, the values are the aggregated statistics Dict - the keys represent the months, the values are the aggregated statistics
""" """
if self.model == 100: if self.model != 110:
return False return False
response = self._send_command('{"emeter":{"get_monthstat":{"year":' + str(year) + '}}}') response = self._send_command('{"emeter":{"get_monthstat":{"year":' + str(year) + '}}}')
@ -175,7 +176,7 @@ class SmartPlug(object):
True: Success True: Success
False: Failure or not supported by switch False: Failure or not supported by switch
""" """
if self.model == 100: if self.model != 110:
return False return False
response = self._send_command('{"emeter":{"erase_emeter_stat":null}}') response = self._send_command('{"emeter":{"erase_emeter_stat":null}}')
@ -187,7 +188,7 @@ class SmartPlug(object):
def current_consumption(self): def current_consumption(self):
"""Get the current power consumption in Watt.""" """Get the current power consumption in Watt."""
if self.model == 100: if self.model != 110:
return False return False
response = self.get_emeter_realtime() response = self.get_emeter_realtime()
@ -252,10 +253,5 @@ class SmartPlug(object):
def _identify_model(self): def _identify_model(self):
"""Query sysinfo and determine model""" """Query sysinfo and determine model"""
sys_info = self.get_info() sys_info = self.get_info()
model = re.sub('HS', '', sys_info["system"]["get_sysinfo"]["model"][:5])
if sys_info["system"]["get_sysinfo"]["model"][:5] == 'HS100':
model = 100
elif sys_info["system"]["get_sysinfo"]["model"][:5] == 'HS110':
model = 110
return model return model