99 ATTR_HVAC_MODE ,
1010 ATTR_TARGET_TEMP_HIGH ,
1111 ATTR_TARGET_TEMP_LOW ,
12- PRESET_AWAY , # pw-beta homekit emulation
13- PRESET_HOME , # pw-beta homekit emulation
1412 ClimateEntity ,
1513 ClimateEntityFeature ,
1614 HVACAction ,
3230 ACTIVE_PRESET ,
3331 AVAILABLE_SCHEDULES ,
3432 CLIMATE_MODE ,
35- CONF_HOMEKIT_EMULATION , # pw-beta homekit emulation
3633 CONTROL_STATE ,
3734 DEV_CLASS ,
3835 DOMAIN ,
@@ -65,9 +62,6 @@ async def async_setup_entry(
6562) -> None :
6663 """Set up Plugwise thermostats from a config entry."""
6764 coordinator = entry .runtime_data
68- homekit_enabled : bool = entry .options .get (
69- CONF_HOMEKIT_EMULATION , False
70- ) # pw-beta homekit emulation
7165
7266 @callback
7367 def _add_entities () -> None :
@@ -82,16 +76,12 @@ def _add_entities() -> None:
8276 if gateway_name == "Adam" :
8377 if device [DEV_CLASS ] == "climate" :
8478 entities .append (
85- PlugwiseClimateEntity (
86- coordinator , device_id , homekit_enabled
87- ) # pw-beta homekit emulation
79+ PlugwiseClimateEntity (coordinator , device_id )
8880 )
8981 LOGGER .debug ("Add climate %s" , device [ATTR_NAME ])
9082 elif device [DEV_CLASS ] in MASTER_THERMOSTATS :
9183 entities .append (
92- PlugwiseClimateEntity (
93- coordinator , device_id , homekit_enabled
94- ) # pw-beta homekit emulation
84+ PlugwiseClimateEntity (coordinator , device_id )
9585 )
9686 LOGGER .debug ("Add climate %s" , device [ATTR_NAME ])
9787
@@ -135,7 +125,6 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity, RestoreEntity):
135125
136126 _last_active_schedule : str | None = None
137127 _previous_action_mode : str | None = HVACAction .HEATING .value # Upstream
138- _homekit_mode : HVACMode | None = None # pw-beta homekit emulation + intentional unsort
139128
140129 async def async_added_to_hass (self ) -> None :
141130 """Run when entity about to be added."""
@@ -152,14 +141,12 @@ def __init__(
152141 self ,
153142 coordinator : PlugwiseDataUpdateCoordinator ,
154143 device_id : str ,
155- homekit_enabled : bool , # pw-beta homekit emulation
156144 ) -> None :
157145 """Set up the Plugwise API."""
158146 super ().__init__ (coordinator , device_id )
159147
160148 gateway_id : str = coordinator .api .gateway_id
161149 self ._gateway_data = coordinator .data [gateway_id ]
162- self ._homekit_enabled = homekit_enabled # pw-beta homekit emulation
163150 self ._location = device_id
164151 if (location := self .device .get (LOCATION )) is not None :
165152 self ._location = location
@@ -239,20 +226,14 @@ def hvac_mode(self) -> HVACMode:
239226 return HVACMode .HEAT # pragma: no cover
240227 if hvac not in self .hvac_modes :
241228 return HVACMode .HEAT # pragma: no cover
242- # pw-beta homekit emulation
243- if self ._homekit_enabled and self ._homekit_mode == HVACMode .OFF :
244- return HVACMode .OFF # pragma: no cover
245229
246230 return hvac
247231
248232 @property
249233 def hvac_modes (self ) -> list [HVACMode ]:
250234 """Return a list of available HVACModes."""
251235 hvac_modes : list [HVACMode ] = []
252- if (
253- self ._homekit_enabled # pw-beta homekit emulation
254- or REGULATION_MODES in self ._gateway_data
255- ):
236+ if REGULATION_MODES in self ._gateway_data :
256237 hvac_modes .append (HVACMode .OFF )
257238
258239 if self .device .get (AVAILABLE_SCHEDULES , []):
@@ -319,10 +300,11 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
319300 if hvac_mode == self .hvac_mode :
320301 return
321302
322- if hvac_mode != HVACMode .OFF :
303+ if hvac_mode == HVACMode .OFF :
304+ await self .coordinator .api .set_regulation_mode (hvac_mode .value )
305+ else :
323306 current = self .device .get ("select_schedule" )
324307 desired = current
325-
326308 # Capture the last valid schedule
327309 if desired and desired != "off" :
328310 self ._last_active_schedule = desired
@@ -341,27 +323,10 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
341323 STATE_ON if hvac_mode == HVACMode .AUTO else STATE_OFF ,
342324 desired ,
343325 )
344-
345- await self ._homekit_translate_or_not (hvac_mode ) # pw-beta
346-
347- async def _homekit_translate_or_not (self , mode : HVACMode ) -> None :
348- """Mimic HomeKit by setting a suitable preset, when homekit mode is enabled."""
349- if (
350- not self ._homekit_enabled # pw-beta
351- ):
352- if mode == HVACMode .OFF :
353- await self .coordinator .api .set_regulation_mode (mode .value )
354- elif self .hvac_mode == HVACMode .OFF and self ._previous_action_mode :
355- await self .coordinator .api .set_regulation_mode (self ._previous_action_mode )
356- else : # pw-beta
357- self ._homekit_mode = mode # pragma: no cover
358- if self ._homekit_mode == HVACMode .OFF : # pragma: no cover
359- await self .async_set_preset_mode (PRESET_AWAY ) # pragma: no cover
360- if (
361- self ._homekit_mode in [HVACMode .HEAT , HVACMode .HEAT_COOL ]
362- and self .device .get (ACTIVE_PRESET ) == PRESET_AWAY
363- ): # pragma: no cover
364- await self .async_set_preset_mode (PRESET_HOME ) # pragma: no cover
326+ if self .hvac_mode == HVACMode .OFF and self ._previous_action_mode :
327+ await self .coordinator .api .set_regulation_mode (
328+ self ._previous_action_mode
329+ )
365330
366331 @plugwise_command
367332 async def async_set_preset_mode (self , preset_mode : str ) -> None :
0 commit comments