mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add preset modes to Touchline (#36054)
* Added preset modes. * Flake8 passed. * New and cleaner version. * isort fixed? * OrderedDict removed, constant OPERATION_LIST removed. * ClimateDevice changed to ClimateEntity * Two methods replaced with constants. * Update homeassistant/components/touchline/climate.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/touchline/climate.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/touchline/climate.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * All changes needed. * Cleaned up * Clean up Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
572d5a09cd
commit
317bd8ffd2
@ -1,6 +1,5 @@
|
|||||||
"""Platform for Roth Touchline heat pump controller."""
|
"""Platform for Roth Touchline floor heating controller."""
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from pytouchline import PyTouchline
|
from pytouchline import PyTouchline
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -8,6 +7,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
|
SUPPORT_PRESET_MODE,
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
SUPPORT_TARGET_TEMPERATURE,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, TEMP_CELSIUS
|
||||||
@ -15,7 +15,21 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE
|
PRESET_MODES = {
|
||||||
|
"Normal": {"mode": 0, "program": 0},
|
||||||
|
"Night": {"mode": 1, "program": 0},
|
||||||
|
"Holiday": {"mode": 2, "program": 0},
|
||||||
|
"Pro 1": {"mode": 0, "program": 1},
|
||||||
|
"Pro 2": {"mode": 0, "program": 2},
|
||||||
|
"Pro 3": {"mode": 0, "program": 3},
|
||||||
|
}
|
||||||
|
|
||||||
|
TOUCHLINE_HA_PRESETS = {
|
||||||
|
(settings["mode"], settings["program"]): preset
|
||||||
|
for preset, settings in PRESET_MODES.items()
|
||||||
|
}
|
||||||
|
|
||||||
|
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
|
||||||
|
|
||||||
@ -36,11 +50,13 @@ class Touchline(ClimateEntity):
|
|||||||
"""Representation of a Touchline device."""
|
"""Representation of a Touchline device."""
|
||||||
|
|
||||||
def __init__(self, touchline_thermostat):
|
def __init__(self, touchline_thermostat):
|
||||||
"""Initialize the climate device."""
|
"""Initialize the Touchline device."""
|
||||||
self.unit = touchline_thermostat
|
self.unit = touchline_thermostat
|
||||||
self._name = None
|
self._name = None
|
||||||
self._current_temperature = None
|
self._current_temperature = None
|
||||||
self._target_temperature = None
|
self._target_temperature = None
|
||||||
|
self._current_operation_mode = None
|
||||||
|
self._preset_mode = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
@ -48,26 +64,26 @@ class Touchline(ClimateEntity):
|
|||||||
return SUPPORT_FLAGS
|
return SUPPORT_FLAGS
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update unit attributes."""
|
"""Update thermostat attributes."""
|
||||||
self.unit.update()
|
self.unit.update()
|
||||||
self._name = self.unit.get_name()
|
self._name = self.unit.get_name()
|
||||||
self._current_temperature = self.unit.get_current_temperature()
|
self._current_temperature = self.unit.get_current_temperature()
|
||||||
self._target_temperature = self.unit.get_target_temperature()
|
self._target_temperature = self.unit.get_target_temperature()
|
||||||
|
self._preset_mode = TOUCHLINE_HA_PRESETS.get(
|
||||||
|
(self.unit.get_operation_mode(), self.unit.get_week_program())
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self):
|
||||||
"""Return hvac operation ie. heat, cool mode.
|
"""Return current HVAC mode.
|
||||||
|
|
||||||
Need to be one of HVAC_MODE_*.
|
Need to be one of HVAC_MODE_*.
|
||||||
"""
|
"""
|
||||||
return HVAC_MODE_HEAT
|
return HVAC_MODE_HEAT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self) -> List[str]:
|
def hvac_modes(self):
|
||||||
"""Return the list of available hvac operation modes.
|
"""Return list of possible operation modes."""
|
||||||
|
|
||||||
Need to be a subset of HVAC_MODES.
|
|
||||||
"""
|
|
||||||
return [HVAC_MODE_HEAT]
|
return [HVAC_MODE_HEAT]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -95,6 +111,25 @@ class Touchline(ClimateEntity):
|
|||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
return self._target_temperature
|
return self._target_temperature
|
||||||
|
|
||||||
|
@property
|
||||||
|
def preset_mode(self):
|
||||||
|
"""Return the current preset mode."""
|
||||||
|
return self._preset_mode
|
||||||
|
|
||||||
|
@property
|
||||||
|
def preset_modes(self):
|
||||||
|
"""Return available preset modes."""
|
||||||
|
return list(PRESET_MODES)
|
||||||
|
|
||||||
|
def set_preset_mode(self, preset_mode):
|
||||||
|
"""Set new target preset mode."""
|
||||||
|
self.unit.set_operation_mode(PRESET_MODES[preset_mode]["mode"])
|
||||||
|
self.unit.set_week_program(PRESET_MODES[preset_mode]["program"])
|
||||||
|
|
||||||
|
def set_hvac_mode(self, hvac_mode):
|
||||||
|
"""Set new target hvac mode."""
|
||||||
|
self._current_operation_mode = HVAC_MODE_HEAT
|
||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if kwargs.get(ATTR_TEMPERATURE) is not None:
|
if kwargs.get(ATTR_TEMPERATURE) is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user