mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-15 14:48:43 +00:00
Add support for HS300 power strip (#137)
* discover runs, prints on since of device 0 * added preliminary support for HS300 * forgot to add smartdevice to commit * added index to CLI * clean up dirty code * added fake sysinfo_hs300 * changed device alias to match MAC * #131 Move _id_to_index into smartstrip so everyone can pass index * Update pyHS100/discover.py Co-Authored-By: jimboca <jimboca3@gmail.com> * refactoring to deduplicate code between smarplug and smartstrip * fixing CI failures for devices without children * incorporating feedback from pull request. * fixing hound violation * changed internal store from list of dicts to dict * changed other methods to dictionary store as well * removed unused optional type from imports * changed plugs to Dict, remove redundant sys_info calls * added more functionality for smart strip, added smart strip tests * updated FakeTransportProtocol for devices with children * corrected hound violations * add click-datetime
This commit is contained in:
@@ -33,9 +33,10 @@ class SmartPlug(SmartDevice):
|
||||
|
||||
def __init__(self,
|
||||
host: str,
|
||||
protocol: 'TPLinkSmartHomeProtocol' = None) -> None:
|
||||
SmartDevice.__init__(self, host, protocol)
|
||||
self.emeter_type = "emeter"
|
||||
protocol: 'TPLinkSmartHomeProtocol' = None,
|
||||
context: str = None) -> None:
|
||||
SmartDevice.__init__(self, host, protocol, context)
|
||||
self._type = "emeter"
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
@@ -126,7 +127,6 @@ class SmartPlug(SmartDevice):
|
||||
|
||||
:return: True if switch supports brightness changes, False otherwise
|
||||
:rtype: bool
|
||||
|
||||
"""
|
||||
return "brightness" in self.sys_info
|
||||
|
||||
@@ -193,8 +193,15 @@ class SmartPlug(SmartDevice):
|
||||
:return: datetime for on since
|
||||
:rtype: datetime
|
||||
"""
|
||||
return datetime.datetime.now() - \
|
||||
datetime.timedelta(seconds=self.sys_info["on_time"])
|
||||
if self.context:
|
||||
for plug in self.sys_info["children"]:
|
||||
if plug["id"] == self.context:
|
||||
on_time = plug["on_time"]
|
||||
break
|
||||
else:
|
||||
on_time = self.sys_info["on_time"]
|
||||
|
||||
return datetime.datetime.now() - datetime.timedelta(seconds=on_time)
|
||||
|
||||
@property
|
||||
def state_information(self) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user