Send empty dictionary instead of null for iot queries (#1145)

This commit is contained in:
Steven B. 2024-10-01 12:47:36 +01:00 committed by GitHub
parent db80c383a9
commit 81e2685605
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 7 deletions

View File

@ -285,7 +285,7 @@ async def get_legacy_fixture(device):
try:
click.echo(f"Testing {test_call}..", nl=False)
info = await device.protocol.query(
{test_call.module: {test_call.method: None}}
{test_call.module: {test_call.method: {}}}
)
resp = info[test_call.module]
except Exception as ex:
@ -302,7 +302,7 @@ async def get_legacy_fixture(device):
final_query = defaultdict(defaultdict)
final = defaultdict(defaultdict)
for succ, resp in successes:
final_query[succ.module][succ.method] = None
final_query[succ.module][succ.method] = {}
final[succ.module][succ.method] = resp
final = default_to_regular(final)

View File

@ -32,8 +32,8 @@ from .xortransport import XorTransport
_LOGGER = logging.getLogger(__name__)
GET_SYSINFO_QUERY = {
"system": {"get_sysinfo": None},
GET_SYSINFO_QUERY: dict[str, dict[str, dict]] = {
"system": {"get_sysinfo": {}},
}

View File

@ -296,8 +296,8 @@ class Discover:
DISCOVERY_PORT = 9999
DISCOVERY_QUERY = {
"system": {"get_sysinfo": None},
DISCOVERY_QUERY: dict[str, dict[str, dict]] = {
"system": {"get_sysinfo": {}},
}
DISCOVERY_PORT_2 = 20002

View File

@ -207,6 +207,8 @@ class IotDevice(Device):
def _create_request(
self, target: str, cmd: str, arg: dict | None = None, child_ids=None
):
if arg is None:
arg = {}
request: dict[str, Any] = {target: {cmd: arg}}
if child_ids is not None:
request = {"context": {"child_ids": child_ids}, target: {cmd: arg}}

View File

@ -88,7 +88,6 @@ class KlapTransport(BaseTransport):
"""
DEFAULT_PORT: int = 80
DISCOVERY_QUERY = {"system": {"get_sysinfo": None}}
SESSION_COOKIE_NAME = "TP_SESSIONID"
TIMEOUT_COOKIE_NAME = "TIMEOUT"