Skip to content

Commit

Permalink
Merge branch 'master' of github.com:uvjustin/pyalarmdotcomajax
Browse files Browse the repository at this point in the history
  • Loading branch information
elahd authored Apr 11, 2022
2 parents 9d962ff + d1efd3d commit 1dc6084
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
# https://pypi.org/project/python-typing-update/ was causing trouble. Some of the below items seek to re-implement the typing-update flow.

default_language_version:
python: python3.9
repos:
- repo: https://github.com/sqlalchemyorg/zimports/
rev: v0.4.5
Expand All @@ -19,7 +17,7 @@ repos:
- id: autoflake
files: ^((pyalarmdotcomajax)/.+)?[^/]+\.py$
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.3.0
hooks:
- id: black
args:
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
v0.2.5, 2022-04-08 Added read_only attribute to controllable devices.
v0.2.4, 2022-04-07 Add freeze sensors.
Fixed night arming.
Started adding Alarm.com API reference data for future enhancements.
Expand Down
5 changes: 5 additions & 0 deletions pyalarmdotcomajax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,11 @@ async def _async_login_and_get_key(self, attempts: int = 1) -> None:
) as resp:

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

# If Alarm.com is warning us that we'll have to set up two factor authentication soon, alert caller.
Expand Down
3 changes: 3 additions & 0 deletions pyalarmdotcomajax/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ def _print_element_tearsheet(
Battery: {battery}"""
)

if element.read_only:
print(f" Read Only: {element.read_only}")

if isinstance(element, ADCLight) and element.brightness:
print(f" Brightness: {element.brightness}%")

Expand Down
22 changes: 22 additions & 0 deletions pyalarmdotcomajax/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ def __init__(
"Initialized %s (%s) %s", self.device_type, self._family_raw, self.name
)

@property
def read_only(self) -> bool | None:
"""Return whether logged in user has permission to peek in."""
return (
not result
if isinstance(
(result := self._attribs_raw.get("hasPermissionToChangeState")),
bool,
)
else None
)

class DeviceState(Enum):
"""Placeholder for child device states."""

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

@property
def read_only(self) -> None:
"""Non-actionable object."""
return


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

@property
def read_only(self) -> None:
"""Non-actionable object."""
return


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

0 comments on commit 1dc6084

Please sign in to comment.