Skip to content

Commit 38f1c53

Browse files
committed
Rename to zone
1 parent 23968c2 commit 38f1c53

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed

plugwise/constants.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@
144144
"relay": UOM(NONE),
145145
}
146146

147-
# Climate related measurements
148-
CLIMATE_MEASUREMENTS: Final[dict[str, DATA | UOM]] = {
149-
"temperature": UOM(TEMP_CELSIUS), # HA Core thermostat current_temperature
150-
}
151-
152147
# Heater Central related measurements
153148
HEATER_CENTRAL_MEASUREMENTS: Final[dict[str, DATA | UOM]] = {
154149
"boiler_state": DATA(
@@ -195,6 +190,14 @@
195190
"outdoor_temperature",
196191
)
197192

193+
# Zone/climate related measurements
194+
ZONE_MEASUREMENTS: Final[dict[str, DATA | UOM]] = {
195+
"electricity_consumed": UOM(POWER_WATT),
196+
"electricity_produced": UOM(POWER_WATT),
197+
"relay": UOM(NONE),
198+
"temperature": UOM(TEMP_CELSIUS), # HA Core thermostat current_temperature
199+
}
200+
198201
# Literals
199202
SMILE_P1 = "Smile P1"
200203
POWER = "power"
@@ -513,7 +516,7 @@ class ActuatorData(TypedDict, total=False):
513516
upper_bound: float
514517

515518

516-
class ClimateData(TypedDict, total=False):
519+
class ZoneData(TypedDict, total=False):
517520
"""The Climate Data class, covering the collected and ordered output-data per location."""
518521

519522
dev_class: str
@@ -529,6 +532,7 @@ class ClimateData(TypedDict, total=False):
529532
available_schedules: list[str]
530533
select_schedule: str
531534

535+
sensors: SmileSensors
532536
thermostat: ActuatorData
533537

534538

@@ -582,5 +586,5 @@ class PlugwiseData:
582586
"""Plugwise data provided as output."""
583587

584588
gateway: GatewayData
585-
climates: dict[str, ClimateData]
586589
devices: dict[str, DeviceData]
590+
zones: dict[str, ZoneData]

plugwise/data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _all_device_data(self) -> None:
3636
Collect data for each device and add to self.gw_data and self.gw_devices.
3737
"""
3838
self._update_gw_devices()
39-
self._update_climates()
39+
self._update_zones()
4040
self.gw_data.update(
4141
{
4242
"gateway_id": self.gateway_id,
@@ -51,14 +51,14 @@ def _all_device_data(self) -> None:
5151
{"heater_id": self._heater_id, "cooling_present": self._cooling_present}
5252
)
5353

54-
def _update_climates(self) -> None:
54+
def _update_zones(self) -> None:
5555
"""Helper-function for _all_device_data() and async_update().
5656
57-
Collect data for each climate-location and add to self.climate_data.
57+
Collect data for each zone/location and add to self.zone_data.
5858
"""
59-
for location_id, climate in self.climate_data.items():
59+
for location_id, zone in self.zone_data.items():
6060
data = self._get_location_data(location_id)
61-
climate.update(data)
61+
zone.update(data)
6262

6363
def _update_gw_devices(self) -> None:
6464
"""Helper-function for _all_device_data() and async_update().
@@ -157,14 +157,14 @@ def _get_location_data(self, loc_id: str) -> DeviceData:
157157
158158
Provide device-data, based on Location ID (= loc_id).
159159
"""
160-
climate = self.climate_data[loc_id]
161-
data = self._get_climate_data(loc_id)
160+
zone = self.zone_data[loc_id]
161+
data = self._get_zone_data(loc_id)
162162
if ctrl_state := self._control_state(loc_id):
163163
data["control_state"] = ctrl_state
164164
self._count += 1
165165

166166
# Thermostat data (presets, temperatures etc)
167-
self._device_data_climate(loc_id, climate, data)
167+
self._device_data_climate(loc_id, zone, data)
168168

169169
return data
170170

plugwise/helper.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
ADAM,
1616
ANNA,
1717
ATTR_NAME,
18-
CLIMATE_MEASUREMENTS,
1918
DATA,
2019
DEVICE_MEASUREMENTS,
2120
DHW_SETPOINT,
@@ -33,15 +32,16 @@
3332
THERMOSTAT_CLASSES,
3433
TOGGLES,
3534
UOM,
35+
ZONE_MEASUREMENTS,
3636
ActuatorData,
3737
ActuatorDataType,
3838
ActuatorType,
39-
ClimateData,
4039
DeviceData,
4140
GatewayData,
4241
SensorType,
4342
ThermoLoc,
4443
ToggleNameType,
44+
ZoneData,
4545
)
4646
from plugwise.exceptions import (
4747
ConnectionFailedError,
@@ -250,7 +250,6 @@ def __init__(self) -> None:
250250
self._cooling_enabled = False
251251

252252
self.gateway_id: str
253-
self.climate_data: ClimateData = {}
254253
self.gw_data: GatewayData = {}
255254
self.gw_devices: dict[str, DeviceData] = {}
256255
self.loc_data: dict[str, ThermoLoc]
@@ -263,6 +262,7 @@ def __init__(self) -> None:
263262
self.smile_type: str
264263
self.smile_zigbee_mac_address: str | None
265264
self.therms_with_offset_func: list[str] = []
265+
self.zone_data: ZoneData = {}
266266
SmileCommon.__init__(self)
267267

268268
def _all_appliances(self) -> None:
@@ -483,19 +483,19 @@ def _get_appliances_with_offset_functionality(self) -> list[str]:
483483

484484
return therm_list
485485

486-
def _get_climate_data(self, loc_id: str) -> ClimateData:
486+
def _get_zone_data(self, loc_id: str) -> ZoneData:
487487
"""Helper-function for smile.py: _get_device_data().
488488
489489
Collect the location-data based on location id.
490490
"""
491-
data: ClimateData = {"sensors": {}}
492-
climate = self.climate_data[loc_id]
493-
measurements = CLIMATE_MEASUREMENTS
491+
data: ZoneData = {"sensors": {}}
492+
zone = self.zone_data[loc_id]
493+
measurements = ZONE_MEASUREMENTS
494494
if (
495495
location := self._domain_objects.find(f'./location[@id="{loc_id}"]')
496496
) is not None:
497497
self._appliance_measurements(location, data, measurements)
498-
self._get_actuator_functionalities(location, climate, data)
498+
self._get_actuator_functionalities(location, zone, data)
499499

500500
return data
501501

@@ -682,7 +682,7 @@ def _get_actuator_functionalities(
682682
"""Helper-function for _get_measurement_data()."""
683683
for item in ACTIVE_ACTUATORS:
684684
# Skip max_dhw_temperature, not initially valid,
685-
# skip thermostat for all but climates
685+
# skip thermostat for all but zones with thermostats
686686
if item == "max_dhw_temperature" or (
687687
item == "thermostat" and device["dev_class"] != "climate"
688688
):
@@ -835,7 +835,7 @@ def _scan_thermostats(self) -> None:
835835

836836
for loc_id, loc_data in list(self._thermo_locs.items()):
837837
if loc_data["primary_prio"] != 0:
838-
self.climate_data.update(
838+
self.zone_data.update(
839839
{
840840
loc_id: {
841841
"dev_class": "climate",
@@ -845,11 +845,6 @@ def _scan_thermostats(self) -> None:
845845
}
846846
)
847847

848-
# All thermostat appliances can keep their device_class but must not become climate-entities in HA.
849-
# For each _thermo_loc a special climate-device must be created, with setpoint and temperature taken from the thermostat appliance with the lowest reported temperature.
850-
# Also the corresponding device_id must be available, and updated, as an attribute.
851-
# And the other attributes must be taken from the _thermo_loc.
852-
853848
def _match_locations(self) -> dict[str, ThermoLoc]:
854849
"""Helper-function for _scan_thermostats().
855850

plugwise/smile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
NOTIFICATIONS,
2424
OFF,
2525
RULES,
26-
ClimateData,
2726
DeviceData,
2827
GatewayData,
2928
PlugwiseData,
3029
ThermoLoc,
30+
ZoneData,
3131
)
3232
from plugwise.data import SmileData
3333
from plugwise.exceptions import ConnectionFailedError, DataMissingError, PlugwiseError
@@ -126,9 +126,9 @@ def get_all_devices(self) -> None:
126126

