Skip to content

Commit

Permalink
Add wake.up and go.dormant messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamillar committed Nov 11, 2024
1 parent caaffb1 commit b97ca2d
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gwproto/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"""

from gwproto.enums.actor_class import ActorClass
from gwproto.enums.admin_event import AdminEvent
from gwproto.enums.admin_state import AdminState
from gwproto.enums.alert_priority import AlertPriority
from gwproto.enums.aquastat_control import AquastatControl
from gwproto.enums.change_aquastat_control import ChangeAquastatControl
Expand Down Expand Up @@ -65,6 +67,8 @@

__all__ = [
"ActorClass", # [sh.actor.class.002](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#shactorclass)
"AdminEvent", # [admin.event.000](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminevent)
"AdminState", # [admin.state.000](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminstate)
"AlertPriority", # [alert.priority.000](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#alertpriority)
"AquastatControl", # [aquastat.control.state.000](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#aquastatcontrolstate)
"ChangeAquastatControl", # [change.aquastat.control.000](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#changeaquastatcontrol)
Expand Down
36 changes: 36 additions & 0 deletions src/gwproto/enums/admin_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from enum import auto
from typing import List

from gw.enums import GwStrEnum


class AdminEvent(GwStrEnum):
"""
Values:
- WakeUp
- GoDormant
For more information:
- [ASLs](https://gridworks-type-registry.readthedocs.io/en/latest/)
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminevent)
"""

WakeUp = auto()
GoDormant = auto()

@classmethod
def default(cls) -> "AdminEvent":
return cls.WakeUp

@classmethod
def values(cls) -> List[str]:
return [elt.value for elt in cls]

@classmethod
def enum_name(cls) -> str:
return "admin.event"

@classmethod
def enum_version(cls) -> str:
return "000"
36 changes: 36 additions & 0 deletions src/gwproto/enums/admin_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from enum import auto
from typing import List

from gw.enums import GwStrEnum


class AdminState(GwStrEnum):
"""
Values:
- Awake
- Dormant
For more information:
- [ASLs](https://gridworks-type-registry.readthedocs.io/en/latest/)
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#adminstate)
"""

Awake = auto()
Dormant = auto()

@classmethod
def default(cls) -> "AdminState":
return cls.Dormant

@classmethod
def values(cls) -> List[str]:
return [elt.value for elt in cls]

@classmethod
def enum_name(cls) -> str:
return "admin.state"

@classmethod
def enum_version(cls) -> str:
return "000"
4 changes: 4 additions & 0 deletions src/gwproto/enums/pico_cycler_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class PicoCyclerEvent(GwStrEnum):
"""
Values:
- WakeUp
- GoDormant
- PicoMissing
- ConfirmOpened
- StartClosing
Expand All @@ -21,6 +23,8 @@ class PicoCyclerEvent(GwStrEnum):
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#picocyclerevent)
"""

WakeUp = auto()
GoDormant = auto()
PicoMissing = auto()
ConfirmOpened = auto()
StartClosing = auto()
Expand Down
2 changes: 2 additions & 0 deletions src/gwproto/enums/pico_cycler_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PicoCyclerState(GwStrEnum):
"""
Values:
- Dormant
- PicosLive
- RelayOpening
- RelayOpen
Expand All @@ -20,6 +21,7 @@ class PicoCyclerState(GwStrEnum):
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#picocyclerstate)
"""

Dormant = auto()
PicosLive = auto()
RelayOpening = auto()
RelayOpen = auto()
Expand Down
4 changes: 4 additions & 0 deletions src/gwproto/named_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from gwproto.named_types.fsm_event import FsmEvent
from gwproto.named_types.fsm_full_report import FsmFullReport
from gwproto.named_types.fsm_trigger_from_atn import FsmTriggerFromAtn
from gwproto.named_types.go_dormant import GoDormant
from gwproto.named_types.gt_sh_cli_atn_cmd import GtShCliAtnCmd
from gwproto.named_types.heartbeat_b import HeartbeatB
from gwproto.named_types.hubitat_component_gt import HubitatComponentGt
Expand Down Expand Up @@ -48,6 +49,7 @@
from gwproto.named_types.ticklist_hall_report import TicklistHallReport
from gwproto.named_types.ticklist_reed import TicklistReed
from gwproto.named_types.ticklist_reed_report import TicklistReedReport
from gwproto.named_types.wake_up import WakeUp
from gwproto.named_types.web_server_component_gt import WebServerComponentGt

__all__ = [
Expand All @@ -68,6 +70,7 @@
"FsmEvent",
"FsmFullReport",
"FsmTriggerFromAtn",
"GoDormant",
"GtShCliAtnCmd",
"HeartbeatB",
"HubitatComponentGt",
Expand Down Expand Up @@ -95,6 +98,7 @@
"TicklistHallReport",
"TicklistReed",
"TicklistReedReport",
"WakeUp",
"WebServerComponentGt",
"cacs", # noqa: F822
"components", # noqa: F822
Expand Down
13 changes: 13 additions & 0 deletions src/gwproto/named_types/go_dormant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Type go.dormant, version 000"""

from typing import Literal

from pydantic import BaseModel

from gwproto.property_format import SpaceheatName


class GoDormant(BaseModel):
ToName: SpaceheatName
TypeName: Literal["go.dormant"] = "go.dormant"
Version: Literal["000"] = "000"
13 changes: 13 additions & 0 deletions src/gwproto/named_types/wake_up.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Type wake.up, version 000"""

from typing import Literal

from pydantic import BaseModel

from gwproto.property_format import SpaceheatName


class WakeUp(BaseModel):
ToName: SpaceheatName
TypeName: Literal["wake.up"] = "wake.up"
Version: Literal["000"] = "000"
16 changes: 16 additions & 0 deletions tests/enums/admin_event_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Tests for enum admin.event.000 from the GridWorks Type Registry.
"""

from gwproto.enums import AdminEvent


def test_admin_event() -> None:
assert set(AdminEvent.values()) == {
"WakeUp",
"GoDormant",
}

assert AdminEvent.default() == AdminEvent.WakeUp
assert AdminEvent.enum_name() == "admin.event"
assert AdminEvent.enum_version() == "000"
16 changes: 16 additions & 0 deletions tests/enums/admin_state_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Tests for enum admin.state.000 from the GridWorks Type Registry.
"""

from gwproto.enums import AdminState


def test_admin_state() -> None:
assert set(AdminState.values()) == {
"Awake",
"Dormant",
}

assert AdminState.default() == AdminState.Dormant
assert AdminState.enum_name() == "admin.state"
assert AdminState.enum_version() == "000"
2 changes: 2 additions & 0 deletions tests/enums/pico_cycler_event_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

def test_pico_cycler_event() -> None:
assert set(PicoCyclerEvent.values()) == {
"WakeUp",
"GoDormant",
"PicoMissing",
"ConfirmOpened",
"StartClosing",
Expand Down
1 change: 1 addition & 0 deletions tests/enums/pico_cycler_state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

def test_pico_cycler_state() -> None:
assert set(PicoCyclerState.values()) == {
"Dormant",
"PicosLive",
"RelayOpening",
"RelayOpen",
Expand Down
15 changes: 15 additions & 0 deletions tests/named_types/test_go_dormant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Tests go.dormant type, version 000"""

from gwproto.named_types import GoDormant


def test_go_dormant_generated() -> None:
d = {
"ToName": "pico-cycler",
"TypeName": "go.dormant",
"Version": "000",
}

d2 = GoDormant.model_validate(d).model_dump(exclude_none=True)

assert d2 == d
15 changes: 15 additions & 0 deletions tests/named_types/test_wake_up.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Tests wake.up type, version 000"""

from gwproto.named_types import WakeUp


def test_wake_up_generated() -> None:
d = {
"ToName": "pico-cycler",
"TypeName": "wake.up",
"Version": "000",
}

d2 = WakeUp.model_validate(d).model_dump(exclude_none=True)

assert d2 == d

0 comments on commit b97ca2d

Please sign in to comment.