@@ -76,33 +76,33 @@ async def async_setup_entry(
7676 @callback
7777 def _add_entities () -> None :
7878 """Add Entities during init and runtime."""
79- if not coordinator .new_device_zones :
79+ if not coordinator .new_pw_entities :
8080 return
8181
82- climate_present = False
82+ thermostat_zone_present = False
8383 entities : list [PlugwiseClimateEntity ] = []
84- for devzone_id in coordinator .new_device_zones :
85- devzone = coordinator .data .device_zones [ devzone_id ]
86- if devzone [DEV_CLASS ] == "climate" :
87- climate_present = True
88- thermostat = coordinator .data .device_zones [ devzone_id ]
84+ for pw_entity_id in coordinator .new_pw_entities :
85+ pw_entity = coordinator .data .entities [ pw_entity_id ]
86+ if pw_entity [DEV_CLASS ] == "climate" :
87+ thermostat_zone_present = True
88+ thermostat = coordinator .data .entities [ pw_entity_id ]
8989 entities .append (
9090 PlugwiseClimateEntity (
91- coordinator , devzone_id , homekit_enabled
91+ coordinator , pw_entity_id , homekit_enabled
9292 ) # pw-beta homekit emulation
9393 )
9494 LOGGER .debug ("Add climate %s" , thermostat [ATTR_NAME ])
9595
96- if not climate_present :
97- for device_id in coordinator .new_device_zones :
98- device = coordinator .data .device_zones [ device_id ]
99- if device [DEV_CLASS ] in MASTER_THERMOSTATS :
96+ if not thermostat_zone_present :
97+ for pw_entity_id in coordinator .new_pw_entities :
98+ pw_entity = coordinator .data .entities [ pw_entity_id ]
99+ if pw_entity [DEV_CLASS ] in MASTER_THERMOSTATS :
100100 entities .append (
101101 PlugwiseClimateEntity (
102- coordinator , device_id , homekit_enabled
102+ coordinator , pw_entity_id , homekit_enabled
103103 ) # pw-beta homekit emulation
104104 )
105- LOGGER .debug ("Add climate %s" , device [ATTR_NAME ])
105+ LOGGER .debug ("Add climate %s" , pw_entity [ATTR_NAME ])
106106
107107 async_add_entities (entities )
108108
@@ -125,28 +125,28 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
125125 def __init__ (
126126 self ,
127127 coordinator : PlugwiseDataUpdateCoordinator ,
128- device_id : str ,
128+ pw_entity_id : str ,
129129 homekit_enabled : bool , # pw-beta homekit emulation
130130 ) -> None :
131131 """Set up the Plugwise API."""
132- super ().__init__ (coordinator , device_id )
132+ super ().__init__ (coordinator , pw_entity_id )
133133
134134 self ._homekit_enabled = homekit_enabled # pw-beta homekit emulation
135135
136- self ._location = device_id
137- if (location := self .device_zone .get (LOCATION )) is not None :
136+ self ._location = pw_entity_id
137+ if (location := self .pw_entity .get (LOCATION )) is not None :
138138 self ._location = location
139139
140140 gateway_id : str = coordinator .data .gateway [GATEWAY_ID ]
141- self .gateway_data = coordinator .data .device_zones [gateway_id ]
141+ self .gateway_data = coordinator .data .entities [gateway_id ]
142142
143- self ._attr_max_temp = min (self .device_zone [THERMOSTAT ][UPPER_BOUND ], 35.0 )
144- self ._attr_min_temp = self .device_zone [THERMOSTAT ][LOWER_BOUND ]
143+ self ._attr_max_temp = min (self .pw_entity [THERMOSTAT ][UPPER_BOUND ], 35.0 )
144+ self ._attr_min_temp = self .pw_entity [THERMOSTAT ][LOWER_BOUND ]
145145 # Ensure we don't drop below 0.1
146146 self ._attr_target_temperature_step = max (
147- self .device_zone [THERMOSTAT ][RESOLUTION ], 0.1
147+ self .pw_entity [THERMOSTAT ][RESOLUTION ], 0.1
148148 )
149- self ._attr_unique_id = f"{ device_id } -climate"
149+ self ._attr_unique_id = f"{ pw_entity_id } -climate"
150150
151151 # Determine supported features
152152 self .cdr_gateway = coordinator .data .gateway
@@ -162,7 +162,7 @@ def __init__(
162162 self ._attr_supported_features |= (
163163 ClimateEntityFeature .TURN_OFF | ClimateEntityFeature .TURN_ON
164164 )
165- if presets := self .device_zone ["preset_modes" ]: # can be NONE
165+ if presets := self .pw_entity ["preset_modes" ]: # can be NONE
166166 self ._attr_supported_features |= ClimateEntityFeature .PRESET_MODE
167167 self ._attr_preset_modes = presets
168168
@@ -183,7 +183,7 @@ def _previous_action_mode(self, coordinator: PlugwiseDataUpdateCoordinator) -> N
183183 @property
184184 def current_temperature (self ) -> float :
185185 """Return the current temperature."""
186- return self .device_zone [SENSORS ][ATTR_TEMPERATURE ]
186+ return self .pw_entity [SENSORS ][ATTR_TEMPERATURE ]
187187
188188 @property
189189 def target_temperature (self ) -> float :
@@ -192,29 +192,29 @@ def target_temperature(self) -> float:
192192 Connected to the HVACMode combination of AUTO-HEAT.
193193 """
194194
195- return self .device_zone [THERMOSTAT ][TARGET_TEMP ]
195+ return self .pw_entity [THERMOSTAT ][TARGET_TEMP ]
196196
197197 @property
198198 def target_temperature_high (self ) -> float :
199199 """Return the temperature we try to reach in case of cooling.
200200
201201 Connected to the HVACMode combination of AUTO-HEAT_COOL.
202202 """
203- return self .device_zone [THERMOSTAT ][TARGET_TEMP_HIGH ]
203+ return self .pw_entity [THERMOSTAT ][TARGET_TEMP_HIGH ]
204204
205205 @property
206206 def target_temperature_low (self ) -> float :
207207 """Return the heating temperature we try to reach in case of heating.
208208
209209 Connected to the HVACMode combination AUTO-HEAT_COOL.
210210 """
211- return self .device_zone [THERMOSTAT ][TARGET_TEMP_LOW ]
211+ return self .pw_entity [THERMOSTAT ][TARGET_TEMP_LOW ]
212212
213213 @property
214214 def hvac_mode (self ) -> HVACMode :
215215 """Return HVAC operation ie. auto, cool, heat, heat_cool, or off mode."""
216216 if (
217- mode := self .device_zone [CLIMATE_MODE ]
217+ mode := self .pw_entity [CLIMATE_MODE ]
218218 ) is None or mode not in self .hvac_modes : # pw-beta add to Core
219219 return HVACMode .HEAT # pragma: no cover
220220 # pw-beta homekit emulation
@@ -233,7 +233,7 @@ def hvac_modes(self) -> list[HVACMode]:
233233 ):
234234 hvac_modes .append (HVACMode .OFF )
235235
236- if AVAILABLE_SCHEDULES in self .device_zone :
236+ if AVAILABLE_SCHEDULES in self .pw_entity :
237237 hvac_modes .append (HVACMode .AUTO )
238238
239239 if self .cdr_gateway [COOLING_PRESENT ]:
@@ -256,14 +256,14 @@ def hvac_action(self) -> HVACAction: # pw-beta add to Core
256256 self ._previous_action_mode (self .coordinator )
257257
258258 # Adam provides the hvac_action for each thermostat
259- if (control_state := self .device_zone .get (CONTROL_STATE )) in (HVACAction .COOLING , HVACAction .HEATING , HVACAction .PREHEATING ):
259+ if (control_state := self .pw_entity .get (CONTROL_STATE )) in (HVACAction .COOLING , HVACAction .HEATING , HVACAction .PREHEATING ):
260260 return cast (HVACAction , control_state )
261261 if control_state == HVACMode .OFF :
262262 return HVACAction .IDLE
263263
264264 # Anna
265265 heater : str = self .coordinator .data .gateway ["heater_id" ]
266- heater_data = self .coordinator .data .device_zones [heater ]
266+ heater_data = self .coordinator .data .entities [heater ]
267267 if heater_data [BINARY_SENSORS ][HEATING_STATE ]:
268268 return HVACAction .HEATING
269269 if heater_data [BINARY_SENSORS ].get (COOLING_STATE , False ):
@@ -274,7 +274,7 @@ def hvac_action(self) -> HVACAction: # pw-beta add to Core
274274 @property
275275 def preset_mode (self ) -> str | None :
276276 """Return the current preset mode."""
277- return self .device_zone [ACTIVE_PRESET ]
277+ return self .pw_entity [ACTIVE_PRESET ]
278278
279279 @plugwise_command
280280 async def async_set_temperature (self , ** kwargs : Any ) -> None :
0 commit comments