mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Merge pull request #227 from balloob/thermostat
Custom min/max temperature for thermostat
This commit is contained in:
commit
d33af6e83e
@ -11,7 +11,7 @@ from homeassistant.helpers.entity_component import EntityComponent
|
|||||||
import homeassistant.util as util
|
import homeassistant.util as util
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF)
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, TEMP_CELCIUS)
|
||||||
|
|
||||||
DOMAIN = "thermostat"
|
DOMAIN = "thermostat"
|
||||||
DEPENDENCIES = []
|
DEPENDENCIES = []
|
||||||
@ -24,6 +24,8 @@ SERVICE_SET_TEMPERATURE = "set_temperature"
|
|||||||
|
|
||||||
ATTR_CURRENT_TEMPERATURE = "current_temperature"
|
ATTR_CURRENT_TEMPERATURE = "current_temperature"
|
||||||
ATTR_AWAY_MODE = "away_mode"
|
ATTR_AWAY_MODE = "away_mode"
|
||||||
|
ATTR_MAX_TEMP = "max_temp"
|
||||||
|
ATTR_MIN_TEMP = "min_temp"
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -131,6 +133,9 @@ class ThermostatDevice(Entity):
|
|||||||
if device_attr is not None:
|
if device_attr is not None:
|
||||||
data.update(device_attr)
|
data.update(device_attr)
|
||||||
|
|
||||||
|
data[ATTR_MIN_TEMP] = self.min_temp
|
||||||
|
data[ATTR_MAX_TEMP] = self.max_temp
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -162,3 +167,13 @@ class ThermostatDevice(Entity):
|
|||||||
def turn_away_mode_off(self):
|
def turn_away_mode_off(self):
|
||||||
""" Turns away mode off. """
|
""" Turns away mode off. """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def min_temp(self):
|
||||||
|
""" Return minimum temperature. """
|
||||||
|
return self.hass.config.temperature(7, TEMP_CELCIUS)[0]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_temp(self):
|
||||||
|
""" Return maxmum temperature. """
|
||||||
|
return self.hass.config.temperature(35, TEMP_CELCIUS)[0]
|
||||||
|
@ -62,6 +62,7 @@ import logging
|
|||||||
import datetime
|
import datetime
|
||||||
import homeassistant.components as core
|
import homeassistant.components as core
|
||||||
|
|
||||||
|
import homeassistant.util as util
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF
|
from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF
|
||||||
|
|
||||||
@ -90,16 +91,18 @@ class HeatControl(ThermostatDevice):
|
|||||||
self.target_sensor_entity_id = config.get("target_sensor")
|
self.target_sensor_entity_id = config.get("target_sensor")
|
||||||
|
|
||||||
self.time_temp = []
|
self.time_temp = []
|
||||||
|
if config.get("time_temp"):
|
||||||
for time_temp in list(config.get("time_temp").split(",")):
|
for time_temp in list(config.get("time_temp").split(",")):
|
||||||
time, temp = time_temp.split(':')
|
time, temp = time_temp.split(':')
|
||||||
time_start, time_end = time.split('-')
|
time_start, time_end = time.split('-')
|
||||||
start_time = datetime.datetime.time(datetime.datetime.
|
start_time = datetime.datetime.time(
|
||||||
strptime(time_start, '%H%M'))
|
datetime.datetime.strptime(time_start, '%H%M'))
|
||||||
end_time = datetime.datetime.time(datetime.datetime.
|
end_time = datetime.datetime.time(
|
||||||
strptime(time_end, '%H%M'))
|
datetime.datetime.strptime(time_end, '%H%M'))
|
||||||
self.time_temp.append((start_time, end_time, float(temp)))
|
self.time_temp.append((start_time, end_time, float(temp)))
|
||||||
|
|
||||||
self.min_temp = float(config.get("min_temp"))
|
self._min_temp = util.convert(config.get("min_temp"), float, 0)
|
||||||
|
self._max_temp = util.convert(config.get("max_temp"), float, 100)
|
||||||
|
|
||||||
self._manual_sat_temp = None
|
self._manual_sat_temp = None
|
||||||
self._away = False
|
self._away = False
|
||||||
@ -178,7 +181,7 @@ class HeatControl(ThermostatDevice):
|
|||||||
if not self._heater_manual_changed:
|
if not self._heater_manual_changed:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.set_temperature(100)
|
self.set_temperature(self.max_temp)
|
||||||
|
|
||||||
self._heater_manual_changed = True
|
self._heater_manual_changed = True
|
||||||
|
|
||||||
@ -194,3 +197,13 @@ class HeatControl(ThermostatDevice):
|
|||||||
def turn_away_mode_off(self):
|
def turn_away_mode_off(self):
|
||||||
""" Turns away mode off. """
|
""" Turns away mode off. """
|
||||||
self._away = False
|
self._away = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def min_temp(self):
|
||||||
|
""" Return minimum temperature. """
|
||||||
|
return self._min_temp
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_temp(self):
|
||||||
|
""" Return maxmum temperature. """
|
||||||
|
return self._max_temp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user