Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

Versions from 0.40 and up

## Ongoing
## v0.63.0

- Remove climate home-kit emulation option via PR [#1023](https://github.com/plugwise/plugwise-beta/pull/1023)
- Implement Core PR [#159626](https://github.com/home-assistant/core/pull/159626) via PR [#994](https://github.com/plugwise/plugwise-beta/pull/994)
- Chores
- Introduce prek (for pre-commit) & align with v2 gh-actions
Expand Down
55 changes: 10 additions & 45 deletions custom_components/plugwise/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
ATTR_HVAC_MODE,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
PRESET_AWAY, # pw-beta homekit emulation
PRESET_HOME, # pw-beta homekit emulation
ClimateEntity,
ClimateEntityFeature,
HVACAction,
Expand All @@ -32,7 +30,6 @@
ACTIVE_PRESET,
AVAILABLE_SCHEDULES,
CLIMATE_MODE,
CONF_HOMEKIT_EMULATION, # pw-beta homekit emulation
CONTROL_STATE,
DEV_CLASS,
DOMAIN,
Expand Down Expand Up @@ -65,9 +62,6 @@ async def async_setup_entry(
) -> None:
"""Set up Plugwise thermostats from a config entry."""
coordinator = entry.runtime_data
homekit_enabled: bool = entry.options.get(
CONF_HOMEKIT_EMULATION, False
) # pw-beta homekit emulation

@callback
def _add_entities() -> None:
Expand All @@ -82,16 +76,12 @@ def _add_entities() -> None:
if gateway_name == "Adam":
if device[DEV_CLASS] == "climate":
entities.append(
PlugwiseClimateEntity(
coordinator, device_id, homekit_enabled
) # pw-beta homekit emulation
PlugwiseClimateEntity(coordinator, device_id)
)
LOGGER.debug("Add climate %s", device[ATTR_NAME])
elif device[DEV_CLASS] in MASTER_THERMOSTATS:
entities.append(
PlugwiseClimateEntity(
coordinator, device_id, homekit_enabled
) # pw-beta homekit emulation
PlugwiseClimateEntity(coordinator, device_id)
)
LOGGER.debug("Add climate %s", device[ATTR_NAME])

Expand Down Expand Up @@ -135,7 +125,6 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity, RestoreEntity):

_last_active_schedule: str | None = None
_previous_action_mode: str | None = HVACAction.HEATING.value # Upstream
_homekit_mode: HVACMode | None = None # pw-beta homekit emulation + intentional unsort

async def async_added_to_hass(self) -> None:
"""Run when entity about to be added."""
Expand All @@ -152,14 +141,12 @@ def __init__(
self,
coordinator: PlugwiseDataUpdateCoordinator,
device_id: str,
homekit_enabled: bool, # pw-beta homekit emulation
) -> None:
"""Set up the Plugwise API."""
super().__init__(coordinator, device_id)

gateway_id: str = coordinator.api.gateway_id
self._gateway_data = coordinator.data[gateway_id]
self._homekit_enabled = homekit_enabled # pw-beta homekit emulation
self._location = device_id
if (location := self.device.get(LOCATION)) is not None:
self._location = location
Expand Down Expand Up @@ -239,20 +226,14 @@ def hvac_mode(self) -> HVACMode:
return HVACMode.HEAT # pragma: no cover
if hvac not in self.hvac_modes:
return HVACMode.HEAT # pragma: no cover
# pw-beta homekit emulation
if self._homekit_enabled and self._homekit_mode == HVACMode.OFF:
return HVACMode.OFF # pragma: no cover

return hvac

@property
def hvac_modes(self) -> list[HVACMode]:
"""Return a list of available HVACModes."""
hvac_modes: list[HVACMode] = []
if (
self._homekit_enabled # pw-beta homekit emulation
or REGULATION_MODES in self._gateway_data
):
if REGULATION_MODES in self._gateway_data:
hvac_modes.append(HVACMode.OFF)

if self.device.get(AVAILABLE_SCHEDULES, []):
Expand Down Expand Up @@ -319,10 +300,11 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
if hvac_mode == self.hvac_mode:
return

if hvac_mode != HVACMode.OFF:
if hvac_mode == HVACMode.OFF:
await self.coordinator.api.set_regulation_mode(hvac_mode.value)
else:
current = self.device.get("select_schedule")
desired = current

# Capture the last valid schedule
if desired and desired != "off":
self._last_active_schedule = desired
Expand All @@ -341,27 +323,10 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
STATE_ON if hvac_mode == HVACMode.AUTO else STATE_OFF,
desired,
)

await self._homekit_translate_or_not(hvac_mode) # pw-beta

