File: association.py

package info (click to toggle)
zwave-js-server-python 0.67.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,820 kB
  • sloc: python: 15,886; sh: 21; javascript: 16; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Provide a model for the association."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from .controller import Controller
    from .node import Node


@dataclass
class AssociationGroup:
    """Represent a association group dict type."""

    max_nodes: int
    is_lifeline: bool
    multi_channel: bool
    label: str
    profile: int | None = None
    issued_commands: dict[int, list[int]] = field(default_factory=dict)


@dataclass
class AssociationAddress:
    """Represent a association dict type."""

    controller: Controller
    node_id: int
    endpoint: int | None = None

    @property
    def node(self) -> Node | None:
        """Return the node."""
        if self.node_id in self.controller.nodes:
            return self.controller.nodes[self.node_id]
        return None