127127
async def async_update(self) -> PlugwiseData:
128128
"""Perform an incremental update for updating the various device states."""
129-
self.climate_data: ClimateData = {}
130129
self.gw_data: GatewayData = {}
131130
self.gw_devices: dict[str, DeviceData] = {}
131+
self.zone_data: ZoneData = {}
132132
try:
133133
await self.full_update_device()
134134
self.get_all_devices()
@@ -144,8 +144,8 @@ async def async_update(self) -> PlugwiseData:
144144

145145
return PlugwiseData(
146146
gateway=self.gw_data,
147-
climates=self.climate_data,
148147
devices=self.gw_devices,
148+
zones=self.zone_data,
149149
)
150150

151151
########################################################################################################

tests/test_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ async def device_test(
584584
if "cooling_state" in heat_cooler["binary_sensors"]:
585585
self._cooling_active = heat_cooler["binary_sensors"]["cooling_state"]
586586

587-
self._write_json("all_data", {"gateway": data.gateway, "devices": data.devices})
587+
self._write_json("all_data", {"gateway": data.gateway, "devices": data.devices, "zones": data.zones})
588588

589589
if "FIXTURES" in os.environ:
590590
_LOGGER.info("Skipping tests: Requested fixtures only") # pragma: no cover
@@ -596,7 +596,7 @@ async def device_test(
596596
_LOGGER.info("Gateway id = %s", data.gateway["gateway_id"])
597597
_LOGGER.info("Hostname = %s", smile.smile_hostname)
598598
_LOGGER.info("Gateway data = %s", data.gateway)
599-
_LOGGER.info("Climate data = %s", data.climates)
599+
_LOGGER.info("Zone data = %s", data.zones)
600600
_LOGGER.info("Device list = %s", data.devices)
601601
self.show_setup(location_list, data.devices)
602602

0 commit comments

Comments
 (0)