mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-05 04:52:08 +00:00
Merge branch 'main' of https://github.com/VadymMelnychuk/pyhOn
# Conflicts: # pyhon/appliances/wh.py
This commit is contained in:
commit
73fe98032b
2
.github/workflows/python-check.yml
vendored
2
.github/workflows/python-check.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.10", "3.11"]
|
python-version: ["3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
|
@ -94,15 +94,15 @@ class HonAppliance:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def appliance_model_id(self) -> str:
|
def appliance_model_id(self) -> str:
|
||||||
return self._info.get("applianceModelId", "")
|
return str(self._info.get("applianceModelId", ""))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def appliance_type(self) -> str:
|
def appliance_type(self) -> str:
|
||||||
return self._info.get("applianceTypeName", "")
|
return str(self._info.get("applianceTypeName", ""))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mac_address(self) -> str:
|
def mac_address(self) -> str:
|
||||||
return self.info.get("macAddress", "")
|
return str(self.info.get("macAddress", ""))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
@ -138,11 +138,11 @@ class HonAppliance:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def model_id(self) -> int:
|
def model_id(self) -> int:
|
||||||
return self._info.get("applianceModelId", 0)
|
return int(self._info.get("applianceModelId", 0))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def options(self) -> Dict[str, Any]:
|
def options(self) -> Dict[str, Any]:
|
||||||
return self._appliance_model.get("options", {})
|
return dict(self._appliance_model.get("options", {}))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def commands(self) -> Dict[str, HonCommand]:
|
def commands(self) -> Dict[str, HonCommand]:
|
||||||
|
|
|
@ -7,10 +7,10 @@ class Appliance(ApplianceBase):
|
||||||
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
data = super().attributes(data)
|
data = super().attributes(data)
|
||||||
if data.get("lastConnEvent", {}).get("category", "") == "DISCONNECTED":
|
if data.get("lastConnEvent", {}).get("category", "") == "DISCONNECTED":
|
||||||
data["parameters"]["temp"].value = "0"
|
data["parameters"]["temp"].value = 0
|
||||||
data["parameters"]["onOffStatus"].value = "0"
|
data["parameters"]["onOffStatus"].value = 0
|
||||||
data["parameters"]["remoteCtrValid"].value = "0"
|
data["parameters"]["remoteCtrValid"].value = 0
|
||||||
data["parameters"]["remainingTimeMM"].value = "0"
|
data["parameters"]["remainingTimeMM"].value = 0
|
||||||
|
|
||||||
data["active"] = data["parameters"]["onOffStatus"] == "1"
|
data["active"] = data["parameters"]["onOffStatus"].value == 1
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -7,7 +7,7 @@ from pyhon.parameter.base import HonParameter
|
||||||
class Appliance(ApplianceBase):
|
class Appliance(ApplianceBase):
|
||||||
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
def attributes(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
data = super().attributes(data)
|
data = super().attributes(data)
|
||||||
parameter = data["parameters"]["onOffStatus"]
|
parameter = data.get("parameters", {}).get("onOffStatus")
|
||||||
is_class = isinstance(parameter, HonParameter)
|
is_class = isinstance(parameter, HonParameter)
|
||||||
data["active"] = parameter.value == 1 if is_class else parameter == 1
|
data["active"] = parameter.value == 1 if is_class else parameter == 1
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -144,7 +144,11 @@ class HonCommand:
|
||||||
self.appliance.sync_command_to_params(self.name)
|
self.appliance.sync_command_to_params(self.name)
|
||||||
try:
|
try:
|
||||||
result = 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,
|
||||||
|
self._category_name,
|
||||||
)
|
)
|
||||||
if not result:
|
if not result:
|
||||||
_LOGGER.error(result)
|
_LOGGER.error(result)
|
||||||
|
|
|
@ -190,6 +190,7 @@ class HonAPI:
|
||||||
command: str,
|
command: str,
|
||||||
parameters: Dict[str, Any],
|
parameters: Dict[str, Any],
|
||||||
ancillary_parameters: Dict[str, Any],
|
ancillary_parameters: Dict[str, Any],
|
||||||
|
program_name: str = "",
|
||||||
) -> bool:
|
) -> bool:
|
||||||
now: str = datetime.utcnow().isoformat()
|
now: str = datetime.utcnow().isoformat()
|
||||||
data: Dict[str, Any] = {
|
data: Dict[str, Any] = {
|
||||||
|
@ -208,6 +209,8 @@ class HonAPI:
|
||||||
"parameters": parameters,
|
"parameters": parameters,
|
||||||
"applianceType": appliance.appliance_type,
|
"applianceType": appliance.appliance_type,
|
||||||
}
|
}
|
||||||
|
if command == "startProgram" and program_name:
|
||||||
|
data.update({"programName": program_name.upper()})
|
||||||
url: str = f"{const.API_URL}/commands/v1/send"
|
url: str = f"{const.API_URL}/commands/v1/send"
|
||||||
async with self._hon.post(url, json=data) as response:
|
async with self._hon.post(url, json=data) as response:
|
||||||
json_data: Dict[str, Any] = await response.json()
|
json_data: Dict[str, Any] = await response.json()
|
||||||
|
@ -319,6 +322,12 @@ class TestAPI(HonAPI):
|
||||||
command: str,
|
command: str,
|
||||||
parameters: Dict[str, Any],
|
parameters: Dict[str, Any],
|
||||||
ancillary_parameters: Dict[str, Any],
|
ancillary_parameters: Dict[str, Any],
|
||||||
|
program_name: str = "",
|
||||||
) -> bool:
|
) -> bool:
|
||||||
_LOGGER.info("%s - %s", str(parameters), str(ancillary_parameters))
|
_LOGGER.info(
|
||||||
|
"%s - %s - %s",
|
||||||
|
str(parameters),
|
||||||
|
str(ancillary_parameters),
|
||||||
|
str(program_name),
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -6,7 +6,7 @@ CLIENT_ID = (
|
||||||
"3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9."
|
"3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9."
|
||||||
"HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6"
|
"HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6"
|
||||||
)
|
)
|
||||||
APP_VERSION = "2.3.5"
|
APP_VERSION = "2.4.7"
|
||||||
OS_VERSION = 31
|
OS_VERSION = 31
|
||||||
OS = "android"
|
OS = "android"
|
||||||
DEVICE_MODEL = "exynos9820"
|
DEVICE_MODEL = "exynos9820"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
aiohttp~=3.8
|
aiohttp>=3.8
|
||||||
yarl~=1.9
|
yarl>=1.8
|
||||||
typing-extensions~=4.7
|
typing-extensions>=4.8
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
black==23.7.0
|
black>=22.12
|
||||||
flake8==6.0.0
|
flake8>=6.0
|
||||||
mypy==1.4.1
|
mypy>=0.991
|
||||||
pylint==2.17.4
|
pylint>=2.15
|
||||||
|
setuptools>=62.3
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -7,7 +7,7 @@ with open("README.md", "r", encoding="utf-8") as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.15.9",
|
version="0.15.14",
|
||||||
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,
|
||||||
|
@ -21,7 +21,7 @@ setup(
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
python_requires=">=3.10",
|
python_requires=">=3.10",
|
||||||
install_requires=["aiohttp~=3.8", "typing-extensions~=4.7", "yarl~=1.9"],
|
install_requires=["aiohttp>=3.8", "typing-extensions>=4.8", "yarl>=1.8"],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 4 - Beta",
|
"Development Status :: 4 - Beta",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
|
@ -30,6 +30,7 @@ setup(
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
Loading…
Reference in a new issue