From 6c1c2430002db665a82266230a39a31e7b509c1a Mon Sep 17 00:00:00 2001 From: Todd Ingarfield Date: Sun, 11 Oct 2015 11:42:24 -0500 Subject: [PATCH] start away mode --- .../components/thermostat/radiotherm.py | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index e11f845b0b4..850bdcc2b83 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -9,7 +9,7 @@ from urllib.error import URLError from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL, 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'] @@ -29,13 +29,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # Detect hosts with hass discovery, config or radiotherm discovery hosts = [] if discovery_info: - logger.info('hass radiotherm discovery', discovery_info) + logger.info('hass radiotherm discovery: %s', discovery_info) elif CONF_HOST in config: hosts = [config[CONF_HOST]] else: hosts.append(radiotherm.discover.discover_address()) - name = config.get(CONF_NAME) if hosts is None: logger.error("no radiotherm thermostats detected") return @@ -48,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): tstats.append(RadioThermostat(tstat)) except (URLError, OSError): logger.exception( - "Unable to connect to Radio Thermostat @{}".format(host)) + "Unable to connect to Radio Thermostat: %s", host) add_devices(tstats) @@ -61,12 +60,19 @@ class RadioThermostat(ThermostatDevice): if name: self.set_name(name) self.set_time() + self._away = False + self._away_cool = 82 + self._away_heat = 70 @property def name(self): """ Returns the name of the Radio Thermostat. """ return self.device.name['raw'] + def set_name(self, name): + """ Set thermostat name """ + self.device.name = name + @property def unit_of_measurement(self): """ Unit of measurement this thermostat expresses itself in. """ @@ -116,9 +122,18 @@ class RadioThermostat(ThermostatDevice): elif self.operation == STATE_HEAT: self.device.t_heat = temperature - def set_name(self, name): - """ Set thermostat name """ - self.device.name = name + @property + def is_away_mode_on(self): + """ 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): """ Set device time """