Files
2026-04-27 15:07:30 +02:00

60 lines
1.3 KiB
Python

"""Shared data models for Sternwarte."""
from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime
@dataclass(slots=True)
class SternwarteState:
"""Parsed state from the Web-IO."""
inputs: list[bool] = field(default_factory=lambda: [False] * 12)
outputs: list[bool] = field(default_factory=lambda: [False] * 12)
counters: list[int] = field(default_factory=lambda: [0] * 12)
wind_speed_kmh: float = 0.0
@property
def roof_closed(self) -> bool:
return self.inputs[10]
@property
def roof_open(self) -> bool:
return self.inputs[11]
@property
def roof_moving(self) -> bool:
return self.inputs[9]
@property
def raining(self) -> bool:
return self.inputs[7]
@property
def roof_power(self) -> bool:
return self.outputs[0]
@dataclass(slots=True)
class SternwarteSchedule:
"""Persistent schedule state."""
open_at: str = ""
close_at: str = ""
open_done: bool = False
close_done: bool = False
open_power_on_at: str = ""
close_power_on_at: str = ""
rain_close_power_on_at: str = ""
close_power_off_at: str = ""
pending_auto_close: bool = False
@dataclass(slots=True)
class WindSample:
"""Single wind measurement."""
time: datetime
kmh: float