Skip to content

Commit 8951131

Browse files
authored
Merge pull request #1023 from plugwise/remove-homekit
Remove homekit option
2 parents b1689cf + c676f20 commit 8951131

16 files changed

Lines changed: 214 additions & 60 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
Versions from 0.40 and up
44

5-
## Ongoing
5+
## v0.63.0
66

7+
- Remove climate home-kit emulation option via PR [#1023](https://github.com/plugwise/plugwise-beta/pull/1023)
78
- Implement Core PR [#159626](https://github.com/home-assistant/core/pull/159626) via PR [#994](https://github.com/plugwise/plugwise-beta/pull/994)
89
- Chores
910
- Introduce prek (for pre-commit) & align with v2 gh-actions

custom_components/plugwise/climate.py

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
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,
@@ -32,7 +30,6 @@
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:

custom_components/plugwise/config_flow.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
from .const import (
4747
ANNA_WITH_ADAM,
48-
CONF_HOMEKIT_EMULATION, # pw-beta option
4948
CONF_REFRESH_INTERVAL, # pw-beta option
5049
DEFAULT_PORT,
5150
DEFAULT_UPDATE_INTERVAL,
@@ -308,7 +307,6 @@ def async_get_options_flow(
308307

309308

310309
# pw-beta - change the scan-interval via CONFIGURE
311-
# pw-beta - add homekit emulation via CONFIGURE
312310
# pw-beta - change the frontend refresh interval via CONFIGURE
313311
class PlugwiseOptionsFlowHandler(OptionsFlow): # pw-beta options
314312
"""Plugwise option flow."""
@@ -330,10 +328,6 @@ def _create_options_schema(self, coordinator: PlugwiseDataUpdateCoordinator) ->
330328

331329
if coordinator.api.smile.type == THERMOSTAT:
332330
schema.update({
333-
vol.Optional(
334-
CONF_HOMEKIT_EMULATION,
335-
default=self.options.get(CONF_HOMEKIT_EMULATION, False),
336-
): vol.All(cv.boolean),
337331
vol.Optional(
338332
CONF_REFRESH_INTERVAL,
339333
default=self.options.get(CONF_REFRESH_INTERVAL, 1.5),

custom_components/plugwise/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"iot_class": "local_polling",
99
"loggers": ["plugwise"],
1010
"requirements": ["plugwise==1.11.2"],
11-
"version": "0.62.2",
11+
"version": "0.63.0",
1212
"zeroconf": ["_plugwise._tcp.local."]
1313
}

custom_components/plugwise/strings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@
327327
"init": {
328328
"data": {
329329
"cooling_on": "Anna: cooling-mode is on",
330-
"homekit_emulation": "Homekit emulation (i.e. on hvac_off => Away) *) beta-only option",
331330
"refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option",
332331
"scan_interval": "Scan Interval (seconds) *) beta-only option"
333332
},

custom_components/plugwise/translations/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@
327327
"init": {
328328
"data": {
329329
"cooling_on": "Anna: cooling-mode is on",
330-
"homekit_emulation": "Homekit emulation (i.e. on hvac_off => Away) *) beta-only option",
331330
"refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option",
332331
"scan_interval": "Scan Interval (seconds) *) beta-only option"
333332
},

custom_components/plugwise/translations/nl.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@
327327
"init": {
328328
"data": {
329329
"cooling_on": "Anna: koelmodus is aan",
330-
"homekit_emulation": "Homekit emulatie (bij hvac_off => Afwezig) *) optie alleen in beta",
331330
"refresh_interval": "Frontend ververs-tijd (1,5 - 5 seconden) *) optie alleen in beta",
332331
"scan_interval": "Scan Interval (seconden) *) optie alleen in beta"
333332
},

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "plugwise-beta"
3-
version = "0.62.2"
3+
version = "0.63.0"
44
description = "Plugwise beta custom-component"
55
readme = "README.md"
66
requires-python = ">=3.13"

tests/components/plugwise/snapshots/test_binary_sensor.ambr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
'labels': set({
2121
}),
2222
'name': None,
23+
'object_id_base': 'Plugwise notification',
2324
'options': dict({
2425
}),
2526
'original_device_class': None,
@@ -71,6 +72,7 @@
7172
'labels': set({
7273
}),
7374
'name': None,
75+
'object_id_base': 'Battery',
7476
'options': dict({
7577
}),
7678
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -120,6 +122,7 @@
120122
'labels': set({
121123
}),
122124
'name': None,
125+
'object_id_base': 'Battery',
123126
'options': dict({
124127
}),
125128
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -169,6 +172,7 @@
169172
'labels': set({
170173
}),
171174
'name': None,
175+
'object_id_base': 'Heating',
172176
'options': dict({
173177
}),
174178
'original_device_class': None,
@@ -217,6 +221,7 @@
217221
'labels': set({
218222
}),
219223
'name': None,
224+
'object_id_base': 'Battery',
220225
'options': dict({
221226
}),
222227
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -266,6 +271,7 @@
266271
'labels': set({
267272
}),
268273
'name': None,
274+
'object_id_base': 'Battery',
269275
'options': dict({
270276
}),
271277
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -315,6 +321,7 @@
315321
'labels': set({
316322
}),
317323
'name': None,
324+
'object_id_base': 'Battery',
318325
'options': dict({
319326
}),
320327
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -364,6 +371,7 @@
364371
'labels': set({
365372
}),
366373
'name': None,
374+
'object_id_base': 'Battery',
367375
'options': dict({
368376
}),
369377
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -413,6 +421,7 @@
413421
'labels': set({
414422
}),
415423
'name': None,
424+
'object_id_base': 'Battery',
416425
'options': dict({
417426
}),
418427
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -462,6 +471,7 @@
462471
'labels': set({
463472
}),
464473
'name': None,
474+
'object_id_base': 'Battery',
465475
'options': dict({
466476
}),
467477
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
@@ -511,6 +521,7 @@
511521
'labels': set({
512522
}),
513523
'name': None,
524+
'object_id_base': 'Compressor state',
514525
'options': dict({
515526
}),
516527
'original_device_class': None,
@@ -559,6 +570,7 @@
559570
'labels': set({
560571
}),
561572
'name': None,
573+
'object_id_base': 'Cooling',
562574
'options': dict({
563575
}),
564576
'original_device_class': None,
@@ -607,6 +619,7 @@
607619
'labels': set({
608620
}),
609621
'name': None,
622+
'object_id_base': 'Cooling enabled',
610623
'options': dict({
611624
}),
612625
'original_device_class': None,
@@ -655,6 +668,7 @@
655668
'labels': set({
656669
}),
657670
'name': None,
671+
'object_id_base': 'DHW state',
658672
'options': dict({
659673
}),
660674
'original_device_class': None,
@@ -703,6 +717,7 @@
703717
'labels': set({
704718
}),
705719
'name': None,
720+
'object_id_base': 'Flame state',
706721
'options': dict({
707722
}),
708723
'original_device_class': None,
@@ -751,6 +766,7 @@
751766
'labels': set({
752767
}),
753768
'name': None,
769+
'object_id_base': 'Heating',
754770
'options': dict({
755771
}),
756772
'original_device_class': None,
@@ -799,6 +815,7 @@
799815
'labels': set({
800816
}),
801817
'name': None,
818+
'object_id_base': 'Secondary boiler state',
802819
'options': dict({
803820
}),
804821
'original_device_class': None,
@@ -847,6 +864,7 @@
847864
'labels': set({
848865
}),
849866
'name': None,
867+
'object_id_base': 'Plugwise notification',
850868
'options': dict({
851869
}),
852870
'original_device_class': None,
@@ -895,6 +913,7 @@
895913
'labels': set({
896914
}),
897915
'name': None,
916+
'object_id_base': 'Plugwise notification',
898917
'options': dict({
899918
}),
900919
'original_device_class': None,

tests/components/plugwise/snapshots/test_button.ambr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
'labels': set({
2121
}),
2222
'name': None,
23+
'object_id_base': 'Reboot',
2324
'options': dict({
2425
}),
2526
'original_device_class': <ButtonDeviceClass.RESTART: 'restart'>,

0 commit comments

Comments
 (0)