Skip to content

Commit

Permalink
Merge pull request #222 from austinmroczek/master
Browse files Browse the repository at this point in the history
Handle ArmingState code 10215
  • Loading branch information
austinmroczek authored Apr 28, 2024
2 parents 52a7887 + 48ea1d6 commit d685030
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
16 changes: 9 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name="total_connect_client"
version="2023.12.1"
version="2024.4"
authors = [
{ name="Craig J. Midwinter", email="[email protected]" },
]
Expand All @@ -19,7 +19,7 @@ classifiers = [
"Operating System :: OS Independent",
]
keywords=["alarm", "TotalConnect"]
dependencies=["zeep>=4.1.0"]
dependencies=["zeep>=4.2.1"]

[project.urls]
"Homepage" = "https://github.com/craigjmidwinter/total-connect-client"
Expand All @@ -37,24 +37,26 @@ disable = ["use-symbolic-message-instead", "too-few-public-methods", "too-many-i
legacy_tox_ini = """
[tox]
requires =
tox>=4
virtualenv>=20.26
env_list =
build
lint
py311
py310
py39
py{39,310,311,312}
#skip_missing_interpreters = True
[testenv]
setenv =
LANG=en_US.UTF-8
PYTHONPATH = {toxinidir}
commands =
pytest --timeout=30 --cov=total_connect_client --cov-report term-missing -p no:sugar {posargs}
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements_test.txt
commands =
pytest tests --timeout=30 --cov=total_connect_client --cov-report term-missing -p no:sugar {posargs}
[testenv:lint]
deps =
Expand Down
3 changes: 2 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
wheel>=0.29.0
build>=0.9.0
tox>=2.8.1
tox>=4.15.0
flake8>=3.4.1
flake8-docstrings>=1.1.0
pylint>=1.8.2
Expand All @@ -12,3 +12,4 @@ pytest-timeout>=1.0.0
restructuredtext-lint>=1.0.1
pygments>=2.2.0
requests_mock>=1.3.0
virtualenv>=20.26
20 changes: 20 additions & 0 deletions tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import pytest
from const import (
LOCATION_INFO_BASIC_NORMAL,
METADATA_DISARMED,
METADATA_DISARMED_LOW_BATTERY,
RESPONSE_DISARMED,
RESPONSE_GET_ZONE_DETAILS_SUCCESS,
)

from total_connect_client.const import ArmingState
from total_connect_client.exceptions import PartialResponseError, TotalConnectError
from total_connect_client.location import DEFAULT_USERCODE, TotalConnectLocation

Expand Down Expand Up @@ -173,3 +175,21 @@ def tests_set_usercode(self):
assert loc.set_usercode("1234") is True
assert loc.usercode == "1234"
assert mock_client.validate_usercode.call_count == 2


def tests_update_status():
"""Test location._update_status()."""
location = TotalConnectLocation(LOCATION_INFO_BASIC_NORMAL, Mock())

# known arming state should not produce an error
response = {
"PanelMetadataAndStatus": METADATA_DISARMED,
"ArmingState": ArmingState.DISARMED,
}
location._update_status(response)
assert location.arming_state == ArmingState.DISARMED

# unknown arming state should produce an error
with pytest.raises(TotalConnectError):
response["ArmingState"] = 99999
location._update_status(response)
6 changes: 5 additions & 1 deletion total_connect_client/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ArmingState(Enum):
ALARMING = 10207
ALARMING_FIRE_SMOKE = 10212
ALARMING_CARBON_MONOXIDE = 10213
ALARMING_CARBON_MONOXIDE_PROA7 = 10215

ARMING = 10307
DISARMING = 10308
Expand Down Expand Up @@ -125,7 +126,10 @@ def is_triggered_fire(self):

def is_triggered_gas(self):
"""Return True if the system is triggered for carbon monoxide."""
return self == ArmingState.ALARMING_CARBON_MONOXIDE
return self in (
ArmingState.ALARMING_CARBON_MONOXIDE,
ArmingState.ALARMING_CARBON_MONOXIDE_PROA7,
)

def is_triggered(self):
"""Return True if the system is triggered in any way."""
Expand Down

0 comments on commit d685030

Please sign in to comment.