Skip to content

Commit b4fc851

Browse files
Add inclusion state changed controller event (#1114)
1 parent f79f4f1 commit b4fc851

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

test/model/test_controller.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,11 @@ async def test_additional_events(controller: Controller) -> None:
22542254
{"source": "controller", "event": "inclusion started", "strategy": 0},
22552255
)
22562256
controller.receive_event(event)
2257+
event = Event(
2258+
"inclusion state changed",
2259+
{"source": "controller", "event": "inclusion state changed", "state": 1},
2260+
)
2261+
controller.receive_event(event)
22572262
event = Event(
22582263
"inclusion stopped", {"source": "controller", "event": "inclusion stopped"}
22592264
)

zwave_js_server/model/controller/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,9 @@ def handle_exclusion_failed(self, event: Event) -> None:
901901
def handle_inclusion_started(self, event: Event) -> None:
902902
"""Process an inclusion started event."""
903903

904+
def handle_inclusion_state_changed(self, event: Event) -> None:
905+
"""Process an inclusion state changed event."""
906+
904907
def handle_exclusion_started(self, event: Event) -> None:
905908
"""Process an exclusion started event."""
906909

zwave_js_server/model/controller/event_model.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Literal, TypedDict
66

7-
from ...const import InclusionStrategy, RemoveNodeReason
7+
from ...const import InclusionState, InclusionStrategy, RemoveNodeReason
88
from ...event import BaseEventModel
99
from ..node.data_model import FoundNodeDataType, NodeDataType
1010
from .firmware import (
@@ -154,6 +154,22 @@ def from_dict(cls, data: dict) -> InclusionStartedEventModel:
154154
)
155155

156156

157+
class InclusionStateChangedEventModel(BaseControllerEventModel):
158+
"""Model for `inclusion state changed` event data."""
159+
160+
event: Literal["inclusion state changed"]
161+
state: InclusionState
162+
163+
@classmethod
164+
def from_dict(cls, data: dict) -> InclusionStateChangedEventModel:
165+
"""Initialize from dict."""
166+
return cls(
167+
source=data["source"],
168+
event=data["event"],
169+
state=data["state"],
170+
)
171+
172+
157173
class InclusionStoppedEventModel(BaseControllerEventModel):
158174
"""Model for `inclusion stopped` event data."""
159175

@@ -336,6 +352,7 @@ def from_dict(cls, data: dict) -> StatusChangedEventModel:
336352
"inclusion aborted": InclusionAbortedEventModel,
337353
"inclusion failed": InclusionFailedEventModel,
338354
"inclusion started": InclusionStartedEventModel,
355+
"inclusion state changed": InclusionStateChangedEventModel,
339356
"inclusion stopped": InclusionStoppedEventModel,
340357
"node added": NodeAddedEventModel,
341358
"node found": NodeFoundEventModel,

0 commit comments

Comments
 (0)