Removed name and netdisco functions, implemented update method to caches values, radiotherm lib to coveragerc and requirements_all.txt

pull/503/head
Todd Ingarfield 2015-10-14 11:11:33 -05:00
commit ddeb84cb9c
3 changed files with 31 additions and 53 deletions

View File

@ -88,6 +88,7 @@ omit =
homeassistant/components/switch/transmission.py homeassistant/components/switch/transmission.py
homeassistant/components/switch/wemo.py homeassistant/components/switch/wemo.py
homeassistant/components/thermostat/nest.py homeassistant/components/thermostat/nest.py
homeassistant/components/thermostat/radiotherm.py
[report] [report]

View File

@ -16,21 +16,12 @@ REQUIREMENTS = ['radiotherm==1.2']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Radio Thermostat. """ """ Sets up the Radio Thermostat. """
import radiotherm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
try:
import radiotherm
except ImportError:
logger.exception(
"Error while importing dependency radiotherm. "
"Did you maybe not install the radiotherm dependency?")
return
# Detect hosts with hass discovery, config or radiotherm discovery
hosts = [] hosts = []
if discovery_info: if CONF_HOST in config:
logger.info('hass radiotherm discovery: %s', discovery_info)
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())
@ -55,23 +46,19 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class RadioThermostat(ThermostatDevice): class RadioThermostat(ThermostatDevice):
""" Represent a Radio Thermostat. """ """ Represent a Radio Thermostat. """
def __init__(self, device, name=None): def __init__(self, device):
self.device = device self.device = device
if name:
self.set_name(name)
self.set_time() self.set_time()
self._away = False self._target_temperature = None
self._away_cool = 82 self._current_temperature = None
self._away_heat = 70 self._operation = STATE_IDLE
self._name = None
self.update()
@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._name
def set_name(self, name):
""" Set thermostat name """
self.device.name = name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
@ -81,10 +68,7 @@ class RadioThermostat(ThermostatDevice):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """ Returns device specific state attributes. """
# Move these to Thermostat Device and make them global
return { return {
"humidity": None,
"target_humidity": None,
"fan": self.device.fmode['human'], "fan": self.device.fmode['human'],
"mode": self.device.tmode['human'] "mode": self.device.tmode['human']
} }
@ -92,48 +76,38 @@ class RadioThermostat(ThermostatDevice):
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """ Returns the current temperature. """
return self.device.temp['raw'] return round(self._current_temperature, 1)
@property @property
def operation(self): def operation(self):
""" Returns current operation. head, cool idle """ """ Returns current operation. head, cool idle """
if self.device.tmode['human'] == 'Cool': return self._operation
return STATE_COOL
elif self.device.tmode['human'] == 'Heat':
return STATE_HEAT
else:
return STATE_IDLE
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """ Returns the temperature we try to reach. """
if self.operation == STATE_COOL: return round(self._target_temperature, 1)
temp = self.device.t_cool['raw']
elif self.operation == STATE_HEAT:
temp = self.device.t_heat['raw']
return round(temp, 1) def update(self):
self._current_temperature = self.device.temp['raw']
self._name = self.device.name['raw']
if self.device.tmode['human'] == 'Cool':
self._target_temperature = self.device.t_cool['raw']
self._operation = STATE_COOL
elif self.device.tmode['human'] == 'Heat':
self._target_temperature = self.device.t_heat['raw']
self._operation = STATE_HEAT
else:
self._operation = STATE_IDLE
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """ Set new target temperature """
if self.operation == STATE_COOL: if self._operation == STATE_COOL:
self.device.t_cool = temperature self.device.t_cool = temperature
elif self.operation == STATE_HEAT: elif self._operation == STATE_HEAT:
self.device.t_heat = temperature self.device.t_heat = temperature
self.device.hold = 1
@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): def set_time(self):
""" Set device time """ """ Set device time """

View File

@ -137,3 +137,6 @@ SoCo==0.11.1
# PlexAPI (media_player.plex) # PlexAPI (media_player.plex)
https://github.com/adrienbrault/python-plexapi/archive/df2d0847e801d6d5cda920326d693cf75f304f1a.zip#python-plexapi==1.0.2 https://github.com/adrienbrault/python-plexapi/archive/df2d0847e801d6d5cda920326d693cf75f304f1a.zip#python-plexapi==1.0.2
# Radio Thermostat (thermostat.radiotherm)
radiotherm=1.2