|
37 | 37 | from .extensions import ConfigurationOption |
38 | 38 | from .extensions import ExtendedProperties |
39 | 39 |
|
40 | | -__version__ = "0.4.5" |
41 | | - |
| 40 | +__version__ = "0.4.6" |
42 | 41 |
|
43 | 42 | log = logging.getLogger(__name__) |
44 | 43 |
|
@@ -390,7 +389,7 @@ async def async_send_command( |
390 | 389 | and (msg_body.get("forceBypass") is True) |
391 | 390 | ): |
392 | 391 | # 422 sometimes occurs when forceBypass is True but there's nothing to bypass. |
393 | | - log.warning( |
| 392 | + log.debug( |
394 | 393 | "Error executing %s, trying again without force bypass...", |
395 | 394 | event.value, |
396 | 395 | ) |
@@ -872,7 +871,10 @@ async def _async_get_trouble_conditions(self) -> None: |
872 | 871 |
|
873 | 872 | # Takes EITHER url (without base) or device_type. |
874 | 873 | async def _async_get_items_and_subordinates( |
875 | | - self, device_type: DeviceType | None = None, url: str | None = None |
| 874 | + self, |
| 875 | + device_type: DeviceType | None = None, |
| 876 | + url: str | None = None, |
| 877 | + retry_on_failure: bool = True, |
876 | 878 | ) -> list: |
877 | 879 | """Get attributes, metadata, and child devices for an ADC device class.""" |
878 | 880 |
|
@@ -936,13 +938,27 @@ async def _async_get_items_and_subordinates( |
936 | 938 | # All requests for those device types will return 403. |
937 | 939 | # |
938 | 940 | # On some providers, 403 may mean that the user has been logged out. |
939 | | - # For now, we'll ignore this case. |
| 941 | + # Try logging in again, then give up by pretending that we couldn't find any devices of this type. |
940 | 942 |
|
941 | | - log.debug( |
942 | | - "Got 403 status when fetching data for device type %s.", device_type |
943 | | - ) |
| 943 | + log.error("Error fetching data from Alarm.com.") |
| 944 | + |
| 945 | + if not retry_on_failure: |
| 946 | + log.debug( |
| 947 | + "Got 403 status when fetching data for device type %s. Logging" |
| 948 | + " in again didn't help.", |
| 949 | + device_type, |
| 950 | + ) |
| 951 | + |
| 952 | + return list([]) |
| 953 | + |
| 954 | + log.error("Trying to refresh auth tokens by logging in again.") |
944 | 955 |
|
945 | | - return list([]) |
| 956 | + await self.async_login() |
| 957 | + |
| 958 | + return await self._async_get_items_and_subordinates( |
| 959 | + device_type=device_type, |
| 960 | + retry_on_failure=False, |
| 961 | + ) |
946 | 962 |
|
947 | 963 | if ( |
948 | 964 | rsp_errors[0].get("status") == "409" |
|
0 commit comments