Skip to content

Commit

Permalink
Fix connection issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Mar 6, 2023
1 parent 00ac691 commit 79a1212
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ venv/
__pycache__/
dist/
**/*.egg-info/
test.py
test*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 5 additions & 1 deletion pyhon/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ async def load_commands(self, device: HonDevice):
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,
"category": "CYCLE"
}
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):
Expand Down
3 changes: 2 additions & 1 deletion pyhon/appliances/wm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ def __init__(self, data):
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 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="pyhOn",
version="0.2.4",
version="0.2.5",
author="Andre Basche",
description="Control hOn devices with python",
long_description=long_description,
Expand Down

0 comments on commit 79a1212

Please sign in to comment.