From 99975fe6e764c1ab821f05e93d31512daa4a01f8 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sat, 2 Sep 2023 15:06:00 +0200 Subject: [PATCH] More rearranging --- plugwise/constants.py | 131 ++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/plugwise/constants.py b/plugwise/constants.py index 91eb0fdb0..b6762183a 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -31,29 +31,6 @@ VOLUME_CUBIC_METERS: Final = "m³" VOLUME_CUBIC_METERS_PER_HOUR: Final = "m³/h" -ACTUATOR_CLASSES: Final[tuple[str, ...]] = ( - "heater_central", - "thermostat", - "thermostatic_radiator_valve", - "zone_thermometer", - "zone_thermostat", -) -ActuatorType = Literal[ - "domestic_hot_water_setpoint", - "max_dhw_temperature", - "maximum_boiler_temperature", - "temperature_offset", - "thermostat", -] -ACTIVE_ACTUATORS: Final[tuple[str, ...]] = get_args(ActuatorType) -ActuatorDataType = Literal[ - "lower_bound", - "resolution", - "setpoint", - "setpoint_high", - "setpoint_low", - "upper_bound", -] DAYS: Final[dict[str, int]] = { "mo": 0, "tu": 1, @@ -108,36 +85,10 @@ "070051": "Switch", "080029": "Switch", } -LIMITS: Final[tuple[str, ...]] = ( - "offset", - "setpoint", - "resolution", - "lower_bound", - "upper_bound", -) + MAX_SETPOINT: Final[float] = 30.0 MIN_SETPOINT: Final[float] = 4.0 NONE: Final = "None" -SPECIAL_FORMAT: Final[tuple[str, ...]] = (ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS) -SWITCH_GROUP_TYPES: Final[tuple[str, ...]] = ("switching", "report") -ZONE_THERMOSTATS: Final[tuple[str, ...]] = ( - "thermostat", - "thermostatic_radiator_valve", - "zone_thermometer", - "zone_thermostat", -) -THERMOSTAT_CLASSES: Final[tuple[str, ...]] = ( - "thermostat", - "thermo_sensor", - "zone_thermometer", - "zone_thermostat", - "thermostatic_radiator_valve", -) -SPECIAL_PLUG_TYPES: Final[tuple[str, ...]] = ( - "central_heating_pump", - "valve_actuator", - "heater_electric", -) # XML data paths APPLIANCES: Final = "/core/appliances" @@ -151,6 +102,7 @@ UOM = namedtuple("UOM", "unit_of_measurement") DATA = namedtuple("DATA", "name unit_of_measurement") + # P1 related measurements: P1_MEASUREMENTS: Final[dict[str, UOM]] = { "electricity_consumed": UOM(POWER_WATT), @@ -234,15 +186,6 @@ "outdoor_temperature": DATA("outdoor_air_temperature", TEMP_CELSIUS), } -ToggleNameType = Literal[ - "cooling_ena_switch", - "dhw_cm_switch", -] -TOGGLES: Final[dict[str, ToggleNameType]] = { - "cooling_enabled": "cooling_ena_switch", - "domestic_hot_water_comfort_mode": "dhw_cm_switch", -} - # Known types of Smiles and Stretches SMILE = namedtuple("SMILE", "smile_type smile_name") SMILES: Final[dict[str, SMILE]] = { @@ -258,7 +201,32 @@ "stretch_v3": SMILE("stretch", "Stretch"), } -# All available Binary Sensor, Sensor, and Switch Types +# Class, Literal and related tuple-definitions + +ACTUATOR_CLASSES: Final[tuple[str, ...]] = ( + "heater_central", + "thermostat", + "thermostatic_radiator_valve", + "zone_thermometer", + "zone_thermostat", +) +ActuatorType = Literal[ + "domestic_hot_water_setpoint", + "max_dhw_temperature", + "maximum_boiler_temperature", + "temperature_offset", + "thermostat", +] +ACTIVE_ACTUATORS: Final[tuple[str, ...]] = get_args(ActuatorType) + +ActuatorDataType = Literal[ + "lower_bound", + "resolution", + "setpoint", + "setpoint_high", + "setpoint_low", + "upper_bound", +] ApplianceType = Literal[ "dev_class", @@ -291,6 +259,14 @@ "temperature_offset", ] +LIMITS: Final[tuple[str, ...]] = ( + "offset", + "setpoint", + "resolution", + "lower_bound", + "upper_bound", +) + SelectType = Literal[ "select_dhw_mode", "select_regulation_mode", @@ -357,6 +333,14 @@ ] SENSORS: Final[tuple[str, ...]] = get_args(SensorType) +SPECIAL_PLUG_TYPES: Final[tuple[str, ...]] = ( + "central_heating_pump", + "valve_actuator", + "heater_electric", +) + +SPECIAL_FORMAT: Final[tuple[str, ...]] = (ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS) + SwitchType = Literal[ "cooling_ena_switch", "dhw_cm_switch", @@ -365,6 +349,32 @@ ] SWITCHES: Final[tuple[str, ...]] = get_args(SwitchType) +SWITCH_GROUP_TYPES: Final[tuple[str, ...]] = ("switching", "report") + +THERMOSTAT_CLASSES: Final[tuple[str, ...]] = ( + "thermostat", + "thermo_sensor", + "zone_thermometer", + "zone_thermostat", + "thermostatic_radiator_valve", +) + +ToggleNameType = Literal[ + "cooling_ena_switch", + "dhw_cm_switch", +] +TOGGLES: Final[dict[str, ToggleNameType]] = { + "cooling_enabled": "cooling_ena_switch", + "domestic_hot_water_comfort_mode": "dhw_cm_switch", +} + +ZONE_THERMOSTATS: Final[tuple[str, ...]] = ( + "thermostat", + "thermostatic_radiator_valve", + "zone_thermometer", + "zone_thermostat", +) + class GatewayData(TypedDict, total=False): """The Gateway Data class.""" @@ -434,7 +444,6 @@ class SmileSensors(TypedDict, total=False): electricity_produced_peak_interval: int electricity_produced_peak_point: int electricity_produced_point: float - elga_status_code: int gas_consumed_cumulative: float gas_consumed_interval: float humidity: float