Fix connection issues
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -3,4 +3,4 @@ venv/
 | 
			
		||||
__pycache__/
 | 
			
		||||
dist/
 | 
			
		||||
**/*.egg-info/
 | 
			
		||||
test.py
 | 
			
		||||
test*
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@
 | 
			
		||||
[](https://pypi.org/project/pyhOn)
 | 
			
		||||
[](https://pypi.org/project/pyhOn)
 | 
			
		||||
[](https://www.python.org/)
 | 
			
		||||
[](https://github.com/Andre0512/pyhOn/blob/main/LICENCE)
 | 
			
		||||
[](https://pypistats.org/packages/pyhOn)  
 | 
			
		||||
[](https://github.com/Andre0512/pyhOn/blob/main/LICENSE)
 | 
			
		||||
[](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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user