Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions pyalarmdotcomajax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
from .extensions import ConfigurationOption
from .extensions import ExtendedProperties

__version__ = "0.4.5"

__version__ = "0.4.6"

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -390,7 +389,7 @@ async def async_send_command(
and (msg_body.get("forceBypass") is True)
):
# 422 sometimes occurs when forceBypass is True but there's nothing to bypass.
log.warning(
log.debug(
"Error executing %s, trying again without force bypass...",
event.value,
)
Expand Down Expand Up @@ -872,7 +871,10 @@ async def _async_get_trouble_conditions(self) -> None:

# Takes EITHER url (without base) or device_type.
async def _async_get_items_and_subordinates(
self, device_type: DeviceType | None = None, url: str | None = None
self,
device_type: DeviceType | None = None,
url: str | None = None,
retry_on_failure: bool = True,
) -> list:
"""Get attributes, metadata, and child devices for an ADC device class."""

Expand Down Expand Up @@ -936,13 +938,27 @@ async def _async_get_items_and_subordinates(
# All requests for those device types will return 403.
#
# On some providers, 403 may mean that the user has been logged out.
# For now, we'll ignore this case.
# Try logging in again, then give up by pretending that we couldn't find any devices of this type.

log.debug(
"Got 403 status when fetching data for device type %s.", device_type
)
log.error("Error fetching data from Alarm.com.")

if not retry_on_failure:
log.debug(
"Got 403 status when fetching data for device type %s. Logging"
" in again didn't help.",
device_type,
)

return list([])

log.error("Trying to refresh auth tokens by logging in again.")

return list([])
await self.async_login()

return await self._async_get_items_and_subordinates(
device_type=device_type,
retry_on_failure=False,
)

if (
rsp_errors[0].get("status") == "409"
Expand Down