Skip to content

Commit aace678

Browse files
committed
Add frost protect preset with frost_temp.
1 parent 6a6c273 commit aace678

7 files changed

Lines changed: 134 additions & 7 deletions

File tree

custom_components/smart_thermostat/climate.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
_LOGGER = logging.getLogger(__name__)
6666

6767

68+
# Device is in frost guard mode
69+
PRESET_ANTI_FROST = "frost"
70+
6871
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
6972
{
7073
vol.Required(const.CONF_HEATER): cv.entity_ids,
@@ -103,6 +106,7 @@
103106
vol.Optional(const.CONF_PRESET_SYNC_MODE, default=const.DEFAULT_PRESET_SYNC_MODE): vol.In(
104107
['sync', 'none']
105108
),
109+
vol.Optional(const.CONF_ANTI_FROST_TEMP): vol.Coerce(float),
106110
vol.Optional(const.CONF_AWAY_TEMP): vol.Coerce(float),
107111
vol.Optional(const.CONF_ECO_TEMP): vol.Coerce(float),
108112
vol.Optional(const.CONF_BOOST_TEMP): vol.Coerce(float),
@@ -169,6 +173,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
169173
'output_safety': config.get(const.CONF_OUTPUT_SAFETY),
170174
'initial_hvac_mode': config.get(const.CONF_INITIAL_HVAC_MODE),
171175
'preset_sync_mode': config.get(const.CONF_PRESET_SYNC_MODE),
176+
'frost_temp': config.get(const.CONF_ANTI_FROST_TEMP),
172177
'away_temp': config.get(const.CONF_AWAY_TEMP),
173178
'eco_temp': config.get(const.CONF_ECO_TEMP),
174179
'boost_temp': config.get(const.CONF_BOOST_TEMP),
@@ -218,6 +223,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
218223
platform.async_register_entity_service( # type: ignore
219224
"set_preset_temp",
220225
{
226+
vol.Optional("frost_temp"): vol.Coerce(float),
227+
vol.Optional("frost_temp_disable"): vol.Coerce(bool),
221228
vol.Optional("away_temp"): vol.Coerce(float),
222229
vol.Optional("away_temp_disable"): vol.Coerce(bool),
223230
vol.Optional("eco_temp"): vol.Coerce(float),
@@ -244,6 +251,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
244251

245252
class SmartThermostat(ClimateEntity, RestoreEntity, ABC):
246253
"""Representation of a Smart Thermostat device."""
254+
_attr_translation_key = "smart_thermostat_translation"
247255

248256
def __init__(self, **kwargs):
249257
"""Initialize the thermostat."""
@@ -295,6 +303,7 @@ def __init__(self, **kwargs):
295303
self._support_flags |= ClimateEntityFeature.TURN_ON
296304
self._enable_turn_on_off_backwards_compatibility = False # Remove after deprecation period
297305
self._attr_preset_mode = 'none'
306+
self._frost_temp = kwargs.get('frost_temp')
298307
self._away_temp = kwargs.get('away_temp')
299308
self._eco_temp = kwargs.get('eco_temp')
300309
self._boost_temp = kwargs.get('boost_temp')
@@ -303,7 +312,8 @@ def __init__(self, **kwargs):
303312
self._sleep_temp = kwargs.get('sleep_temp')
304313
self._activity_temp = kwargs.get('activity_temp')
305314
self._preset_sync_mode = kwargs.get('preset_sync_mode')
306-
if True in [temp is not None for temp in [self._away_temp,
315+
if True in [temp is not None for temp in [self._frost_temp,
316+
self._away_temp,
307317
self._eco_temp,
308318
self._boost_temp,
309319
self._comfort_temp,
@@ -435,7 +445,7 @@ def _async_startup(*_):
435445
self.entity_id, self._target_temp)
436446
else:
437447
self._target_temp = float(old_state.attributes.get(ATTR_TEMPERATURE))
438-
for preset_mode in ['away_temp', 'eco_temp', 'boost_temp', 'comfort_temp', 'home_temp',
448+
for preset_mode in ['frost_temp', 'away_temp', 'eco_temp', 'boost_temp', 'comfort_temp', 'home_temp',
439449
'sleep_temp', 'activity_temp']:
440450
if old_state.attributes.get(preset_mode) is not None:
441451
setattr(self, f"_{preset_mode}", float(old_state.attributes.get(preset_mode)))
@@ -490,6 +500,10 @@ def _async_startup(*_):
490500
self._hvac_mode = HVACMode.OFF
491501
await self._async_control_heating(calc_pid=True)
492502

503+
@property
504+
def translation_key(self):
505+
return "smart_thermostat_translation"
506+
493507
@property
494508
def should_poll(self):
495509
"""Return the polling state."""
@@ -572,6 +586,7 @@ def preset_modes(self):
572586
def _preset_modes_temp(self):
573587
"""Return a list of preset modes and their temperatures"""
574588
return {
589+
PRESET_ANTI_FROST: self._frost_temp,
575590
PRESET_AWAY: self._away_temp,
576591
PRESET_ECO: self._eco_temp,
577592
PRESET_BOOST: self._boost_temp,
@@ -585,6 +600,7 @@ def _preset_modes_temp(self):
585600
def _preset_temp_modes(self):
586601
"""Return a list of preset temperature and their modes"""
587602
return {
603+
self._frost_temp: PRESET_ANTI_FROST,
588604
self._away_temp: PRESET_AWAY,
589605
self._eco_temp: PRESET_ECO,
590606
self._boost_temp: PRESET_BOOST,
@@ -656,6 +672,7 @@ def pid_control_output(self):
656672
def extra_state_attributes(self):
657673
"""attributes to include in entity"""
658674
device_state_attributes = {
675+
'frost_temp': self._frost_temp,
659676
'away_temp': self._away_temp,
660677
'eco_temp': self._eco_temp,
661678
'boost_temp': self._boost_temp,

custom_components/smart_thermostat/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
CONF_OUTPUT_SAFETY = 'output_safety'
4444
CONF_INITIAL_HVAC_MODE = "initial_hvac_mode"
4545
CONF_PRESET_SYNC_MODE = "preset_sync_mode"
46+
CONF_ANTI_FROST_TEMP = "frost_temp"
4647
CONF_AWAY_TEMP = "away_temp"
4748
CONF_ECO_TEMP = "eco_temp"
4849
CONF_BOOST_TEMP = "boost_temp"
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
{
2-
"services": {
3-
"clear_integral": "mdi:thermostat-cog",
4-
"set_pid_mode": "mdi:thermostat-cog",
5-
"set_pid_gain": "mdi:thermostat-cog",
6-
"set_preset_temp": "mdi:thermostat"
2+
"entity": {
3+
"climate": {
4+
"smart_thermostat_translation": {
5+
"state_attributes": {
6+
"preset_mode": {
7+
"default": "mdi:circle-medium",
8+
"state": {
9+
"activity": "mdi:motion-sensor",
10+
"away": "mdi:account-arrow-right",
11+
"boost": "mdi:rocket-launch",
12+
"comfort": "mdi:sofa",
13+
"eco": "mdi:leaf",
14+
"home": "mdi:home",
15+
"sleep": "mdi:bed",
16+
"frost": "mdi:snowflake-thermometer"
17+
}
18+
}
19+
}
20+
}
21+
}
722
}
823
}

custom_components/smart_thermostat/services.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ set_preset_temp:
8989
integration: smart_thermostat
9090
domain: climate
9191
fields:
92+
frost_temp:
93+
name: Frost Guard
94+
description: Frost Guard mode temperature
95+
required: false
96+
advanced: false
97+
example: 5.0
98+
selector:
99+
number:
100+
min: 0
101+
max: 95
102+
step: 0.1
103+
mode: slider
92104
away_temp:
93105
name: Away
94106
description: Away mode temperature
@@ -173,6 +185,14 @@ set_preset_temp:
173185
max: 95
174186
step: 0.1
175187
mode: slider
188+
frost_temp_disable:
189+
name: Disable anti-frost
190+
description: Disable the anti-frost mode temperature
191+
required: false
192+
advanced: false
193+
example: true
194+
selector:
195+
boolean:
176196
away_temp_disable:
177197
name: Disable away
178198
description: Disable the away mode temperature
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"title": "Coucou Smart Thermostat",
3+
"entity": {
4+
"climate": {
5+
"smart_thermostat_translation": {
6+
"state_attributes": {
7+
"preset_mode": {
8+
"name": "Preset",
9+
"state": {
10+
"none": "None",
11+
"eco": "Eco",
12+
"away": "Away",
13+
"boost": "Boost",
14+
"comfort": "Comfort",
15+
"home": "[%key:common::state::home%]",
16+
"sleep": "Sleep",
17+
"activity": "Activity",
18+
"frost": "Frost Protect"
19+
}
20+
},
21+
"preset_modes": {
22+
"name": "Presets"
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"entity": {
3+
"climate": {
4+
"smart_thermostat_translation": {
5+
"state_attributes": {
6+
"preset_mode": {
7+
"state": {
8+
"activity": "Activity",
9+
"away": "Away",
10+
"frost": "Frost Protect",
11+
"boost": "Boost",
12+
"comfort": "Comfort",
13+
"eco": "Eco",
14+
"home": "Home",
15+
"none": "None",
16+
"sleep": "Sleep"
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"entity": {
3+
"climate": {
4+
"smart_thermostat_translation": {
5+
"state_attributes": {
6+
"preset_mode": {
7+
"state": {
8+
"activity": "Activité",
9+
"away": "Absent",
10+
"frost": "Hors-gel",
11+
"boost": "Boost",
12+
"comfort": "Confort",
13+
"eco": "Eco",
14+
"home": "Présent",
15+
"none": "Aucun",
16+
"sleep": "Nuit"
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)