async def _homekit_translate_or_not(self, mode: HVACMode) -> None:
"""Mimic HomeKit by setting a suitable preset, when homekit mode is enabled."""
if (
not self._homekit_enabled # pw-beta
):
if mode == HVACMode.OFF:
await self.coordinator.api.set_regulation_mode(mode.value)
elif self.hvac_mode == HVACMode.OFF and self._previous_action_mode:
await self.coordinator.api.set_regulation_mode(self._previous_action_mode)
else: # pw-beta
self._homekit_mode = mode # pragma: no cover
if self._homekit_mode == HVACMode.OFF: # pragma: no cover
await self.async_set_preset_mode(PRESET_AWAY) # pragma: no cover
if (
self._homekit_mode in [HVACMode.HEAT, HVACMode.HEAT_COOL]
and self.device.get(ACTIVE_PRESET) == PRESET_AWAY
): # pragma: no cover
await self.async_set_preset_mode(PRESET_HOME) # pragma: no cover
if self.hvac_mode == HVACMode.OFF and self._previous_action_mode:
await self.coordinator.api.set_regulation_mode(
self._previous_action_mode
)

@plugwise_command
async def async_set_preset_mode(self, preset_mode: str) -> None:
Expand Down
6 changes: 0 additions & 6 deletions custom_components/plugwise/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

from .const import (
ANNA_WITH_ADAM,
CONF_HOMEKIT_EMULATION, # pw-beta option
CONF_REFRESH_INTERVAL, # pw-beta option
DEFAULT_PORT,
DEFAULT_UPDATE_INTERVAL,
Expand Down Expand Up @@ -308,7 +307,6 @@ def async_get_options_flow(


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

if coordinator.api.smile.type == THERMOSTAT:
schema.update({
vol.Optional(
CONF_HOMEKIT_EMULATION,
default=self.options.get(CONF_HOMEKIT_EMULATION, False),
): vol.All(cv.boolean),
vol.Optional(
CONF_REFRESH_INTERVAL,
default=self.options.get(CONF_REFRESH_INTERVAL, 1.5),
Expand Down
2 changes: 1 addition & 1 deletion custom_components/plugwise/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"loggers": ["plugwise"],
"requirements": ["plugwise==1.11.2"],
"version": "0.62.2",
"version": "0.63.0",
"zeroconf": ["_plugwise._tcp.local."]
}
1 change: 0 additions & 1 deletion custom_components/plugwise/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
"init": {
"data": {
"cooling_on": "Anna: cooling-mode is on",
"homekit_emulation": "Homekit emulation (i.e. on hvac_off => Away) *) beta-only option",
"refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option",
"scan_interval": "Scan Interval (seconds) *) beta-only option"
},
Expand Down
1 change: 0 additions & 1 deletion custom_components/plugwise/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
"init": {
"data": {
"cooling_on": "Anna: cooling-mode is on",
"homekit_emulation": "Homekit emulation (i.e. on hvac_off => Away) *) beta-only option",
"refresh_interval": "Frontend refresh-time (1.5 - 5 seconds) *) beta-only option",
"scan_interval": "Scan Interval (seconds) *) beta-only option"
},
Expand Down
1 change: 0 additions & 1 deletion custom_components/plugwise/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@
"init": {
"data": {
"cooling_on": "Anna: koelmodus is aan",
"homekit_emulation": "Homekit emulatie (bij hvac_off => Afwezig) *) optie alleen in beta",
"refresh_interval": "Frontend ververs-tijd (1,5 - 5 seconden) *) optie alleen in beta",
"scan_interval": "Scan Interval (seconden) *) optie alleen in beta"
},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "plugwise-beta"
version = "0.62.2"
version = "0.63.0"
description = "Plugwise beta custom-component"
readme = "README.md"
requires-python = ">=3.13"
Expand Down
19 changes: 19 additions & 0 deletions tests/components/plugwise/snapshots/test_binary_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Plugwise notification',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -71,6 +72,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -120,6 +122,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -169,6 +172,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Heating',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -217,6 +221,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -266,6 +271,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -315,6 +321,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -364,6 +371,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -413,6 +421,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -462,6 +471,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
Expand Down Expand Up @@ -511,6 +521,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Compressor state',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -559,6 +570,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Cooling',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -607,6 +619,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Cooling enabled',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -655,6 +668,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'DHW state',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -703,6 +717,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Flame state',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -751,6 +766,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Heating',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -799,6 +815,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Secondary boiler state',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -847,6 +864,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Plugwise notification',
'options': dict({
}),
'original_device_class': None,
Expand Down Expand Up @@ -895,6 +913,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Plugwise notification',
'options': dict({
}),
'original_device_class': None,
Expand Down
1 change: 1 addition & 0 deletions tests/components/plugwise/snapshots/test_button.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'labels': set({
}),
'name': None,
'object_id_base': 'Reboot',
'options': dict({
}),
'original_device_class': <ButtonDeviceClass.RESTART: 'restart'>,
Expand Down
Loading
Loading