From 867d7be1c9f79ecec4bbfc6325fb1abb2b2b40d6 Mon Sep 17 00:00:00 2001 From: Christopher Tremblay Date: Sat, 11 May 2024 10:09:43 -0700 Subject: [PATCH] Add support for the 2022 entity model in HA (#14) * Add an async function to know when the library is done with its initialization. The new HA needs this information at creation time to properly represent an enrity. PS: Requires Python >= 3.12 * Update the python versions to 3.12 in the various resource tiles. * Delete .vs directory --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .github/workflows/pulls.yaml | 2 +- .github/workflows/pypi-upload.yaml | 2 +- adext/adext.py | 13 +++++++++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2235d69..197cf4d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,7 +4,7 @@ #------------------------------------------------------------------------------------------------------------- # Update the VARIANT arg in devcontainer.json to pick a Python version: 3, 3.8, 3.7, 3.6 -ARG VARIANT=3 +ARG VARIANT=3.12 FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} # [Optional] If your requirements rarely change, uncomment this section to add them to the image. diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 21142b0..ae98475 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ "dockerfile": "Dockerfile", "context": "..", "args": { - "VARIANT": "3.8" + "VARIANT": "3.12" } }, "settings": { diff --git a/.github/workflows/pulls.yaml b/.github/workflows/pulls.yaml index 6845648..273e702 100644 --- a/.github/workflows/pulls.yaml +++ b/.github/workflows/pulls.yaml @@ -5,7 +5,7 @@ on: pull_request jobs: pytest: runs-on: ubuntu-latest - container: python:3.8 + container: python:3.12 steps: - name: Checkout repo uses: actions/checkout@v2 diff --git a/.github/workflows/pypi-upload.yaml b/.github/workflows/pypi-upload.yaml index 33ec613..ae7a1a9 100644 --- a/.github/workflows/pypi-upload.yaml +++ b/.github/workflows/pypi-upload.yaml @@ -7,7 +7,7 @@ on: jobs: build-and-publish: runs-on: ubuntu-20.04 - container: python:3.8 + container: python:3.12 steps: - uses: actions/checkout@v2 with: diff --git a/adext/adext.py b/adext/adext.py index a209083..7c3b272 100644 --- a/adext/adext.py +++ b/adext/adext.py @@ -2,6 +2,8 @@ Extends the AlarmDecoder class to include helper methods for HomeAssistant """ +import asyncio + from alarmdecoder.decoder import AlarmDecoder from alarmdecoder.panels import DSC, ADEMCO as HONEYWELL @@ -15,6 +17,17 @@ class AdExt(AlarmDecoder): Extended AlarmDecoder class """ + def __init__(self, device, ignore_message_states=False, ignore_lrr_states=True): + super().__init__(device, ignore_message_states, ignore_lrr_states) + self._event = asyncio.Event() + + def _handle_version(self, data): + super()._handle_version(data) + self._event.set() + + async def is_init(self): + return (await self._event.wait()) + def _get_arm_sequence( self, arm_mode, code, code_arm_required, auto_bypass, alt_night_mode=False, ):