mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
start away mode
This commit is contained in:
parent
84c72ebf63
commit
6c1c243000
@ -9,7 +9,7 @@ from urllib.error import URLError
|
|||||||
|
|
||||||
from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
|
||||||
STATE_IDLE, STATE_HEAT)
|
STATE_IDLE, STATE_HEAT)
|
||||||
from homeassistant.const import (CONF_HOST, CONF_NAME, TEMP_FAHRENHEIT)
|
from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT)
|
||||||
|
|
||||||
REQUIREMENTS = ['radiotherm==1.2']
|
REQUIREMENTS = ['radiotherm==1.2']
|
||||||
|
|
||||||
@ -29,13 +29,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
# Detect hosts with hass discovery, config or radiotherm discovery
|
# Detect hosts with hass discovery, config or radiotherm discovery
|
||||||
hosts = []
|
hosts = []
|
||||||
if discovery_info:
|
if discovery_info:
|
||||||
logger.info('hass radiotherm discovery', discovery_info)
|
logger.info('hass radiotherm discovery: %s', discovery_info)
|
||||||
elif CONF_HOST in config:
|
elif CONF_HOST in config:
|
||||||
hosts = [config[CONF_HOST]]
|
hosts = [config[CONF_HOST]]
|
||||||
else:
|
else:
|
||||||
hosts.append(radiotherm.discover.discover_address())
|
hosts.append(radiotherm.discover.discover_address())
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
|
||||||
if hosts is None:
|
if hosts is None:
|
||||||
logger.error("no radiotherm thermostats detected")
|
logger.error("no radiotherm thermostats detected")
|
||||||
return
|
return
|
||||||
@ -48,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
tstats.append(RadioThermostat(tstat))
|
tstats.append(RadioThermostat(tstat))
|
||||||
except (URLError, OSError):
|
except (URLError, OSError):
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"Unable to connect to Radio Thermostat @{}".format(host))
|
"Unable to connect to Radio Thermostat: %s", host)
|
||||||
|
|
||||||
add_devices(tstats)
|
add_devices(tstats)
|
||||||
|
|
||||||
@ -61,12 +60,19 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
if name:
|
if name:
|
||||||
self.set_name(name)
|
self.set_name(name)
|
||||||
self.set_time()
|
self.set_time()
|
||||||
|
self._away = False
|
||||||
|
self._away_cool = 82
|
||||||
|
self._away_heat = 70
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
""" Returns the name of the Radio Thermostat. """
|
""" Returns the name of the Radio Thermostat. """
|
||||||
return self.device.name['raw']
|
return self.device.name['raw']
|
||||||
|
|
||||||
|
def set_name(self, name):
|
||||||
|
""" Set thermostat name """
|
||||||
|
self.device.name = name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
""" Unit of measurement this thermostat expresses itself in. """
|
""" Unit of measurement this thermostat expresses itself in. """
|
||||||
@ -116,9 +122,18 @@ class RadioThermostat(ThermostatDevice):
|
|||||||
elif self.operation == STATE_HEAT:
|
elif self.operation == STATE_HEAT:
|
||||||
self.device.t_heat = temperature
|
self.device.t_heat = temperature
|
||||||
|
|
||||||
def set_name(self, name):
|
@property
|
||||||
""" Set thermostat name """
|
def is_away_mode_on(self):
|
||||||
self.device.name = name
|
""" Returns away mode """
|
||||||
|
return self._away
|
||||||
|
|
||||||
|
def turn_away_mode_on(self):
|
||||||
|
""" Turns away mode on. """
|
||||||
|
self._away = True
|
||||||
|
|
||||||
|
def turn_away_mode_off(self):
|
||||||
|
""" Turns away mode off. """
|
||||||
|
self._away = False
|
||||||
|
|
||||||
def set_time(self):
|
def set_time(self):
|
||||||
""" Set device time """
|
""" Set device time """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user