Fix connection issues
This commit is contained in:
parent
00ac6912e2
commit
79a121263f
5 changed files with 11 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,4 +3,4 @@ venv/
|
|||
__pycache__/
|
||||
dist/
|
||||
**/*.egg-info/
|
||||
test.py
|
||||
test*
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
[![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 - 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 - Downloads](https://img.shields.io/pypi/dm/pyhOn)](https://pypistats.org/packages/pyhOn)
|
||||
[![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)
|
||||
Control your Haier appliances with python!
|
||||
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 result
|
||||
|
||||
async def load_attributes(self, device: HonDevice):
|
||||
async def load_attributes(self, device: HonDevice, loop=False):
|
||||
params = {
|
||||
"macAddress": device.mac_address,
|
||||
"applianceType": device.appliance_type_name,
|
||||
|
@ -92,6 +92,10 @@ class HonConnection:
|
|||
}
|
||||
url = f"{const.API_URL}/commands/v1/context"
|
||||
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", {})
|
||||
|
||||
async def load_statistics(self, device: HonDevice):
|
||||
|
|
|
@ -3,5 +3,6 @@ class Appliance:
|
|||
self._data = data
|
||||
|
||||
def get(self):
|
||||
self._data["connected"] = self._data["lastConnEvent.category"] == "CONNECTED"
|
||||
if self._data["lastConnEvent.category"] == "DISCONNECTED":
|
||||
self._data["machMode"] = "0"
|
||||
return self._data
|
||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
|||
|
||||
setup(
|
||||
name="pyhOn",
|
||||
version="0.2.4",
|
||||
version="0.2.5",
|
||||
author="Andre Basche",
|
||||
description="Control hOn devices with python",
|
||||
long_description=long_description,
|
||||
|
|
Loading…
Reference in a new issue