Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 218 add hors gel #263

Merged
merged 2 commits into from
Dec 10, 2023
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
25 changes: 21 additions & 4 deletions custom_components/versatile_thermostat/base_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
CONF_PRESENCE_SENSOR,
CONF_PRESET_POWER,
SUPPORT_FLAGS,
PRESET_FROST_PROTECTION,
PRESET_POWER,
PRESET_SECURITY,
PROPORTIONAL_FUNCTION_TPI,
Expand Down Expand Up @@ -148,9 +149,11 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
{
"is_on",
"type",
"frost_temp",
"eco_temp",
"boost_temp",
"comfort_temp",
"frost_away_temp",
"eco_away_temp",
"boost_away_temp",
"comfort_away_temp",
Expand Down Expand Up @@ -272,6 +275,9 @@ def post_init(self, entry_infos):
)

self._ac_mode = entry_infos.get(CONF_AC_MODE) is True
self._attr_max_temp = entry_infos.get(CONF_TEMP_MAX)
self._attr_min_temp = entry_infos.get(CONF_TEMP_MIN)

# convert entry_infos into usable attributes
presets = {}
items = CONF_PRESETS_WITH_AC.items() if self._ac_mode else CONF_PRESETS.items()
Expand All @@ -281,6 +287,9 @@ def post_init(self, entry_infos):
presets[key] = entry_infos.get(value)
else:
_LOGGER.debug("value %s not found in Entry", value)
presets[key] = (
self._attr_max_temp if self._ac_mode else self._attr_min_temp
)

presets_away = {}
items = (
Expand All @@ -294,6 +303,9 @@ def post_init(self, entry_infos):
presets_away[key] = entry_infos.get(value)
else:
_LOGGER.debug("value %s not found in Entry", value)
presets_away[key] = (
self._attr_max_temp if self._ac_mode else self._attr_min_temp
)

if self._window_call_cancel is not None:
self._window_call_cancel()
Expand All @@ -310,8 +322,6 @@ def post_init(self, entry_infos):
self._proportional_function = entry_infos.get(CONF_PROP_FUNCTION)
self._temp_sensor_entity_id = entry_infos.get(CONF_TEMP_SENSOR)
self._ext_temp_sensor_entity_id = entry_infos.get(CONF_EXTERNAL_TEMP_SENSOR)
self._attr_max_temp = entry_infos.get(CONF_TEMP_MAX)
self._attr_min_temp = entry_infos.get(CONF_TEMP_MIN)
# Default value not configurable
self._attr_target_temperature_step = 0.1
self._power_sensor_entity_id = entry_infos.get(CONF_POWER_SENSOR)
Expand Down Expand Up @@ -1105,9 +1115,12 @@ async def async_set_hvac_mode(self, hvac_mode, need_control_heating=True):
await under.set_hvac_mode(hvac_mode) or need_control_heating
)

# If AC is on maybe we have to change the temperature in force mode
# If AC is on maybe we have to change the temperature in force mode, but not in frost mode (there is no Frost protection possible in AC mode)
if self._ac_mode:
await self._async_set_preset_mode_internal(self._attr_preset_mode, True)
if self.preset_mode != PRESET_FROST_PROTECTION:
await self._async_set_preset_mode_internal(self._attr_preset_mode, True)
else:
await self._async_set_preset_mode_internal(PRESET_ECO, True)

if need_control_heating and sub_need_control_heating:
await self.async_control_heating(force=True)
Expand Down Expand Up @@ -2165,9 +2178,13 @@ def update_custom_attributes(self):
"hvac_mode": self.hvac_mode,
"preset_mode": self.preset_mode,
"type": self._thermostat_type,
"frost_temp": self._presets[PRESET_FROST_PROTECTION],
"eco_temp": self._presets[PRESET_ECO],
"boost_temp": self._presets[PRESET_BOOST],
"comfort_temp": self._presets[PRESET_COMFORT],
"frost_away_temp": self._presets_away.get(
self.get_preset_away_name(PRESET_FROST_PROTECTION)
),
"eco_away_temp": self._presets_away.get(
self.get_preset_away_name(PRESET_ECO)
),
Expand Down
4 changes: 2 additions & 2 deletions custom_components/versatile_thermostat/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ def __init__(self, infos) -> None:

self.STEP_PRESETS_DATA_SCHEMA = vol.Schema( # pylint: disable=invalid-name
{
vol.Optional(v, default=0.0): vol.Coerce(float)
vol.Optional(v, default=0): vol.Coerce(float)
for (k, v) in CONF_PRESETS.items()
}
)

