mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-12-02 18:17:17 +01:00
Fix connection issues
This commit is contained in:
parent
00ac6912e2
commit
79a121263f
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,4 +3,4 @@ venv/
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
dist/
|
dist/
|
||||||
**/*.egg-info/
|
**/*.egg-info/
|
||||||
test.py
|
test*
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
[![PyPI - Status](https://img.shields.io/pypi/status/pyhOn)](https://pypi.org/project/pyhOn)
|
[![PyPI - Status](https://img.shields.io/pypi/status/pyhOn)](https://pypi.org/project/pyhOn)
|
||||||
[![PyPI](https://img.shields.io/pypi/v/pyhOn?color=blue)](https://pypi.org/project/pyhOn)
|
[![PyPI](https://img.shields.io/pypi/v/pyhOn?color=blue)](https://pypi.org/project/pyhOn)
|
||||||
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyhOn)](https://www.python.org/)
|
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyhOn)](https://www.python.org/)
|
||||||
[![PyPI - License](https://img.shields.io/pypi/l/pyhOn)](https://github.com/Andre0512/pyhOn/blob/main/LICENCE)
|
[![PyPI - License](https://img.shields.io/pypi/l/pyhOn)](https://github.com/Andre0512/pyhOn/blob/main/LICENSE)
|
||||||
[![PyPI - Downloads](https://img.shields.io/pypi/dm/pyhOn)](https://pypistats.org/packages/pyhOn)
|
[![PyPI - Downloads](https://img.shields.io/pypi/dm/pyhOn)](https://pypistats.org/packages/pyhon)
|
||||||
Control your Haier appliances with python!
|
Control your Haier appliances with python!
|
||||||
The idea behind this library is, to make the use of all available commands as simple as possible.
|
The idea behind this library is, to make the use of all available commands as simple as possible.
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class HonConnection:
|
|||||||
return {}
|
return {}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def load_attributes(self, device: HonDevice):
|
async def load_attributes(self, device: HonDevice, loop=False):
|
||||||
params = {
|
params = {
|
||||||
"macAddress": device.mac_address,
|
"macAddress": device.mac_address,
|
||||||
"applianceType": device.appliance_type_name,
|
"applianceType": device.appliance_type_name,
|
||||||
@ -92,6 +92,10 @@ class HonConnection:
|
|||||||
}
|
}
|
||||||
url = f"{const.API_URL}/commands/v1/context"
|
url = f"{const.API_URL}/commands/v1/context"
|
||||||
async with self._session.get(url, params=params, headers=await self._headers) as response:
|
async with self._session.get(url, params=params, headers=await self._headers) as response:
|
||||||
|
if response.status_code >= 400 and not loop:
|
||||||
|
_LOGGER.error("%s - Error %s - %s", url, response.status_code, await response.text)
|
||||||
|
await self.setup()
|
||||||
|
return await self.load_attributes(device, loop=True)
|
||||||
return (await response.json()).get("payload", {})
|
return (await response.json()).get("payload", {})
|
||||||
|
|
||||||
async def load_statistics(self, device: HonDevice):
|
async def load_statistics(self, device: HonDevice):
|
||||||
|
@ -3,5 +3,6 @@ class Appliance:
|
|||||||
self._data = data
|
self._data = data
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
self._data["connected"] = self._data["lastConnEvent.category"] == "CONNECTED"
|
if self._data["lastConnEvent.category"] == "DISCONNECTED":
|
||||||
|
self._data["machMode"] = "0"
|
||||||
return self._data
|
return self._data
|
||||||
|
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.2.4",
|
version="0.2.5",
|
||||||
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 New Issue
Block a user