From d26e33a055c6cc7fca6ccd2b91270d243f1a0e66 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sat, 15 Apr 2023 00:29:24 +0200 Subject: [PATCH] Fix error in starting programs --- pyhon/connection/api.py | 7 ++++--- pyhon/connection/device.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pyhon/connection/api.py b/pyhon/connection/api.py index 7704a22..a9fab02 100644 --- a/pyhon/connection/api.py +++ b/pyhon/connection/api.py @@ -139,7 +139,7 @@ class HonAPI: "commandName": command, "transactionId": f"{appliance.mac_address}_{now[:-3]}Z", "applianceOptions": appliance.commands_options, - "appliance": self._hon.device.get(), + "device": self._hon.device.get(mobile=True), "attributes": { "channel": "mobileApp", "origin": "standardProgram", @@ -150,10 +150,11 @@ class HonAPI: "applianceType": appliance.appliance_type, } url: str = f"{const.API_URL}/commands/v1/send" - async with self._hon.post(url, json=data) as resp: - json_data: Dict = await resp.json() + async with self._hon.post(url, json=data) as response: + json_data: Dict = await response.json() if json_data.get("payload", {}).get("resultCode") == "0": return True + _LOGGER.error(await response.text()) return False async def appliance_configuration(self) -> Dict: diff --git a/pyhon/connection/device.py b/pyhon/connection/device.py index 39e529c..ea7f30e 100644 --- a/pyhon/connection/device.py +++ b/pyhon/connection/device.py @@ -32,11 +32,12 @@ class HonDevice: def mobile_id(self) -> str: return self._mobile_id - def get(self) -> Dict: - return { + def get(self, mobile: bool = False) -> Dict: + result = { "appVersion": self.app_version, "mobileId": self.mobile_id, - "osVersion": self.os_version, "os": self.os, + "osVersion": self.os_version, "deviceModel": self.device_model, } + return (result | {"mobileOs": result.pop("os")}) if mobile else result