self.STEP_PRESETS_WITH_AC_DATA_SCHEMA = ( # pylint: disable=invalid-name
vol.Schema( # pylint: disable=invalid-name
{
vol.Optional(v, default=0.0): vol.Coerce(float)
vol.Optional(v, default=0): vol.Coerce(float)
for (k, v) in CONF_PRESETS_WITH_AC.items()
}
)
Expand Down
13 changes: 12 additions & 1 deletion custom_components/versatile_thermostat/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

PRESET_POWER = "power"
PRESET_SECURITY = "security"
PRESET_FROST_PROTECTION = "frost"

HIDDEN_PRESETS = [PRESET_POWER, PRESET_SECURITY]

Expand Down Expand Up @@ -112,6 +113,7 @@
CONF_PRESETS = {
p: f"{p}_temp"
for p in (
PRESET_FROST_PROTECTION,
PRESET_ECO,
PRESET_COMFORT,
PRESET_BOOST,
Expand All @@ -121,6 +123,7 @@
CONF_PRESETS_WITH_AC = {
p: f"{p}_temp"
for p in (
PRESET_FROST_PROTECTION,
PRESET_ECO,
PRESET_COMFORT,
PRESET_BOOST,
Expand All @@ -136,6 +139,7 @@
CONF_PRESETS_AWAY = {
p: f"{p}_temp"
for p in (
PRESET_FROST_PROTECTION + PRESET_AWAY_SUFFIX,
PRESET_ECO + PRESET_AWAY_SUFFIX,
PRESET_COMFORT + PRESET_AWAY_SUFFIX,
PRESET_BOOST + PRESET_AWAY_SUFFIX,
Expand All @@ -145,6 +149,7 @@
CONF_PRESETS_AWAY_WITH_AC = {
p: f"{p}_temp"
for p in (
PRESET_FROST_PROTECTION + PRESET_AWAY_SUFFIX,
PRESET_ECO + PRESET_AWAY_SUFFIX,
PRESET_COMFORT + PRESET_AWAY_SUFFIX,
PRESET_BOOST + PRESET_AWAY_SUFFIX,
Expand All @@ -154,7 +159,12 @@
)
}

CONF_PRESETS_SELECTIONABLE = [PRESET_ECO, PRESET_COMFORT, PRESET_BOOST]
CONF_PRESETS_SELECTIONABLE = [
PRESET_FROST_PROTECTION,
PRESET_ECO,
PRESET_COMFORT,
PRESET_BOOST,
]

CONF_PRESETS_VALUES = list(CONF_PRESETS.values())
CONF_PRESETS_AWAY_VALUES = list(CONF_PRESETS_AWAY.values())
Expand Down Expand Up @@ -213,6 +223,7 @@
CONF_AUTO_REGULATION_DTEMP,
CONF_AUTO_REGULATION_PERIOD_MIN,
CONF_INVERSE_SWITCH,
CONF_AUTO_FAN_MODE,
]
+ CONF_PRESETS_VALUES
+ CONF_PRESETS_AWAY_VALUES
Expand Down
1 change: 1 addition & 0 deletions custom_components/versatile_thermostat/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set_preset_temperature:
- "eco"
- "comfort"
- "boost"
- "frost"
- "eco_ac"
- "comfort_ac"
- "boost_ac"
Expand Down
31 changes: 31 additions & 0 deletions custom_components/versatile_thermostat/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,19 @@
"title": "Presets",
"description": "For each preset set the target temperature (0 to ignore preset)",
"data": {
"eco_temp": "Eco preset",
"comfort_temp": "Comfort preset",
"boost_temp": "Boost preset",
"frost_temp": "Frost protection preset",
"eco_ac_temp": "Eco preset for AC mode",
"comfort_ac_temp": "Comfort preset for AC mode",
"boost_ac_temp": "Boost preset for AC mode"
},
"data_description": {
"eco_temp": "Temperature in Eco preset",
"comfort_temp": "Temperature in Comfort preset",
"boost_temp": "Temperature in Boost preset",
"frost_temp": "Temperature in Frost protection preset",
"eco_ac_temp": "Temperature in Eco preset for AC mode",
"comfort_ac_temp": "Temperature in Comfort preset for AC mode",
"boost_ac_temp": "Temperature in Boost preset for AC mode"
Expand Down Expand Up @@ -136,10 +146,21 @@
"title": "Presence management",
"description": "Presence management attributes.\nGives the a presence sensor of your home (true is someone is present).\nThen specify either the preset to use when presence sensor is false or the offset in temperature to apply.\nIf preset is given, the offset will not be used.\nLeave corresponding entity_id empty if not used.",
"data": {
"presence_sensor_entity_id": "Presence sensor",
"eco_away_temp": "Eco preset",
"comfort_away_temp": "Comfort preset",
"boost_away_temp": "Boost preset",
"frost_away_temp": "Frost protection preset",
"eco_ac_away_temp": "Eco preset in AC mode",
"comfort_ac_away_temp": "Comfort preset in AC mode",
"boost_ac_away_temp": "Boost pres et in AC mode"
},
"data_description": {
"presence_sensor_entity_id": "Presence sensor entity id",
"eco_away_temp": "Temperature in Eco preset when no presence",
"comfort_away_temp": "Temperature in Comfort preset when no presence",
"boost_away_temp": "Temperature in Boost preset when no presence",
"frost_away_temp": "Temperature in Frost protection preset when no presence",
"eco_ac_away_temp": "Temperature in Eco preset when no presence in AC mode",
"comfort_ac_away_temp": "Temperature in Comfort preset when no presence in AC mode",
"boost_ac_away_temp": "Temperature in Boost preset when no presence in AC mode"
Expand Down Expand Up @@ -250,9 +271,19 @@
"title": "Presets",
"description": "For each preset set the target temperature (0 to ignore preset)",
"data": {
"eco_temp": "Eco preset",
"comfort_temp": "Comfort preset",
"boost_temp": "Boost preset",
"frost_temp": "Frost protection preset",
"eco_ac_temp": "Eco preset for AC mode",
"comfort_ac_temp": "Comfort preset for AC mode",
"boost_ac_temp": "Boost preset for AC mode"
},
"data_description": {
"eco_temp": "Temperature in Eco preset",
"comfort_temp": "Temperature in Comfort preset",
"boost_temp": "Temperature in Boost preset",
"frost_temp": "Temperature in Frost protection preset",
"eco_ac_temp": "Temperature in Eco preset for AC mode",
"comfort_ac_temp": "Temperature in Comfort preset for AC mode",
"boost_ac_temp": "Temperature in Boost preset for AC mode"
Expand Down
18 changes: 15 additions & 3 deletions custom_components/versatile_thermostat/thermostat_climate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=line-too-long
# pylint: disable=line-too-long, too-many-lines
""" A climate over switch classe """
import logging
from datetime import timedelta, datetime
Expand Down Expand Up @@ -65,7 +65,11 @@ class ThermostatOverClimate(BaseThermostat):
_auto_regulation_dtemp: float = None
_auto_regulation_period_min: int = None
_last_regulation_change: datetime = None
# The fan mode configured in configEntry
_auto_fan_mode: str = None
# The current fan mode (could be change by service call)
_current_auto_fan_mode: str = None
# The fan_mode name depending of the current_mode
_auto_activated_fan_mode: str = None
_auto_deactivated_fan_mode: str = None

Expand All @@ -82,6 +86,7 @@ class ThermostatOverClimate(BaseThermostat):
"regulation_accumulated_error",
"auto_regulation_mode",
"auto_fan_mode",
"current_auto_fan_mode",
"auto_activated_fan_mode",
"auto_deactivated_fan_mode",
}
Expand Down Expand Up @@ -350,6 +355,8 @@ def choose_auto_regulation_mode(self, auto_regulation_mode):
def choose_auto_fan_mode(self, auto_fan_mode):
"""Choose the correct fan mode depending of the underlying capacities and the configuration"""

self._current_auto_fan_mode = auto_fan_mode

# Get the supported feature of the first underlying. We suppose each underlying have the same fan attributes
fan_supported = self.supported_features & ClimateEntityFeature.FAN_MODE > 0

Expand Down Expand Up @@ -382,8 +389,9 @@ def find_fan_mode(fan_modes, fan_mode) -> str:
break

_LOGGER.info(
"%s - choose_auto_fan_mode founds auto_activated_fan_mode=%s and auto_deactivated_fan_mode=%s",
"%s - choose_auto_fan_mode founds current_auto_fan_mode=%s auto_activated_fan_mode=%s and auto_deactivated_fan_mode=%s",
self,
self._current_auto_fan_mode,
self._auto_activated_fan_mode,
self._auto_deactivated_fan_mode,
)
Expand Down Expand Up @@ -463,9 +471,14 @@ def update_custom_attributes(self):
] = self._regulation_algo.accumulated_error

self._attr_extra_state_attributes["auto_fan_mode"] = self.auto_fan_mode
self._attr_extra_state_attributes[
"current_auto_fan_mode"
] = self._current_auto_fan_mode

self._attr_extra_state_attributes[
"auto_activated_fan_mode"
] = self._auto_activated_fan_mode

self._attr_extra_state_attributes[
"auto_deactivated_fan_mode"
] = self._auto_deactivated_fan_mode
Expand Down Expand Up @@ -987,5 +1000,4 @@ async def service_set_auto_fan_mode(self, auto_fan_mode):
elif auto_fan_mode == "Turbo":
self.choose_auto_fan_mode(CONF_AUTO_FAN_TURBO)

await self._send_regulated_temperature()
self.update_custom_attributes()
4 changes: 4 additions & 0 deletions custom_components/versatile_thermostat/translations/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"eco_temp": "Θερμοκρασία στο προκαθορισμένο Eco",
"comfort_temp": "Θερμοκρασία στο προκαθορισμένο Comfort",
"boost_temp": "Θερμοκρασία στο προκαθορισμένο Boost",
"frost_temp": "Θερμοκρασία στο προκαθορισμένο Frost protection",
"eco_ac_temp": "Θερμοκρασία στο προκαθορισμένο Eco για λειτουργία AC",
"comfort_ac_temp": "Θερμοκρασία στο προκαθορισμένο Comfort για λειτουργία AC",
"boost_ac_temp": "Θερμοκρασία στο προκαθορισμένο Boost για λειτουργία AC"
Expand Down Expand Up @@ -140,6 +141,7 @@
"eco_away_temp": "Θερμοκρασία στο προκαθορισμένο Eco όταν δεν υπάρχει παρουσία",
"comfort_away_temp": "Θερμοκρασία στο προκαθορισμένο Comfort όταν δεν υπάρχει παρουσία",
"boost_away_temp": "Θερμοκρασία στο προκαθορισμένο Boost όταν δεν υπάρχει παρουσία",
"frost_away_temp": "Θερμοκρασία στο προκαθορισμένο Frost protection όταν δεν υπάρχει παρουσία",
"eco_ac_away_temp": "Θερμοκρασία στο προκαθορισμένο Eco όταν δεν υπάρχει παρουσία σε λειτουργία AC",
"comfort_ac_away_temp": "Θερμοκρασία στο προκαθορισμένο Comfort όταν δεν υπάρχει παρουσία σε λειτουργία AC",
"boost_ac_away_temp": "Θερμοκρασία στο προκαθορισμένο Boost όταν δεν υπάρχει παρουσία σε λειτουργία AC"
Expand Down Expand Up @@ -253,6 +255,7 @@
"eco_temp": "Θερμοκρασία στην οικονομική προεπιλογή",
"comfort_temp": "Θερμοκρασία στην άνετη προεπιλογή",
"boost_temp": "Θερμοκρασία στην ενισχυμένη προεπιλογή",
"frost_temp": "Θερμοκρασία στο προκαθορισμένο Frost protection",
"eco_ac_temp": "Θερμοκρασία στην οικονομική προεπιλογή για τη λειτουργία AC",
"comfort_ac_temp": "Θερμοκρασία στην άνετη προεπιλογή για τη λειτουργία AC",
"boost_ac_temp": "Θερμοκρασία στην ενισχυμένη προεπιλογή για τη λειτουργία AC"
Expand Down Expand Up @@ -311,6 +314,7 @@
"eco_away_temp": "Θερμοκρασία στο πρόγραμμα Eco όταν δεν υπάρχει παρουσία",
"comfort_away_temp": "Θερμοκρασία στο πρόγραμμα Comfort όταν δεν υπάρχει παρουσία",
"boost_away_temp": "Θερμοκρασία στο πρόγραμμα Boost όταν δεν υπάρχει παρουσία",
"frost_away_temp": "Θερμοκρασία στο προκαθορισμένο Frost protection όταν δεν υπάρχει παρουσία",
"eco_ac_away_temp": "Θερμοκρασία στο πρόγραμμα Eco όταν δεν υπάρχει παρουσία σε λειτουργία AC",
"comfort_ac_away_temp": "Θερμοκρασία στο πρόγραμμα Comfort όταν δεν υπάρχει παρουσία σε λειτουργία AC",
"boost_ac_away_temp": "Θερμοκρασία στο πρόγραμμα Boost όταν δεν υπάρχει παρουσία σε λειτουργία AC"
Expand Down
Loading