Update dump_devinfo to include 20002 discovery results (#556)

* Fix dump_devinfo and add discovery_result to json

* Update following review.  Do not serialize aliases.

* Delete kasa/tests/fixtures/HS100(UK)_1.0_1.2.6.json
This commit is contained in:
sdb9696
2023-11-29 19:01:20 +00:00
committed by GitHub
parent 9728866afb
commit 9de3f69033
5 changed files with 74 additions and 41 deletions

View File

@@ -423,7 +423,7 @@ class DiscoveryResult(BaseModel):
mac: str
mgt_encrypt_schm: EncryptionScheme
device_id: Optional[str] = Field(default=None, alias="device_type_hash")
device_id: Optional[str] = Field(default=None, alias="device_id_hash")
owner: Optional[str] = Field(default=None, alias="device_owner_hash")
hw_ver: Optional[str] = None
is_support_iot_cloud: Optional[bool] = None

View File

@@ -211,6 +211,7 @@ class SmartDevice:
# checks in accessors. the @updated_required decorator does not ensure
# mypy that these are not accessed incorrectly.
self._last_update: Any = None
self._discovery_info: Optional[Dict[str, Any]] = None
self._sys_info: Any = None # TODO: this is here to avoid changing tests
self._features: Set[str] = set()
@@ -371,6 +372,7 @@ class SmartDevice:
# This allows setting of some info properties directly
# from partial discovery info that will then be found
# by the requires_update decorator
self._discovery_info = info
self._set_sys_info(info)
def _set_sys_info(self, sys_info: Dict[str, Any]) -> None:

View File

@@ -1,43 +1,46 @@
{
"emeter": {
"err_code": -1,
"err_msg": "module not support"
},
"smartlife.iot.common.emeter": {
"err_code": -1,
"err_msg": "module not support"
},
"smartlife.iot.dimmer": {
"err_code": -1,
"err_msg": "module not support"
},
"smartlife.iot.smartbulb.lightingservice": {
"err_code": -1,
"err_msg": "module not support"
"discovery_result": {
"device_id": "00000000000000000000000000000000",
"device_model": "HS100(UK)",
"device_type": "IOT.SMARTPLUGSWITCH",
"factory_default": true,
"hw_ver": "4.1",
"ip": "127.0.0.123",
"mac": "00-00-00-00-00-00",
"mgt_encrypt_schm": {
"encrypt_type": "KLAP",
"http_port": 80,
"is_support_https": false
},
"owner": "00000000000000000000000000000000"
},
"system": {
"get_sysinfo": {
"active_mode": "schedule",
"alias": "Unused 3",
"active_mode": "none",
"alias": "Bedroom Lamp 2",
"dev_name": "Smart Wi-Fi Plug",
"deviceId": "0000000000000000000000000000000000000000",
"err_code": 0,
"feature": "TIM",
"fwId": "00000000000000000000000000000000",
"hwId": "00000000000000000000000000000000",
"hw_ver": "4.1",
"icon_hash": "",
"latitude": 0,
"latitude_i": 0,
"led_off": 0,
"longitude": 0,
"longitude_i": 0,
"mac": "00:00:00:00:00:00",
"mic_type": "IOT.SMARTPLUGSWITCH",
"model": "HS100(UK)",
"next_action": {
"type": -1
},
"ntc_state": 0,
"oemId": "00000000000000000000000000000000",
"on_time": 0,
"relay_state": 0,
"rssi": -63,
"rssi": -66,
"status": "new",
"sw_ver": "1.1.0 Build 201016 Rel.175121",
"type": "IOT.SMARTPLUGSWITCH",
"updating": 0
}
}

View File

@@ -294,9 +294,10 @@ class FakeTransportProtocol(TPLinkSmartHomeProtocol):
for target in info:
# print("target %s" % target)
for cmd in info[target]:
# print("initializing tgt %s cmd %s" % (target, cmd))
proto[target][cmd] = info[target][cmd]
if target != "discovery_result":
for cmd in info[target]:
# print("initializing tgt %s cmd %s" % (target, cmd))
proto[target][cmd] = info[target][cmd]
# if we have emeter support, we need to add the missing pieces
for module in ["emeter", "smartlife.iot.common.emeter"]:
if (