Skip to content

Commit

Permalink
Merge pull request #28 from kingy444/master
Browse files Browse the repository at this point in the history
v2.0.4
  • Loading branch information
kingy444 authored Nov 13, 2022
2 parents 9960c80 + 121b5d6 commit 8dceb35
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ Changelog

- Add Type 26, 27 & 28 - Skyline Panels
- Force capability 1 for Type 44 - Twist
- Align class name standard
- Align class name standard

**v2.0.4**

- Add Type 10 - SkyLift
- Handle calls to update shade position during maintenance
- Raise error directly on hub calls instead of logger
2 changes: 1 addition & 1 deletion aiopvapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Aio PowerView api version."""

__version__ = "2.0.3"
__version__ = "2.0.4"
20 changes: 12 additions & 8 deletions aiopvapi/helpers/aiorequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ async def get(self, url: str, params: str = None) -> dict:
response = await self.websession.get(url, params=params)
return await check_response(response, [200, 204])
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
_LOGGER.error("Failed to communicate with PowerView hub: %s", error)
raise PvApiConnectionError
raise PvApiConnectionError(
f"Failed to communicate with PowerView hub: {error}"
)
finally:
if response is not None:
await response.release()
Expand All @@ -81,8 +82,9 @@ async def post(self, url: str, data: dict = None):
response = await self.websession.post(url, json=data)
return await check_response(response, [200, 201])
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
_LOGGER.error("Failed to communicate with PowerView hub: %s", error)
raise PvApiConnectionError
raise PvApiConnectionError(
f"Failed to communicate with PowerView hub: {error}"
)
finally:
if response is not None:
await response.release()
Expand All @@ -103,8 +105,9 @@ async def put(self, url: str, data: dict = None):
response = await self.websession.put(url, json=data)
return await check_response(response, [200, 204])
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
_LOGGER.error("Failed to communicate with PowerView hub: %s", error)
raise PvApiConnectionError
raise PvApiConnectionError(
f"Failed to communicate with PowerView hub: {error}"
)
finally:
if response is not None:
await response.release()
Expand All @@ -125,8 +128,9 @@ async def delete(self, url: str, params: dict = None):
response = await self.websession.delete(url, params=params)
return await check_response(response, [200, 204])
except (asyncio.TimeoutError, aiohttp.ClientError) as error:
_LOGGER.error("Failed to communicate with PowerView hub: %s", error)
raise PvApiConnectionError
raise PvApiConnectionError(
f"Failed to communicate with PowerView hub: {error}"
)
finally:
if response is not None:
await response.release()
13 changes: 9 additions & 4 deletions aiopvapi/resources/shade.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,18 @@ async def refresh(self):
"""Query the hub and the actual shade to get the most recent shade
data. Including current shade position."""
raw_data = await self.request.get(self._resource_path, {"refresh": "true"})

self._raw_data = raw_data[ATTR_SHADE]
if isinstance(raw_data, bool):
_LOGGER.debug("No data available, hub undergoing maintenance. Please try again")
return
self._raw_data = raw_data.get(ATTR_SHADE)

async def refresh_battery(self):
"""Query the hub and request the most recent battery state."""
raw_data = await self.request.get(self._resource_path, {"updateBatteryLevel": "true"})

self._raw_data = raw_data[ATTR_SHADE]
if isinstance(raw_data, bool):
_LOGGER.debug("No data available, hub undergoing maintenance. Please try again")
return
self._raw_data = raw_data.get(ATTR_SHADE)

async def set_power_source(self, type):
"""Update the hub with the type of power source."""
Expand Down Expand Up @@ -272,6 +276,7 @@ class ShadeBottomUp(BaseShade):
shade_type(4, "Roman"),
shade_type(5, "Bottom Up"),
shade_type(6, "Duette"),
shade_type(10, "Duette and Applause SkyLift"),
shade_type(31, "Vignette"),
shade_type(42, "M25T Roller Blind"),
shade_type(49, "AC Roller"),
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Have a look at the examples folder for some guidance how to use it.
- Force capability 1 for Type 44 - Twist
- Align class name standard

### v2.0.4

- Add Type 10 - SkyLift
- Handle calls to update shade position during maintenance
- Raise error directly on hub calls instead of logger

## Links

---
Expand Down

0 comments on commit 8dceb35

Please sign in to comment.