Skip to content

Commit

Permalink
Merge pull request #356 from asantaga/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
msp1974 authored Mar 22, 2023
2 parents fff9112 + 193aacf commit f5edbaa
Show file tree
Hide file tree
Showing 19 changed files with 312 additions and 166 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Wiser Home Assistant Integration v3.3.0
# Wiser Home Assistant Integration v3.3.1

[![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 @@ -21,7 +21,6 @@ For more information checkout the AMAZING community thread available on
- Improved data in Wiser events
- Improved error handling for setting schedules from YAML files


## Contents

- [Minimum Requirements](#minimum-requirements)
Expand Down Expand Up @@ -523,14 +522,15 @@ The integration provides a wiser_event event name with types of boosted, started
max: 10
```


## Integration Automations

In order to extend the capability of this integration and simplify complex problems by not having to write complex automations, we have added a new concept of integration automations. Below are the current automations available with a description of how they work. Please note, you need to enable Integration Automations in the integration config.

### Passive Mode

An automation that allows you to set a room to only heat when other rooms are heating. This is only available for TRVs and not Heating Actuators. In each room will be a switch to enable/disable passive mode for that room. In passive mode, the room is actually set to manual to the min temp (set by the thermostat card). This allows the room to call for heat if the temp goes below the minimum. When it is detected that other (non-passive) rooms are requesting heat, the manual temp of the passive rooms is raised in 0.5C increments until it reaches the max temp. At any point, if all non-passive rooms are no longer calling for heat, the passive rooms are set back to their min temp.
An automation that allows you to set a room to only heat when other rooms are heating. This is only available for rooms with TRVs and not Heating Actuators. In each room will be a switch to set Passive Mode on or off for that room.

More detailed information on this automation is available [here](docs/inbuilt_automations.md)

## Schedule Card

Expand Down Expand Up @@ -619,6 +619,27 @@ There are two primary branches for this integration, `master` and `dev` . Master

## Change log

- 3.3.1
- Bump api to v1.3.1
- Added is_passive attribute to climate entity
- Added that away mode overrides passive mode
- Added config option to manage passive mode temperature increments
- Added hub update if built in automations make changes to hub to reflect current status immediately

- 3.3.1beta2
- Bump api to v1.3.0
- Breaking change - if you have installed and used passive mode in v3.3.1beta, this version will leave orphaned select entities that will need to be deleted manually.
- Reworking of passive mode to be based on the auto/heat/off HVAC modes with passive mode on/off switch
- Storage of the manual set temp in the (now existing) integration storage file to presist after a HA restart

- 3.3.1beta
- Bump api to v1.2.2
- Breaking change - added passive mode follow schedule which changes on/off switch for passive mode to selector for type of mode. Please note, there is a bug in the thermostat card (due to be fixed in an upcoming release of HA frontend) which causes the high temperature setting to not show correctly in Passive Follow Schedule mode if you try to change it manually.
- Breaking change - where the automations were enabled in v3.3.0, this willneed re-enabling in v3.3.1beta1 due to changes in the config configuration
- Allow boost override when in passive mode - issue [#348](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/348)
- Added additional opentherm parameters - issue [#337](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/337)
- Corrected error saving on/off schedule - issue [#349](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/349)

- 3.3.0
- Bump api to v1.0.2
- Add event data to wiser events - issue [#324](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/324)
Expand All @@ -635,7 +656,6 @@ There are two primary branches for this integration, `master` and `dev` . Master
- Added new passive mode for rooms with api smarts
- Improved repeater name on device signal entity - issue [#345](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/345)


- 3.2.2
- Bump api to v0.1.8
- v1.1.7 of schedule card
Expand Down Expand Up @@ -837,7 +857,7 @@ There are two primary branches for this integration, `master` and `dev` . Master
- 2.3
- Fix for error given by latest HA highlighting that I/O Detected in event loop - issue [#97](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/97)
- Fix for climate graph not showing true state - issue [#98](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/98)
- Fixed heating boost - issue [#101]([https://github.com/asantaga/wiserHomeAssistantPlatform/issues/101)
- Fixed heating boost - issue [#101](https://github.com/asantaga/wiserHomeAssistantPlatform/issues/101)

- 2.2
- Battery voltage across sensor types now consistent (1 decimal place no v)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wiser/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
]
)

if data.enable_moments and data.wiserhub.moments:
if data.wiserhub.moments:
_LOGGER.debug("Setting up Moments buttons")
for moment in data.wiserhub.moments.all:
wiser_buttons.append(WiserMomentsButton(data, moment.id))
Expand Down
101 changes: 42 additions & 59 deletions custom_components/wiser/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
STATUS_OVERRIDE = "Override"
STATUS_BLANK = ""

TEXT_PASSIVE = "Passive"

WISER_PRESET_TO_HASS = {
"FromAwayMode": STATUS_AWAY,
"FromManualMode": STATUS_BLANK,
Expand All @@ -64,7 +66,10 @@
"FromNoControl": STATUS_BLANK,
}

WISER_PRESETS = {"Advance Schedule": 0, "Cancel Overrides": 0}
WISER_PRESETS = {
"Advance Schedule": 0,
"Cancel Overrides": 0,
}
WISER_PRESETS.update(WISER_BOOST_PRESETS)

HVAC_MODE_WISER_TO_HASS = {
Expand All @@ -82,6 +87,9 @@
SUPPORT_FLAGS = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
PASSIVE_MODE_SUPPORT_FLAGS = (
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE | ClimateEntityFeature.PRESET_MODE
)


async def async_setup_entry(hass, config_entry, async_add_entities):
Expand Down Expand Up @@ -267,13 +275,17 @@ def __init__(self, hass, coordinator, room_id):
self._hvac_modes_list = [modes for modes in HVAC_MODE_HASS_TO_WISER.keys()]
self._is_heating = self._room.is_heating
self._schedule = self._room.schedule
self._previous_target_temp = self.current_temperature

# Set initial previous target temp based on config setting
if self._schedule and self._data.previous_target_temp_option == "Schedule":
self._previous_target_temp = self._room.schedule.current_setting
elif self._data.previous_target_temp_option == "Minimum":
self._previous_target_temp = TEMP_MINIMUM
# Set room stored manual target temp based on options (if not already set)
self._room.stored_manual_target_temperature_alt_source = (
self._data.previous_target_temp_option.lower()
)

# Set passive mode temperature increment value if enabled
if self._room.is_passive_mode:
self._room.passive_temperature_increment = (
self._data.passive_temperature_increment
)

_LOGGER.debug(f"{self._data.wiserhub.system.name} {self.name} initailise")

Expand All @@ -290,6 +302,7 @@ def _handle_coordinator_update(self) -> None:

if not self._room.is_boosted:
self._boosted_time = 0

self.async_write_ha_state()

fire_events(
Expand Down Expand Up @@ -335,35 +348,22 @@ def icon(self):
@property
def hvac_action(self):
"""Return hvac action from data."""
if self._room.mode == "Passive":
return "Passive Mode"
return HVACAction.HEATING if self._room.is_heating else HVACAction.IDLE

@property
def hvac_mode(self):
return (
None
if self._room.mode == "Passive"
else HVAC_MODE_WISER_TO_HASS[self._room.mode]
)
return HVAC_MODE_WISER_TO_HASS[self._room.mode]

@property
def hvac_modes(self):
"""Return the list of available operation modes."""
return None if self._room.mode == "Passive" else self._hvac_modes_list
return self._hvac_modes_list

async def async_set_hvac_mode(self, hvac_mode):
"""Set new operation mode."""
_LOGGER.debug(f"Setting HVAC mode to {hvac_mode} for {self._room.name}")
try:
if self.hvac_mode == HVACMode.HEAT and self.target_temperature != -20:

self._previous_target_temp = self._room.current_target_temperature

await self._room.set_mode(HVAC_MODE_HASS_TO_WISER[hvac_mode])
# Restore previous manual target temp when coming from Off mode back to Manual
if hvac_mode == HVACMode.HEAT and self._previous_target_temp:
await self._room.set_target_temperature(self._previous_target_temp)
await self.async_force_update()
return True
except KeyError:
Expand All @@ -388,10 +388,9 @@ def name(self):
def preset_mode(self):
"""Get current preset mode."""
try:
if (
WISER_PRESET_TO_HASS[self._room.target_temperature_origin]
== STATUS_BOOST
):
if self._room.is_passive_mode:
return TEXT_PASSIVE
elif self._room.preset_mode == "Boost":
if int(self._room.boost_time_remaining / 60) != 0:
return f"{STATUS_BOOST} {int(self._room.boost_time_remaining/60)}m"
else:
Expand All @@ -404,38 +403,22 @@ def preset_mode(self):
@property
def preset_modes(self):
"""Return the list of available preset modes."""
if not self._schedule:
return [
mode
for mode in list(WISER_PRESETS.keys())
if mode != "Advance Schedule"
]
return list(WISER_PRESETS.keys())
return self._room.available_presets

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Async call to set preset mode ."""
_LOGGER.debug(f"Setting Preset Mode {preset_mode} for {self._room.name}")
if preset_mode == "Advance Schedule":
await self._room.schedule_advance()
elif WISER_PRESETS[preset_mode] == 0:
await self._room.cancel_overrides()
elif preset_mode.startswith("Boost"):
boost_time = WISER_PRESETS[preset_mode]
boost_temp = self._data.boost_temp
await self._room.boost(boost_temp, boost_time)
else:
_LOGGER.error(f"Invalid preset mode. Options are {self.preset_modes}")
_LOGGER.info(f"Setting Preset Mode {preset_mode} for {self._room.name}")
try:
await self._room.set_preset(preset_mode)
except ValueError as ex:
_LOGGER.error(ex)

await self.async_force_update()

@property
def state(self):
"""Return state"""
return (
"Passive"
if self._room.mode == "Passive"
else HVAC_MODE_WISER_TO_HASS[self._room.mode]
)
return HVAC_MODE_WISER_TO_HASS[self._room.mode]

@property
def extra_state_attributes(self):
Expand All @@ -456,6 +439,7 @@ def extra_state_attributes(self):
attrs["is_boosted"] = self._room.is_boosted
attrs["is_override"] = self._room.is_override
attrs["is_heating"] = self._room.is_heating
attrs["is_passive"] = self._room.is_passive_mode
attrs["control_output_state"] = "On" if self._room.is_heating else "Off"
attrs["heating_rate"] = self._room.heating_rate

Expand Down Expand Up @@ -485,9 +469,7 @@ def extra_state_attributes(self):
def supported_features(self):
"""Return the list of supported features."""
return (
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
if self._room.mode == "Passive"
else SUPPORT_FLAGS
PASSIVE_MODE_SUPPORT_FLAGS if self._room.is_passive_mode else SUPPORT_FLAGS
)

@property
Expand All @@ -498,6 +480,10 @@ def target_temperature(self):
or self._room.current_target_temperature == TEMP_OFF
):
return None

# if self._is_passive_mode and not self._room.is_boosted:
# return None

return self._room.current_target_temperature

@property
Expand All @@ -521,19 +507,16 @@ def target_temperature_low(self) -> float | None:

async def async_set_temperature(self, **kwargs):
"""Set new target temperatures."""
if self._room.mode == "Passive":
_LOGGER.info(kwargs)
if self._room.is_passive_mode and not self._room.is_boosted:
if kwargs.get("target_temp_low", None):
await self._room.set_passive_mode_lower_temp(
kwargs.get("target_temp_low")
)
# await self._room.set_target_temperature(kwargs.get("target_temp_low"))
await self.async_force_update()

if kwargs.get("target_temp_high", None):
if kwargs.get("target_temp_high", None) and self.hvac_mode == HVACMode.HEAT:
await self._room.set_passive_mode_upper_temp(
kwargs.get("target_temp_high")
)
await self.async_force_update()
else:
target_temperature = kwargs.get(ATTR_TEMPERATURE)
if target_temperature is None:
Expand All @@ -554,7 +537,7 @@ async def async_set_temperature(self, **kwargs):
f"Setting temperature for {self.name} to {target_temperature}"
)
await self._room.set_target_temperature(target_temperature)
await self.async_force_update()
await self.async_force_update()
return True

@property
Expand Down
Loading

0 comments on commit f5edbaa

Please sign in to comment.