mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Custom min/max temperature for thermostat
This commit is contained in:
parent
e277decd4c
commit
cbb390a918
@ -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,22 @@ class ThermostatDevice(Entity):
|
|||||||
if device_attr is not None:
|
if device_attr is not None:
|
||||||
data.update(device_attr)
|
data.update(device_attr)
|
||||||
|
|
||||||
|
if hasattr(self, ATTR_MIN_TEMP):
|
||||||
|
min_temp = self.hass.config.temperature(
|
||||||
|
getattr(self, ATTR_MIN_TEMP), self.unit_of_measurement)[0]
|
||||||
|
else:
|
||||||
|
min_temp = self.hass.config.temperature(
|
||||||
|
7, TEMP_CELCIUS)[0]
|
||||||
|
data[ATTR_MIN_TEMP] = min_temp
|
||||||
|
|
||||||
|
if hasattr(self, ATTR_MAX_TEMP):
|
||||||
|
max_temp = self.hass.config.temperature(
|
||||||
|
getattr(self, ATTR_MAX_TEMP), self.unit_of_measurement)[0]
|
||||||
|
else:
|
||||||
|
max_temp = self.hass.config.temperature(
|
||||||
|
35, TEMP_CELCIUS)[0]
|
||||||
|
data[ATTR_MAX_TEMP] = max_temp
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -90,16 +90,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 = []
|
||||||
for time_temp in list(config.get("time_temp").split(",")):
|
if config.get("time_temp"):
|
||||||
time, temp = time_temp.split(':')
|
for time_temp in list(config.get("time_temp").split(",")):
|
||||||
time_start, time_end = time.split('-')
|
time, temp = time_temp.split(':')
|
||||||
start_time = datetime.datetime.time(datetime.datetime.
|
time_start, time_end = time.split('-')
|
||||||
strptime(time_start, '%H%M'))
|
start_time = datetime.datetime.time(
|
||||||
end_time = datetime.datetime.time(datetime.datetime.
|
datetime.datetime.strptime(time_start, '%H%M'))
|
||||||
strptime(time_end, '%H%M'))
|
end_time = datetime.datetime.time(
|
||||||
self.time_temp.append((start_time, end_time, float(temp)))
|
datetime.datetime.strptime(time_end, '%H%M'))
|
||||||
|
self.time_temp.append((start_time, end_time, float(temp)))
|
||||||
|
|
||||||
self.min_temp = float(config.get("min_temp"))
|
self.min_temp = float(config.get("min_temp"))
|
||||||
|
self.max_temp = float(config.get("max_temp"))
|
||||||
|
|
||||||
self._manual_sat_temp = None
|
self._manual_sat_temp = None
|
||||||
self._away = False
|
self._away = False
|
||||||
@ -178,7 +180,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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user