|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import asyncio |
4 | | -from datetime import datetime, timedelta |
5 | 4 | import json |
6 | 5 | import random |
7 | 6 | import string |
8 | 7 | import sys |
| 8 | +from datetime import datetime, timedelta |
9 | 9 | from typing import Any, Callable, Union, cast |
10 | 10 | from urllib import parse |
11 | 11 |
|
| 12 | +import backoff |
12 | 13 | from aiohttp import ClientSession |
13 | 14 | from aiohttp.client_exceptions import ClientResponseError |
14 | | -import backoff |
15 | 15 | from homeassistant.helpers import config_entry_oauth2_flow |
16 | 16 |
|
17 | 17 | from pyhilo.const import ( |
@@ -129,10 +129,8 @@ def headers(self) -> dict[str, Any]: |
129 | 129 | } |
130 | 130 | return { |
131 | 131 | **headers, |
132 | | - **{ |
133 | | - "Content-Type": "application/json; charset=utf-8", |
134 | | - "Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY, |
135 | | - }, |
| 132 | + "Content-Type": "application/json; charset=utf-8", |
| 133 | + "Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY, |
136 | 134 | } |
137 | 135 |
|
138 | 136 | async def async_get_access_token(self) -> str: |
@@ -516,7 +514,7 @@ async def _set_device_attribute( |
516 | 514 | self, |
517 | 515 | device: HiloDevice, |
518 | 516 | key: DeviceAttribute, |
519 | | - value: Union[str, float, int, None], |
| 517 | + value: Union[str, float, None], |
520 | 518 | ) -> None: |
521 | 519 | url = self._get_url(f"Devices/{device.id}/Attributes", device.location_id) |
522 | 520 | LOG.debug(f"Device Attribute URL is {url}") |
@@ -545,7 +543,8 @@ async def get_event_notifications(self, location_id: int) -> dict[str, Any]: |
545 | 543 | "homePageNotificationBody": "Test manuel de l’alarme détecté.", |
546 | 544 | "notificationDataJSON": "{\"NotificationType\":null,\"Title\":\"\",\"SubTitle\":null,\"Body\":\"Test manuel de l’alarme détecté.\",\"Badge\":0,\"Sound\":null,\"Data\":null,\"Tags\":null,\"Type\":\"TestDetected\",\"DeviceId\":324236,\"LocationId\":4051}", |
547 | 545 | "viewed": false |
548 | | - }""" |
| 546 | + } |
| 547 | + """ |
549 | 548 | url = self._get_url(None, location_id, events=True) |
550 | 549 | LOG.debug(f"Event Notifications URL is {url}") |
551 | 550 | return cast(dict[str, Any], await self.async_request("get", url)) |
@@ -613,7 +612,6 @@ async def get_gd_events( |
613 | 612 | } |
614 | 613 | } |
615 | 614 | """ |
616 | | - |
617 | 615 | url = self._get_url("Events", location_id, True) |
618 | 616 | if not event_id: |
619 | 617 | url += "?active=true" |
|
0 commit comments