Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inclusion state changed controller event #1114

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/model/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)
Expand Down
7 changes: 5 additions & 2 deletions zwave_js_server/model/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
InclusionStrategy.DEFAULT,
InclusionStrategy.SECURITY_S0,
InclusionStrategy.SECURITY_S2,
Expand Down Expand Up @@ -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]
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
InclusionStrategy.DEFAULT,
InclusionStrategy.SECURITY_S0,
InclusionStrategy.SECURITY_S2,
Expand Down Expand Up @@ -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."""

Expand Down
19 changes: 18 additions & 1 deletion zwave_js_server/model/controller/event_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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,
Expand Down
Loading