mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-01-19 02:50:44 +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,
|
"statistics": self.statistics,
|
||||||
"additional_data": self._additional_data,
|
"additional_data": self._additional_data,
|
||||||
}
|
}
|
||||||
if self._extra and data.get("attributes"):
|
|
||||||
data = self._extra.data(data)
|
|
||||||
if command_only:
|
if command_only:
|
||||||
data.pop("attributes")
|
data.pop("attributes")
|
||||||
data.pop("appliance")
|
data.pop("appliance")
|
||||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
||||||
from typing import Optional, Dict, Any, List, TYPE_CHECKING, Union
|
from typing import Optional, Dict, Any, List, TYPE_CHECKING, Union
|
||||||
|
|
||||||
from pyhon import exceptions
|
from pyhon import exceptions
|
||||||
|
from pyhon.exceptions import ApiError
|
||||||
from pyhon.parameter.base import HonParameter
|
from pyhon.parameter.base import HonParameter
|
||||||
from pyhon.parameter.enum import HonParameterEnum
|
from pyhon.parameter.enum import HonParameterEnum
|
||||||
from pyhon.parameter.fixed import HonParameterFixed
|
from pyhon.parameter.fixed import HonParameterFixed
|
||||||
|
@ -111,9 +112,12 @@ class HonCommand:
|
||||||
params = self.parameter_groups.get("parameters", {})
|
params = self.parameter_groups.get("parameters", {})
|
||||||
ancillary_params = self.parameter_groups.get("ancillaryParameters", {})
|
ancillary_params = self.parameter_groups.get("ancillaryParameters", {})
|
||||||
self.appliance.sync_to_params(self.name)
|
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
|
self._appliance, self._name, params, ancillary_params
|
||||||
)
|
)
|
||||||
|
if not result:
|
||||||
|
raise ApiError("Can't send command")
|
||||||
|
return result
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def categories(self) -> Dict[str, "HonCommand"]:
|
def categories(self) -> Dict[str, "HonCommand"]:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from pprint import pformat
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
|
@ -188,6 +189,7 @@ class HonAPI:
|
||||||
if json_data.get("payload", {}).get("resultCode") == "0":
|
if json_data.get("payload", {}).get("resultCode") == "0":
|
||||||
return True
|
return True
|
||||||
_LOGGER.error(await response.text())
|
_LOGGER.error(await response.text())
|
||||||
|
_LOGGER.error("%s - Payload:\n%s", url, pformat(data))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def appliance_configuration(self) -> Dict:
|
async def appliance_configuration(self) -> Dict:
|
||||||
|
|
|
@ -12,3 +12,7 @@ class NoSessionException(Exception):
|
||||||
|
|
||||||
class NoAuthenticationException(Exception):
|
class NoAuthenticationException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ApiError(Exception):
|
||||||
|
pass
|
||||||
|
|
|
@ -28,8 +28,8 @@ class HonParameter:
|
||||||
self.check_trigger(value)
|
self.check_trigger(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def intern_value(self) -> str | float:
|
def intern_value(self) -> str:
|
||||||
return str(self._value) if self._value is not None else ""
|
return str(self.value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def values(self) -> List[str]:
|
def values(self) -> List[str]:
|
||||||
|
|
|
@ -27,6 +27,10 @@ class HonParameterEnum(HonParameter):
|
||||||
def values(self, values) -> None:
|
def values(self, values) -> None:
|
||||||
self._values = values
|
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
|
@property
|
||||||
def value(self) -> str | float:
|
def value(self) -> str | float:
|
||||||
return clean_value(self._value) if self._value is not None else self.values[0]
|
return clean_value(self._value) if self._value is not None else self.values[0]
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.12.2",
|
version="0.12.3",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
|
Loading…
Reference in a new issue