mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-12-22 02:35:32 +00:00
Fix command parameter issue hon#63
This commit is contained in:
parent
7b51caecca
commit
11988c73a6
|
@ -302,8 +302,6 @@ class HonAppliance:
|
|||
"statistics": self.statistics,
|
||||
"additional_data": self._additional_data,
|
||||
}
|
||||
if self._extra and data.get("attributes"):
|
||||
data = self._extra.data(data)
|
||||
if command_only:
|
||||
data.pop("attributes")
|
||||
data.pop("appliance")
|
||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
|||
from typing import Optional, Dict, Any, List, TYPE_CHECKING, Union
|
||||
|
||||
from pyhon import exceptions
|
||||
from pyhon.exceptions import ApiError
|
||||
from pyhon.parameter.base import HonParameter
|
||||
from pyhon.parameter.enum import HonParameterEnum
|
||||
from pyhon.parameter.fixed import HonParameterFixed
|
||||
|
@ -111,9 +112,12 @@ class HonCommand:
|
|||
params = self.parameter_groups.get("parameters", {})
|
||||
ancillary_params = self.parameter_groups.get("ancillaryParameters", {})
|
||||
self.appliance.sync_to_params(self.name)
|
||||
return await self.api.send_command(
|
||||
result = await self.api.send_command(
|
||||
self._appliance, self._name, params, ancillary_params
|
||||
)
|
||||
if not result:
|
||||
raise ApiError("Can't send command")
|
||||
return result
|
||||
|
||||
@property
|
||||
def categories(self) -> Dict[str, "HonCommand"]:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from pprint import pformat
|
||||
from typing import Dict, Optional
|
||||
|
||||
from aiohttp import ClientSession
|
||||
|
@ -188,6 +189,7 @@ class HonAPI:
|
|||
if json_data.get("payload", {}).get("resultCode") == "0":
|
||||
return True
|
||||
_LOGGER.error(await response.text())
|
||||
_LOGGER.error("%s - Payload:\n%s", url, pformat(data))
|
||||
return False
|
||||
|
||||
async def appliance_configuration(self) -> Dict:
|
||||
|
|
|
@ -12,3 +12,7 @@ class NoSessionException(Exception):
|
|||
|
||||
class NoAuthenticationException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ApiError(Exception):
|
||||
pass
|
||||
|
|
|
@ -28,8 +28,8 @@ class HonParameter:
|
|||
self.check_trigger(value)
|
||||
|
||||
@property
|
||||
def intern_value(self) -> str | float:
|
||||
return str(self._value) if self._value is not None else ""
|
||||
def intern_value(self) -> str:
|
||||
return str(self.value)
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
|
|
|
@ -27,6 +27,10 @@ class HonParameterEnum(HonParameter):
|
|||
def values(self, values) -> None:
|
||||
self._values = values
|
||||
|
||||
@property
|
||||
def intern_value(self) -> str:
|
||||
return str(self._value) if self._value is not None else str(self.values[0])
|
||||
|
||||
@property
|
||||
def value(self) -> str | float:
|
||||
return clean_value(self._value) if self._value is not None else self.values[0]
|
||||
|
|
Loading…
Reference in a new issue