Skip to content

Commit 1dc6084

Browse files
authored
Merge branch 'master' of github.com:uvjustin/pyalarmdotcomajax
2 parents 9d962ff + d1efd3d commit 1dc6084

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
# https://pypi.org/project/python-typing-update/ was causing trouble. Some of the below items seek to re-implement the typing-update flow.
33

4-
default_language_version:
5-
python: python3.9
64
repos:
75
- repo: https://github.com/sqlalchemyorg/zimports/
86
rev: v0.4.5
@@ -19,7 +17,7 @@ repos:
1917
- id: autoflake
2018
files: ^((pyalarmdotcomajax)/.+)?[^/]+\.py$
2119
- repo: https://github.com/psf/black
22-
rev: 21.12b0
20+
rev: 22.3.0
2321
hooks:
2422
- id: black
2523
args:

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
v0.2.5, 2022-04-08 Added read_only attribute to controllable devices.
12
v0.2.4, 2022-04-07 Add freeze sensors.
23
Fixed night arming.
34
Started adding Alarm.com API reference data for future enhancements.

pyalarmdotcomajax/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,11 @@ async def _async_login_and_get_key(self, attempts: int = 1) -> None:
935935
) as resp:
936936

937937
if re.search("m=login_fail", str(resp.url)) is not None:
938+
log.error("Login failed.")
939+
log.debug("\nResponse URL:\n%s\n", str(resp.url))
940+
log.debug(
941+
"\nRequest Headers:\n%s\n", str(resp.request_info.headers)
942+
)
938943
raise AuthenticationFailed("Invalid username and password.")
939944

940945
# If Alarm.com is warning us that we'll have to set up two factor authentication soon, alert caller.

pyalarmdotcomajax/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ def _print_element_tearsheet(
306306
Battery: {battery}"""
307307
)
308308

309+
if element.read_only:
310+
print(f" Read Only: {element.read_only}")
311+
309312
if isinstance(element, ADCLight) and element.brightness:
310313
print(f" Brightness: {element.brightness}%")
311314

pyalarmdotcomajax/entities.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ def __init__(
9090
"Initialized %s (%s) %s", self.device_type, self._family_raw, self.name
9191
)
9292

93+
@property
94+
def read_only(self) -> bool | None:
95+
"""Return whether logged in user has permission to peek in."""
96+
return (
97+
not result
98+
if isinstance(
99+
(result := self._attribs_raw.get("hasPermissionToChangeState")),
100+
bool,
101+
)
102+
else None
103+
)
104+
93105
class DeviceState(Enum):
94106
"""Placeholder for child device states."""
95107

@@ -193,6 +205,11 @@ def malfunction(self) -> bool | None:
193205
"""Return whether device is malfunctioning."""
194206
return None
195207

208+
@property
209+
def read_only(self) -> None:
210+
"""Non-actionable object."""
211+
return
212+
196213

197214
class ADCPartition(DesiredStateMixin, ADCBaseElement):
198215
"""Represent Alarm.com partition element."""
@@ -435,6 +452,11 @@ def device_subtype(self) -> ADCSensorSubtype | None:
435452
except ValueError:
436453
return None
437454

455+
@property
456+
def read_only(self) -> None:
457+
"""Non-actionable object."""
458+
return
459+
438460

439461
class ADCGarageDoor(DesiredStateMixin, ADCBaseElement):
440462
"""Represent Alarm.com garage door element."""

0 commit comments

Comments
 (0)