mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 11:13:34 +00:00
* Add check to ensure devices with lat/lon with `_i` suffix are supported (#54) * Add .gitignore for posterity
This commit is contained in:
parent
09e8948790
commit
93d24281c6
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Compiled python modules.
|
||||
__pycache__/
|
||||
|
||||
# Setuptools distribution folder.
|
||||
/dist/
|
||||
|
||||
# Python egg metadata, regenerated from source files by setuptools.
|
||||
/*.egg-info
|
||||
/*.egg
|
||||
|
||||
/build
|
@ -291,8 +291,19 @@ class SmartDevice(object):
|
||||
:rtype: dict
|
||||
"""
|
||||
info = self.sys_info
|
||||
return {"latitude": info["latitude"],
|
||||
"longitude": info["longitude"]}
|
||||
loc = {"latitude": None,
|
||||
"longitude": None}
|
||||
|
||||
if "latitude" in info and "longitude" in info:
|
||||
loc["latitude"] = info["latitude"]
|
||||
loc["longitude"] = info["longitude"]
|
||||
elif "latitude_i" in info and "longitude_i" in info:
|
||||
loc["latitude"] = info["latitude_i"]
|
||||
loc["longitude"] = info["longitude_i"]
|
||||
else:
|
||||
_LOGGER.warning("Unsupported device location.")
|
||||
|
||||
return loc
|
||||
|
||||
@property
|
||||
def rssi(self):
|
||||
|
@ -45,6 +45,28 @@ emeter_units_support = {"get_realtime": get_realtime_units,
|
||||
"get_monthstat": get_monthstat_units,
|
||||
"get_daystat": get_daystat_units,}
|
||||
|
||||
sysinfo_hs105 = {'system': {'get_sysinfo':
|
||||
{'sw_ver': '1.0.6 Build 160722 Rel.081616',
|
||||
'hw_ver': '1.0', 'type': 'IOT.SMARTPLUGSWITCH',
|
||||
'model': 'HS105(US)',
|
||||
'mac': '50:C7:BF:xx:xx:xx',
|
||||
'dev_name': 'Smart Wi-Fi Plug Mini',
|
||||
'alias': 'TP-LINK_Smart Plug_CF0B',
|
||||
'relay_state': 0,
|
||||
'on_time': 0,
|
||||
'active_mode': 'none',
|
||||
'feature': 'TIM',
|
||||
'updating': 0,
|
||||
'icon_hash': '',
|
||||
'rssi': 33,
|
||||
'led_off': 0,
|
||||
'longitude_i': -12.2,
|
||||
'latitude_i': 12.2,
|
||||
'hwId': '60FF6B258734EA6880E186F8C96DDC61',
|
||||
'fwId': '00000000000000000000000000000000',
|
||||
'deviceId': '800654F32938FCBA8F7327887A38647617',
|
||||
'oemId': 'FFF22CFF774A0B89F7624BFC6F50D5DE'}}}
|
||||
|
||||
sysinfo_hs110 = {'system': {'get_sysinfo':
|
||||
{'active_mode': 'schedule',
|
||||
'alias': 'Mobile Plug',
|
||||
|
@ -5,7 +5,7 @@ import datetime
|
||||
import re
|
||||
|
||||
from .. import SmartPlug, SmartPlugException
|
||||
from .fakes import FakeTransportProtocol, sysinfo_hs110
|
||||
from .fakes import FakeTransportProtocol, sysinfo_hs110, sysinfo_hs105
|
||||
|
||||
PLUG_IP = '192.168.250.186'
|
||||
SKIP_STATE_TESTS = False
|
||||
@ -221,6 +221,11 @@ class TestSmartPlug(TestCase):
|
||||
def test_location(self):
|
||||
self.sysinfo_schema(self.plug.location)
|
||||
|
||||
def test_location_i(self):
|
||||
plug_i = SmartPlug(PLUG_IP,
|
||||
protocol=FakeTransportProtocol(sysinfo_hs105))
|
||||
self.sysinfo_schema(plug_i.location)
|
||||
|
||||
def test_rssi(self):
|
||||
self.sysinfo_schema({'rssi': self.plug.rssi}) # wrapping for vol
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user