From 92420f007b09860675c6c7a886b42e8061b6b0c9 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Mon, 11 Nov 2024 14:08:27 +0100 Subject: [PATCH 1/3] Update test --- test/model/test_controller.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/model/test_controller.py b/test/model/test_controller.py index 514581ec8..7b970b842 100644 --- a/test/model/test_controller.py +++ b/test/model/test_controller.py @@ -2254,6 +2254,11 @@ async def test_additional_events(controller: Controller) -> None: {"source": "controller", "event": "inclusion started", "strategy": 0}, ) controller.receive_event(event) + event = Event( + "inclusion state changed", + {"source": "controller", "event": "inclusion state changed", "state": 1}, + ) + controller.receive_event(event) event = Event( "inclusion stopped", {"source": "controller", "event": "inclusion stopped"} ) From fc5a42014760c19eb76df5442d7732ed016d2013 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Mon, 11 Nov 2024 13:54:43 +0100 Subject: [PATCH 2/3] Add inclusion state changed controller event --- zwave_js_server/model/controller/__init__.py | 7 +++++-- .../model/controller/event_model.py | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/zwave_js_server/model/controller/__init__.py b/zwave_js_server/model/controller/__init__.py index 55ae96f42..88abd842c 100644 --- a/zwave_js_server/model/controller/__init__.py +++ b/zwave_js_server/model/controller/__init__.py @@ -263,7 +263,7 @@ def update(self, data: ControllerDataType) -> None: async def async_begin_inclusion( self, - inclusion_strategy: Literal[ + inclusion_strategy: Literal[ # type: ignore[valid-type] InclusionStrategy.DEFAULT, InclusionStrategy.SECURITY_S0, InclusionStrategy.SECURITY_S2, @@ -438,7 +438,7 @@ async def async_remove_failed_node(self, node: Node) -> None: async def async_replace_failed_node( self, node: Node, - inclusion_strategy: Literal[ + inclusion_strategy: Literal[ # type: ignore[valid-type] InclusionStrategy.DEFAULT, InclusionStrategy.SECURITY_S0, InclusionStrategy.SECURITY_S2, @@ -901,6 +901,9 @@ def handle_exclusion_failed(self, event: Event) -> None: def handle_inclusion_started(self, event: Event) -> None: """Process an inclusion started event.""" + def handle_inclusion_state_changed(self, event: Event) -> None: + """Process an inclusion state changed event.""" + def handle_exclusion_started(self, event: Event) -> None: """Process an exclusion started event.""" diff --git a/zwave_js_server/model/controller/event_model.py b/zwave_js_server/model/controller/event_model.py index 65e3aea58..e347d5db2 100644 --- a/zwave_js_server/model/controller/event_model.py +++ b/zwave_js_server/model/controller/event_model.py @@ -4,7 +4,7 @@ from typing import Literal, TypedDict -from ...const import InclusionStrategy, RemoveNodeReason +from ...const import InclusionState, InclusionStrategy, RemoveNodeReason from ...event import BaseEventModel from ..node.data_model import FoundNodeDataType, NodeDataType from .firmware import ( @@ -154,6 +154,22 @@ def from_dict(cls, data: dict) -> InclusionStartedEventModel: ) +class InclusionStateChangedEventModel(BaseControllerEventModel): + """Model for `inclusion state changed` event data.""" + + event: Literal["inclusion state changed"] + state: InclusionState + + @classmethod + def from_dict(cls, data: dict) -> InclusionStateChangedEventModel: + """Initialize from dict.""" + return cls( + source=data["source"], + event=data["event"], + state=data["state"], + ) + + class InclusionStoppedEventModel(BaseControllerEventModel): """Model for `inclusion stopped` event data.""" @@ -336,6 +352,7 @@ def from_dict(cls, data: dict) -> StatusChangedEventModel: "inclusion aborted": InclusionAbortedEventModel, "inclusion failed": InclusionFailedEventModel, "inclusion started": InclusionStartedEventModel, + "inclusion state changed": InclusionStateChangedEventModel, "inclusion stopped": InclusionStoppedEventModel, "node added": NodeAddedEventModel, "node found": NodeFoundEventModel, From 1668322ba5931b9b2dbc2fd16a03ddf443d7362a Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Mon, 11 Nov 2024 14:23:31 +0100 Subject: [PATCH 3/3] Revert type ignore --- zwave_js_server/model/controller/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zwave_js_server/model/controller/__init__.py b/zwave_js_server/model/controller/__init__.py index 88abd842c..e4c01af8c 100644 --- a/zwave_js_server/model/controller/__init__.py +++ b/zwave_js_server/model/controller/__init__.py @@ -263,7 +263,7 @@ def update(self, data: ControllerDataType) -> None: async def async_begin_inclusion( self, - inclusion_strategy: Literal[ # type: ignore[valid-type] + inclusion_strategy: Literal[ InclusionStrategy.DEFAULT, InclusionStrategy.SECURITY_S0, InclusionStrategy.SECURITY_S2, @@ -438,7 +438,7 @@ async def async_remove_failed_node(self, node: Node) -> None: async def async_replace_failed_node( self, node: Node, - inclusion_strategy: Literal[ # type: ignore[valid-type] + inclusion_strategy: Literal[ InclusionStrategy.DEFAULT, InclusionStrategy.SECURITY_S0, InclusionStrategy.SECURITY_S2,