Skip to content

Commit

Permalink
refactor order of declaration of typed dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Oct 18, 2024
1 parent c71b498 commit d9d4155
Showing 1 changed file with 147 additions and 146 deletions.
293 changes: 147 additions & 146 deletions src/ramses_tx/typed_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,153 @@
__all__ = ["PayDictT"]


# fmt: off
LogIdxT = Literal[
'00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C', '0D', '0E', '0F',
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1A', '1B', '1C', '1D', '1E', '1F',
'20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F',
'30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F',
]
# fmt: on


class _FlowRate(TypedDict):
dhw_flow_rate: _HexToTempT


class _Pressure(TypedDict):
pressure: _HexToTempT


class _Setpoint(TypedDict):
setpoint: _HexToTempT


class _Temperature(TypedDict):
temperature: _HexToTempT


class FaultLogEntryNull(TypedDict): # NOTE: not identical to _0418
_log_idx: LogIdxT # "00" to ?"3F"


class FaultLogEntry(TypedDict): # NOTE: not identical to _0418
_log_idx: LogIdxT # "00" to ?"3F"

timestamp: str
fault_state: FaultState
fault_type: FaultType
domain_idx: str
device_class: FaultDeviceClass
device_id: DeviceIdT | None

_unknown_3: str
_unknown_7: str
_unknown_15: str


# These are from 31DA...
class AirQuality(TypedDict):
air_quality: float | None
air_quality_basis: NotRequired[str]


class Co2Level(TypedDict):
co2_level: float | None


class IndoorHumidity(TypedDict):
indoor_humidity: _HexToTempT
temperature: NotRequired[float | None]
dewpoint_temp: NotRequired[float | None]


class OutdoorHumidity(TypedDict):
outdoor_humidity: _HexToTempT
temperature: NotRequired[float | None]
dewpoint_temp: NotRequired[float | None]


class ExhaustTemp(TypedDict):
exhaust_temp: _HexToTempT


class SupplyTemp(TypedDict):
supply_temp: _HexToTempT


class IndoorTemp(TypedDict):
indoor_temp: _HexToTempT


class OutdoorTemp(TypedDict):
outdoor_temp: _HexToTempT


class Capabilities(TypedDict):
speed_capabilities: list[str] | None


class BypassPosition(TypedDict):
bypass_position: float | None


class FanInfo(TypedDict):
fan_info: str
_unknown_fan_info_flags: list[int]


class ExhaustFanSpeed(TypedDict):
exhaust_fan: float | None


class SupplyFanSpeed(TypedDict):
supply_fan: float | None


class RemainingMins(TypedDict):
remaining_mins: int | None


class PostHeater(TypedDict):
post_heater: float | None


class PreHeater(TypedDict):
pre_heater: float | None


class SupplyFlow(TypedDict):
supply_flow: float | None


class ExhaustFlow(TypedDict):
exhaust_flow: float | None


class _VentilationState(
AirQuality,
Co2Level,
ExhaustTemp,
SupplyTemp,
IndoorTemp,
OutdoorTemp,
Capabilities,
BypassPosition,
FanInfo,
ExhaustFanSpeed,
SupplyFanSpeed,
RemainingMins,
PostHeater,
PreHeater,
SupplyFlow,
ExhaustFlow,
):
indoor_humidity: _HexToTempT
outdoor_humidity: _HexToTempT


# These are payload-specific...
class _empty(TypedDict):
pass

Expand Down Expand Up @@ -50,16 +197,6 @@ class _0404(TypedDict):
fragment: NotRequired[str]


# fmt: off
LogIdxT = Literal[
'00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0A', '0B', '0C', '0D', '0E', '0F',
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1A', '1B', '1C', '1D', '1E', '1F',
'20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F',
'30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F',
]
# fmt: on


class _0418_NULL(TypedDict): # only I_/RP with null payload
log_idx: NotRequired[LogIdxT] # only when I_|0418|00 with null payload
log_entry: None
Expand Down Expand Up @@ -246,142 +383,6 @@ class _JASPER(TypedDict):
blob: str


class _FlowRate(TypedDict):
dhw_flow_rate: _HexToTempT


class _Pressure(TypedDict):
pressure: _HexToTempT


class _Setpoint(TypedDict):
setpoint: _HexToTempT


class _Temperature(TypedDict):
temperature: _HexToTempT


class FaultLogEntryNull(TypedDict): # NOTE: not identical to _0418
_log_idx: LogIdxT # "00" to ?"3F"


class FaultLogEntry(TypedDict): # NOTE: not identical to _0418
_log_idx: LogIdxT # "00" to ?"3F"

timestamp: str
fault_state: FaultState
fault_type: FaultType
domain_idx: str
device_class: FaultDeviceClass
device_id: DeviceIdT | None

_unknown_3: str
_unknown_7: str
_unknown_15: str


# These are from 31DA...
class AirQuality(TypedDict):
air_quality: float | None
air_quality_basis: NotRequired[str]


class Co2Level(TypedDict):
co2_level: float | None


class IndoorHumidity(TypedDict):
indoor_humidity: _HexToTempT
temperature: NotRequired[float | None]
dewpoint_temp: NotRequired[float | None]


class OutdoorHumidity(TypedDict):
outdoor_humidity: _HexToTempT
temperature: NotRequired[float | None]
dewpoint_temp: NotRequired[float | None]


class ExhaustTemp(TypedDict):
exhaust_temp: _HexToTempT


class SupplyTemp(TypedDict):
supply_temp: _HexToTempT


class IndoorTemp(TypedDict):
indoor_temp: _HexToTempT


class OutdoorTemp(TypedDict):
outdoor_temp: _HexToTempT


class Capabilities(TypedDict):
speed_capabilities: list[str] | None


class BypassPosition(TypedDict):
bypass_position: float | None


class FanInfo(TypedDict):
fan_info: str
_unknown_fan_info_flags: list[int]


class ExhaustFanSpeed(TypedDict):
exhaust_fan: float | None


class SupplyFanSpeed(TypedDict):
supply_fan: float | None


class RemainingMins(TypedDict):
remaining_mins: int | None


class PostHeater(TypedDict):
post_heater: float | None


class PreHeater(TypedDict):
pre_heater: float | None


class SupplyFlow(TypedDict):
supply_flow: float | None


class ExhaustFlow(TypedDict):
exhaust_flow: float | None


class _VentilationState(
AirQuality,
Co2Level,
ExhaustTemp,
SupplyTemp,
IndoorTemp,
OutdoorTemp,
Capabilities,
BypassPosition,
FanInfo,
ExhaustFanSpeed,
SupplyFanSpeed,
RemainingMins,
PostHeater,
PreHeater,
SupplyFlow,
ExhaustFlow,
):
indoor_humidity: _HexToTempT
outdoor_humidity: _HexToTempT


class PayDictT:
"""Payload dict types."""

Expand Down

0 comments on commit d9d4155

Please sign in to comment.