mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add new methods to dump_devinfo (#1373)
Adds `getMatterSetupInfo`, `getConnectStatus` and `scanApList`
This commit is contained in:
parent
e206d9b4df
commit
d03a387a74
@ -60,4 +60,7 @@ SMARTCAM_REQUESTS: list[dict] = [
|
|||||||
{"get": {"motor": {"name": ["capability"]}}},
|
{"get": {"motor": {"name": ["capability"]}}},
|
||||||
{"get": {"audio_capability": {"name": ["device_speaker", "device_microphone"]}}},
|
{"get": {"audio_capability": {"name": ["device_speaker", "device_microphone"]}}},
|
||||||
{"get": {"audio_config": {"name": ["speaker", "microphone"]}}},
|
{"get": {"audio_config": {"name": ["speaker", "microphone"]}}},
|
||||||
|
{"getMatterSetupInfo": {"matter": {}}},
|
||||||
|
{"getConnectStatus": {"onboarding": {"get_connect_status": {}}}},
|
||||||
|
{"scanApList": {"onboarding": {"scan": {}}}},
|
||||||
]
|
]
|
||||||
|
@ -50,6 +50,8 @@ REDACTORS: dict[str, Callable[[Any], Any] | None] = {
|
|||||||
"bssid": lambda _: "000000000000",
|
"bssid": lambda _: "000000000000",
|
||||||
"channel": lambda _: 0,
|
"channel": lambda _: 0,
|
||||||
"oem_id": lambda x: "REDACTED_" + x[9::],
|
"oem_id": lambda x: "REDACTED_" + x[9::],
|
||||||
|
"hw_id": lambda x: "REDACTED_" + x[9::],
|
||||||
|
"fw_id": lambda x: "REDACTED_" + x[9::],
|
||||||
"setup_code": lambda x: re.sub(r"\w", "0", x), # matter
|
"setup_code": lambda x: re.sub(r"\w", "0", x), # matter
|
||||||
"setup_payload": lambda x: re.sub(r"\w", "0", x), # matter
|
"setup_payload": lambda x: re.sub(r"\w", "0", x), # matter
|
||||||
"mfi_setup_code": lambda x: re.sub(r"\w", "0", x), # mfi_ for homekit
|
"mfi_setup_code": lambda x: re.sub(r"\w", "0", x), # mfi_ for homekit
|
||||||
@ -183,18 +185,18 @@ class SmartProtocol(BaseProtocol):
|
|||||||
multi_result: dict[str, Any] = {}
|
multi_result: dict[str, Any] = {}
|
||||||
smart_method = "multipleRequest"
|
smart_method = "multipleRequest"
|
||||||
|
|
||||||
|
end = len(requests)
|
||||||
|
# The SmartCamProtocol sends requests with a length 1 as a
|
||||||
|
# multipleRequest. The SmartProtocol doesn't so will never
|
||||||
|
# raise_on_error
|
||||||
|
raise_on_error = end == 1
|
||||||
|
|
||||||
multi_requests = [
|
multi_requests = [
|
||||||
{"method": method, "params": params} if params else {"method": method}
|
{"method": method, "params": params} if params else {"method": method}
|
||||||
for method, params in requests.items()
|
for method, params in requests.items()
|
||||||
if method not in FORCE_SINGLE_REQUEST
|
if method not in FORCE_SINGLE_REQUEST
|
||||||
]
|
]
|
||||||
|
|
||||||
end = len(multi_requests)
|
|
||||||
# The SmartCamProtocol sends requests with a length 1 as a
|
|
||||||
# multipleRequest. The SmartProtocol doesn't so will never
|
|
||||||
# raise_on_error
|
|
||||||
raise_on_error = end == 1
|
|
||||||
|
|
||||||
# Break the requests down as there can be a size limit
|
# Break the requests down as there can be a size limit
|
||||||
step = self._multi_request_batch_size
|
step = self._multi_request_batch_size
|
||||||
if step == 1:
|
if step == 1:
|
||||||
@ -285,7 +287,9 @@ class SmartProtocol(BaseProtocol):
|
|||||||
resp = await self._transport.send(
|
resp = await self._transport.send(
|
||||||
self.get_smart_request(method, params)
|
self.get_smart_request(method, params)
|
||||||
)
|
)
|
||||||
self._handle_response_error_code(resp, method, raise_on_error=False)
|
self._handle_response_error_code(
|
||||||
|
resp, method, raise_on_error=raise_on_error
|
||||||
|
)
|
||||||
multi_result[method] = resp.get("result")
|
multi_result[method] = resp.get("result")
|
||||||
return multi_result
|
return multi_result
|
||||||
|
|
||||||
|
@ -221,9 +221,9 @@ class FakeSmartCamTransport(BaseTransport):
|
|||||||
return {**result, "error_code": 0}
|
return {**result, "error_code": 0}
|
||||||
else:
|
else:
|
||||||
return {"error_code": -1}
|
return {"error_code": -1}
|
||||||
elif method[:3] == "get":
|
|
||||||
params = request_dict.get("params")
|
|
||||||
if method in info:
|
if method in info:
|
||||||
|
params = request_dict.get("params")
|
||||||
result = copy.deepcopy(info[method])
|
result = copy.deepcopy(info[method])
|
||||||
if "start_index" in result and "sum" in result:
|
if "start_index" in result and "sum" in result:
|
||||||
list_key = next(
|
list_key = next(
|
||||||
@ -239,6 +239,10 @@ class FakeSmartCamTransport(BaseTransport):
|
|||||||
start_index : start_index + self.list_return_size
|
start_index : start_index + self.list_return_size
|
||||||
]
|
]
|
||||||
return {"result": result, "error_code": 0}
|
return {"result": result, "error_code": 0}
|
||||||
|
|
||||||
|
if self.verbatim:
|
||||||
|
return {"error_code": -1}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
# FIXTURE_MISSING is for service calls not in place when
|
# FIXTURE_MISSING is for service calls not in place when
|
||||||
# SMART fixtures started to be generated
|
# SMART fixtures started to be generated
|
||||||
@ -250,7 +254,6 @@ class FakeSmartCamTransport(BaseTransport):
|
|||||||
return {"result": result, "error_code": 0}
|
return {"result": result, "error_code": 0}
|
||||||
|
|
||||||
return {"error_code": -1}
|
return {"error_code": -1}
|
||||||
return {"error_code": -1}
|
|
||||||
|
|
||||||
async def close(self) -> None:
|
async def close(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
56
tests/fixtures/smartcam/C210(EU)_2.0_1.4.3.json
vendored
56
tests/fixtures/smartcam/C210(EU)_2.0_1.4.3.json
vendored
@ -7,8 +7,8 @@
|
|||||||
"connect_type": "wireless",
|
"connect_type": "wireless",
|
||||||
"device_id": "0000000000000000000000000000000000000000",
|
"device_id": "0000000000000000000000000000000000000000",
|
||||||
"http_port": 443,
|
"http_port": 443,
|
||||||
"last_alarm_time": "0",
|
"last_alarm_time": "1733422805",
|
||||||
"last_alarm_type": "",
|
"last_alarm_type": "motion",
|
||||||
"owner": "00000000000000000000000000000000",
|
"owner": "00000000000000000000000000000000",
|
||||||
"sd_status": "offline"
|
"sd_status": "offline"
|
||||||
},
|
},
|
||||||
@ -32,7 +32,8 @@
|
|||||||
"mac": "40-AE-30-00-00-00",
|
"mac": "40-AE-30-00-00-00",
|
||||||
"mgt_encrypt_schm": {
|
"mgt_encrypt_schm": {
|
||||||
"is_support_https": true
|
"is_support_https": true
|
||||||
}
|
},
|
||||||
|
"protocol_version": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"getAlertConfig": {
|
"getAlertConfig": {
|
||||||
@ -266,15 +267,22 @@
|
|||||||
"getClockStatus": {
|
"getClockStatus": {
|
||||||
"system": {
|
"system": {
|
||||||
"clock_status": {
|
"clock_status": {
|
||||||
"local_time": "2024-11-01 13:58:50",
|
"local_time": "2024-12-15 11:28:40",
|
||||||
"seconds_from_1970": 1730469530
|
"seconds_from_1970": 1734262120
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"getConnectStatus": {
|
||||||
|
"onboarding": {
|
||||||
|
"get_connect_status": {
|
||||||
|
"status": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"getConnectionType": {
|
"getConnectionType": {
|
||||||
"link_type": "wifi",
|
"link_type": "wifi",
|
||||||
"rssi": "3",
|
"rssi": "3",
|
||||||
"rssiValue": -57,
|
"rssiValue": -61,
|
||||||
"ssid": "I01BU0tFRF9TU0lEIw=="
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
},
|
},
|
||||||
"getDetectionConfig": {
|
"getDetectionConfig": {
|
||||||
@ -321,7 +329,7 @@
|
|||||||
"getFirmwareAutoUpgradeConfig": {
|
"getFirmwareAutoUpgradeConfig": {
|
||||||
"auto_upgrade": {
|
"auto_upgrade": {
|
||||||
"common": {
|
"common": {
|
||||||
"enabled": "on",
|
"enabled": "off",
|
||||||
"random_range": "120",
|
"random_range": "120",
|
||||||
"time": "03:00"
|
"time": "03:00"
|
||||||
}
|
}
|
||||||
@ -338,8 +346,8 @@
|
|||||||
"getLastAlarmInfo": {
|
"getLastAlarmInfo": {
|
||||||
"system": {
|
"system": {
|
||||||
"last_alarm_info": {
|
"last_alarm_info": {
|
||||||
"last_alarm_time": "0",
|
"last_alarm_time": "1733422805",
|
||||||
"last_alarm_type": ""
|
"last_alarm_type": "motion"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -961,5 +969,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scanApList": {
|
||||||
|
"onboarding": {
|
||||||
|
"scan": {
|
||||||
|
"ap_list": [
|
||||||
|
{
|
||||||
|
"auth": 4,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 3,
|
||||||
|
"rssi": 2,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 4,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 3,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 4,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 3,
|
||||||
|
"rssi": 0,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"wpa3_supported": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
119
tests/fixtures/smartcam/H200(EU)_1.0_1.3.2.json
vendored
119
tests/fixtures/smartcam/H200(EU)_1.0_1.3.2.json
vendored
@ -26,6 +26,7 @@
|
|||||||
"firmware_version": "1.3.2 Build 20240424 rel.75425",
|
"firmware_version": "1.3.2 Build 20240424 rel.75425",
|
||||||
"hardware_version": "1.0",
|
"hardware_version": "1.0",
|
||||||
"ip": "127.0.0.123",
|
"ip": "127.0.0.123",
|
||||||
|
"isResetWiFi": false,
|
||||||
"is_support_iot_cloud": true,
|
"is_support_iot_cloud": true,
|
||||||
"mac": "A8-6E-84-00-00-00",
|
"mac": "A8-6E-84-00-00-00",
|
||||||
"mgt_encrypt_schm": {
|
"mgt_encrypt_schm": {
|
||||||
@ -214,8 +215,8 @@
|
|||||||
"fw_ver": "1.11.0 Build 230821 Rel.113553",
|
"fw_ver": "1.11.0 Build 230821 Rel.113553",
|
||||||
"hw_id": "00000000000000000000000000000000",
|
"hw_id": "00000000000000000000000000000000",
|
||||||
"hw_ver": "1.0",
|
"hw_ver": "1.0",
|
||||||
"jamming_rssi": -108,
|
"jamming_rssi": -119,
|
||||||
"jamming_signal_level": 2,
|
"jamming_signal_level": 1,
|
||||||
"lastOnboardingTimestamp": 1714016798,
|
"lastOnboardingTimestamp": 1714016798,
|
||||||
"mac": "202351000000",
|
"mac": "202351000000",
|
||||||
"model": "S200B",
|
"model": "S200B",
|
||||||
@ -224,7 +225,7 @@
|
|||||||
"parent_device_id": "0000000000000000000000000000000000000000",
|
"parent_device_id": "0000000000000000000000000000000000000000",
|
||||||
"region": "Europe/London",
|
"region": "Europe/London",
|
||||||
"report_interval": 16,
|
"report_interval": 16,
|
||||||
"rssi": -66,
|
"rssi": -60,
|
||||||
"signal_level": 3,
|
"signal_level": 3,
|
||||||
"specs": "EU",
|
"specs": "EU",
|
||||||
"status": "online",
|
"status": "online",
|
||||||
@ -245,8 +246,17 @@
|
|||||||
"getClockStatus": {
|
"getClockStatus": {
|
||||||
"system": {
|
"system": {
|
||||||
"clock_status": {
|
"clock_status": {
|
||||||
"local_time": "2024-11-01 13:56:27",
|
"local_time": "1984-10-21 23:48:23",
|
||||||
"seconds_from_1970": 1730469387
|
"seconds_from_1970": 467246903
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"getConnectStatus": {
|
||||||
|
"onboarding": {
|
||||||
|
"get_connect_status": {
|
||||||
|
"current_ssid": "",
|
||||||
|
"err_code": 0,
|
||||||
|
"status": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -329,6 +339,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"getMatterSetupInfo": {
|
||||||
|
"setup_code": "00000000000",
|
||||||
|
"setup_payload": "00:000000-000000000000"
|
||||||
|
},
|
||||||
"getMediaEncrypt": {
|
"getMediaEncrypt": {
|
||||||
"cet": {
|
"cet": {
|
||||||
"media_encrypt": {
|
"media_encrypt": {
|
||||||
@ -353,7 +367,7 @@
|
|||||||
"getSirenConfig": {
|
"getSirenConfig": {
|
||||||
"duration": 300,
|
"duration": 300,
|
||||||
"siren_type": "Doorbell Ring 1",
|
"siren_type": "Doorbell Ring 1",
|
||||||
"volume": "6"
|
"volume": "1"
|
||||||
},
|
},
|
||||||
"getSirenStatus": {
|
"getSirenStatus": {
|
||||||
"status": "off",
|
"status": "off",
|
||||||
@ -389,5 +403,98 @@
|
|||||||
"zone_id": "Europe/London"
|
"zone_id": "Europe/London"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"scanApList": {
|
||||||
|
"onboarding": {
|
||||||
|
"scan": {
|
||||||
|
"ap_list": [
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 2,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 0,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 0,
|
||||||
|
"rssi": 2,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 3,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 3,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 4,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 3,
|
||||||
|
"rssi": 2,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"auth": 3,
|
||||||
|
"bssid": "000000000000",
|
||||||
|
"encryption": 2,
|
||||||
|
"rssi": 1,
|
||||||
|
"ssid": "I01BU0tFRF9TU0lEIw=="
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"wpa3_supported": "false"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user