Skip to content

Commit

Permalink
Merge pull request #548 from asantaga/dev
Browse files Browse the repository at this point in the history
v3.4.15
  • Loading branch information
msp1974 authored Dec 11, 2024
2 parents 26a7fee + f09b25c commit 38bcc2c
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 30 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Wiser Home Assistant Integration v3.4.14
# Wiser Home Assistant Integration v3.4.15

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
[![downloads](https://shields.io/github/downloads/asantaga/wiserHomeAssistantPlatform/latest/total?style=for-the-badge)](https://github.com/asantaga/wiserHomeAssistantPlatform)
Expand All @@ -20,7 +20,7 @@ For more information checkout the AMAZING community thread available on
## What's New in 3.4?

- Added support for v2 hub
- Added PowerTagE support
- Added support for many new v2 hub devices
- Climate entity for controlling hot water with external tank temp sensor

## Installing
Expand All @@ -29,6 +29,13 @@ For more information checkout the AMAZING community thread available on

## Change log

- v3.4.15
- Added experimental hw climate mode to operate differently. See wiki for details
- Changed min/max hw climate temp range from 40-80C to 10-80C - issue [#545](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/545)
- Fixed issue whereby hw climate errors if temp sensor not available after HA start - issue [#541](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/541)
- Fixed issue whereby hw climate config requires some entry in the temp sensor select option, even if not enabled - issue [#544](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/544)
- Fixed issue whereby hw min does not change when setting both via service call if temps are 1C or less different - issue [#547](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/547)

- v3.4.14
- Fixed issue causing integration not to load in some circumstances due to failed config entry migration - issue #539
- Added binary sensor active state sensor
Expand Down
43 changes: 33 additions & 10 deletions custom_components/wiser/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ class WiserHotWater(CoordinatorEntity, ClimateEntity, WiserScheduleEntity):
"""WiserHotWater ClientEntity Object."""

_enable_turn_on_off_backwards_compatibility = False
_attr_translation_key = "wiser"

def __init__(self, hass: HomeAssistant, coordinator) -> None:
"""Initialize the sensor."""
Expand All @@ -744,7 +745,11 @@ def __init__(self, hass: HomeAssistant, coordinator) -> None:
self._boost_keep_cycling: bool = True
# Prevent hot water turning on if in heat mode at restart
# requires manual turn on to start if not already on
if self.hvac_mode == HVACMode.HEAT and not self._hotwater.manual_heat:
if (
self.hvac_mode == HVACMode.HEAT
and not self._hotwater.manual_heat
and not self._data.hw_climate_experimental_mode
):
self._keep_cycling = False

_LOGGER.debug("%s %s initiliase", self._data.wiserhub.system.name, self.name)
Expand Down Expand Up @@ -785,7 +790,9 @@ def _handle_coordinator_update(self) -> None:
_LOGGER.debug("%s updating", self.name)

previous_hotwater_values = self._hotwater
previous_hotwater_values._current_temperature = self.current_temperature
self._hotwater = self._data.wiserhub.hotwater
self._hotwater._current_temperature = self.current_temperature
self._schedule = self.hotwater.schedule

if not self.hotwater.is_boosted:
Expand Down Expand Up @@ -850,26 +857,24 @@ def target_temperature_step(self) -> float | None:
@property
def target_temperature_high(self):
"""Return target temp."""
if self.hvac_mode == HVACMode.OFF:
return None

return self.hotwater.current_target_temperature_high

@property
def target_temperature_low(self):
"""Return target temp."""
if self.hvac_mode == HVACMode.OFF:
return None

return self.hotwater.current_target_temperature_low

async def async_set_temperature(self, **kwargs):
"""Set new target temperatures."""
if high_temp := kwargs.get("target_temp_high"):
await self.hotwater.set_target_temperature_high(high_temp)
if low_temp := kwargs.get("target_temp_low"):
# Low must be a minimum of 1C below high to prevent oscillating on/off
if self.target_temperature_high - low_temp < 1:
low_temp = self.target_temperature_high - 1
await self.hotwater.set_target_temperature_low(low_temp)
if high_temp := kwargs.get("target_temp_high"):
await self.hotwater.set_target_temperature_high(high_temp)
_LOGGER.debug(
"Setting temperature range for %s to between %s and %s",
self.name,
Expand Down Expand Up @@ -900,6 +905,7 @@ async def async_set_hvac_mode(self, hvac_mode):
_LOGGER.debug("Setting HVAC mode to %s for Hot Water", hvac_mode)
try:
await self.hotwater.set_mode(HVAC_MODE_HASS_TO_WISER[hvac_mode])
self._keep_cycling = True
await self.async_force_update()
except KeyError:
_LOGGER.error("Invalid HVAC mode. Options are %s", self.hvac_modes)
Expand All @@ -923,7 +929,7 @@ def preset_mode(self):
@property
def preset_modes(self):
"""Return the list of available preset modes."""
return [mode.value for mode in WiserPresetOptionsEnum]
return self.hotwater.available_presets

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Async call to set preset mode ."""
Expand All @@ -937,6 +943,8 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:
await self.hotwater.schedule_advance()
elif preset_mode.lower().startswith(TEXT_BOOST.lower()):
# Lookup boost duration
self._keep_cycling = True

duration = WISER_BOOST_DURATION[preset_mode]
_LOGGER.info("Boosting for %s", duration)
# If temp is already above target, set boost but with off value
Expand Down Expand Up @@ -1042,6 +1050,12 @@ async def run_automation(self) -> bool:
# into manual mode.
return False

if not self.current_temperature:
# No current temp sensor providing value yet
# return
_LOGGER.debug("No value from current temperature sensor")
return False

# Reasons it should heat
if self.current_temperature <= self.target_temperature_low or (
self.current_temperature <= self.target_temperature_high
Expand All @@ -1055,7 +1069,10 @@ async def run_automation(self) -> bool:

if self.hvac_mode == HVACMode.HEAT:
# Manual mode heat is set to off
if not self.hotwater.manual_heat:
if (
self.data.hw_climate_experimental_mode is False
and not self.hotwater.manual_heat
):
should_heat = False
elif self.hvac_mode == HVACMode.AUTO:
# Schedule is set to off
Expand Down Expand Up @@ -1101,7 +1118,13 @@ async def run_automation(self) -> bool:

# Heat mode - reset manual heat
if self.hvac_mode == HVACMode.HEAT:
await self.hotwater.set_manual_heat(False)
if self.data.hw_climate_experimental_mode:
await self.hotwater.set_mode(
HVAC_MODE_HASS_TO_WISER[HVACMode.OFF]
)

else:
await self.hotwater.set_manual_heat(False)

await self.hotwater.override_state("Off")
updated = True
Expand Down
9 changes: 8 additions & 1 deletion custom_components/wiser/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
CONF_AUTOMATIONS_HW_AUTO_MODE,
CONF_AUTOMATIONS_HW_BOOST_MODE,
CONF_AUTOMATIONS_HW_CLIMATE,
CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL,
CONF_AUTOMATIONS_HW_HEAT_MODE,
CONF_AUTOMATIONS_HW_SENSOR_ENTITY_ID,
CONF_AUTOMATIONS_PASSIVE,
Expand Down Expand Up @@ -373,10 +374,16 @@ async def async_step_automation_params(self, user_input=None):
CONF_AUTOMATIONS_HW_CLIMATE, False
),
): bool,
vol.Optional(
CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL,
default=options.get(CONF_AUTOMATIONS_HW_CLIMATE, {}).get(
CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL, False
),
): bool,
vol.Optional(
CONF_AUTOMATIONS_HW_SENSOR_ENTITY_ID,
default=options.get(CONF_AUTOMATIONS_HW_CLIMATE, {}).get(
CONF_AUTOMATIONS_HW_SENSOR_ENTITY_ID
CONF_AUTOMATIONS_HW_SENSOR_ENTITY_ID, "sensor.no_sensor"
),
): EntitySelector(
EntitySelectorConfig(
Expand Down
9 changes: 4 additions & 5 deletions custom_components/wiser/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Constants for Wiser Platform.
"""Constants for Wiser Platform.
https://github.com/asantaga/wiserHomeAssistantPlatform
[email protected]
Expand All @@ -8,8 +7,7 @@

from enum import StrEnum


VERSION = "3.4.14"
VERSION = "3.4.15"
DOMAIN = "wiser"
DATA_WISER_CONFIG = "wiser_config"
URL_BASE = "/wiser"
Expand Down Expand Up @@ -72,7 +70,7 @@ class HWCycleModes(StrEnum):
DEFAULT_HW_AUTO_MODE = HWCycleModes.CONTINUOUS
DEFAULT_HW_HEAT_MODE = HWCycleModes.CONTINUOUS
DEFAULT_HW_BOOST_MODE = HWCycleModes.CONTINUOUS
HW_CLIMATE_MIN_TEMP = 40
HW_CLIMATE_MIN_TEMP = 10
HW_CLIMATE_MAX_TEMP = 80

# Setpoint Modes
Expand All @@ -89,6 +87,7 @@ class HWCycleModes(StrEnum):
CONF_HOSTNAME = "hostname"
CONF_RESTORE_MANUAL_TEMP_OPTION = "restore_manual_temp_option"
CONF_AUTOMATIONS_HW_CLIMATE = "automations_hw_climate"
CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL = "experimental_mode"
CONF_AUTOMATIONS_HW_AUTO_MODE = "hotwater_auto_mode"
CONF_AUTOMATIONS_HW_CLIMATE = "hotwater_climate"
CONF_AUTOMATIONS_HW_HEAT_MODE = "hotwater_heat_mode"
Expand Down
4 changes: 4 additions & 0 deletions custom_components/wiser/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
CONF_AUTOMATIONS_HW_SENSOR_ENTITY_ID,
CONF_AUTOMATIONS_PASSIVE,
CONF_AUTOMATIONS_PASSIVE_TEMP_INCREMENT,
CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL,
CONF_HEATING_BOOST_TEMP,
CONF_HEATING_BOOST_TIME,
CONF_HW_BOOST_TIME,
Expand Down Expand Up @@ -153,6 +154,9 @@ def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
self.hw_boost_mode = config_entry.options.get(
CONF_AUTOMATIONS_HW_CLIMATE, {}
).get(CONF_AUTOMATIONS_HW_BOOST_MODE, DEFAULT_HW_BOOST_MODE)
self.hw_climate_experimental_mode = config_entry.options.get(
CONF_AUTOMATIONS_HW_CLIMATE, {}
).get(CONF_AUTOMATIONS_HW_CLIMATE_EXPERIMENTAL, False)

self.wiserhub = WiserAPI(
host=config_entry.data[CONF_HOST],
Expand Down
12 changes: 10 additions & 2 deletions custom_components/wiser/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
DOMAIN_CLIMATE: [
"current_temperature",
"current_target_temperature",
"current_target_temperature_high",
"current_target_temperature_low",
"is_boosted",
"is_heating",
"boost_time_remaining",
Expand Down Expand Up @@ -105,9 +107,15 @@ def fire_events(hass: HomeAssistant, entity_id: str, old_state: dict, new_state:

if event_data:
for attr in event_data:
if hasattr(old_state, attr):
if (
hasattr(old_state, attr)
and getattr(old_state, attr) is not None
):
old_state_attr[attr] = getattr(old_state, attr)
if hasattr(new_state, attr):
if (
hasattr(new_state, attr)
and getattr(old_state, attr) is not None
):
new_state_attr[attr] = getattr(new_state, attr)

if old_state_attr:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wiser/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/asantaga/wiserHomeAssistantPlatform/issues",
"requirements": [
"aioWiserHeatAPI==1.6.4"
"aioWiserHeatAPI==1.6.5"
],
"version": "3.4.14",
"version": "3.4.15",
"zeroconf": [
{
"type": "_http._tcp.local.",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wiser/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
data = hass.data[DOMAIN][config_entry.entry_id][DATA]
wiser_selects = []

if data.wiserhub.hotwater:
if data.wiserhub.hotwater and not data.enable_hw_climate:
_LOGGER.debug("Setting up Hot Water mode select")
wiser_selects.extend([WiserHotWaterModeSelect(data)])

Expand Down
2 changes: 1 addition & 1 deletion custom_components/wiser/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
)

# Add hw climate switches
if data.enable_hw_climate:
if data.enable_hw_climate and not data.hw_climate_experimental_mode:
wiser_switches.append(WiserHWClimateManualHeatSwitch(data, 0, "Manual Heat"))

async_add_entities(wiser_switches)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wiser/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
"description": "Warmwasser-Klimaparameter",
"data": {
"hotwater_climate": "Aktivieren Sie die Climate-Entität",
"experimental_mode": "Aktivieren Sie den experimentellen Arbeitsmodus",
"hotwater_auto_mode": "Warmwasser-Automatikmodus",
"hotwater_heat_mode": "Warmwasser-Heizmodus",
"hotwater_sensor_entity_id": "Warmwasser-Temperatursensor",
"hotwater_target_temperature": "Standard-Warmwasser-Zieltemperatur"
"hotwater_sensor_entity_id": "Warmwasser-Temperatursensor"
}
},
"automation_params": {
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wiser/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
"description": "Enable Hot Water climate control. See wiki for how it works",
"data": {
"hotwater_climate": "Enable The Climate Entity",
"experimental_mode": "Enable experimental working mode",
"hotwater_auto_mode": "Hot Water Auto Mode",
"hotwater_heat_mode": "Hot Water Heat Mode",
"hotwater_boost_mode": "Hot Water Boost Mode",
"hotwater_sensor_entity_id": "Hot Water Temperature Sensor",
"hotwater_target_temperature": "Default Hot Water Target Temperature (°C)"
"hotwater_sensor_entity_id": "Hot Water Temperature Sensor"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wiser/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
"description": "Paramètres climatiques de l'eau chaude",
"data": {
"hotwater_climate": "Activer l'entité climatique",
"experimental_mode": "Activer le mode de travail expérimental",
"hotwater_auto_mode": "Mode automatique d'eau chaude",
"hotwater_heat_mode": "Mode de chauffage de l'eau chaude",
"hotwater_sensor_entity_id": "Capteur de température d'eau chaude",
"hotwater_schedule_mode": "Mode de programmation d'eau chaude",
"hotwater_target_temperature": "Défaulttempérature cible de l'eau chaud"
"hotwater_schedule_mode": "Mode de programmation d'eau chaude"
}
},
"automation_params": {
Expand Down

0 comments on commit 38bcc2c

Please sign in to comment.