Removed name and netdisco functions, implemented update method to caches values, radiotherm lib to coveragerc and requirements_all.txt
commit
ddeb84cb9c
|
@ -88,6 +88,7 @@ omit =
|
|||
homeassistant/components/switch/transmission.py
|
||||
homeassistant/components/switch/wemo.py
|
||||
homeassistant/components/thermostat/nest.py
|
||||
homeassistant/components/thermostat/radiotherm.py
|
||||
|
||||
|
||||
[report]
|
||||
|
|
|
@ -16,21 +16,12 @@ REQUIREMENTS = ['radiotherm==1.2']
|
|||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the Radio Thermostat. """
|
||||
import radiotherm
|
||||
|
||||
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 = []
|
||||
if discovery_info:
|
||||
logger.info('hass radiotherm discovery: %s', discovery_info)
|
||||
elif CONF_HOST in config:
|
||||
if CONF_HOST in config:
|
||||
hosts = [config[CONF_HOST]]
|
||||
else:
|
||||
hosts.append(radiotherm.discover.discover_address())
|
||||
|
@ -55,23 +46,19 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class RadioThermostat(ThermostatDevice):
|
||||
""" Represent a Radio Thermostat. """
|
||||
|
||||
def __init__(self, device, name=None):
|
||||
def __init__(self, device):
|
||||
self.device = device
|
||||
if name:
|
||||
self.set_name(name)
|
||||
self.set_time()
|
||||
self._away = False
|
||||
self._away_cool = 82
|
||||
self._away_heat = 70
|
||||
self._target_temperature = None
|
||||
self._current_temperature = None
|
||||
self._operation = STATE_IDLE
|
||||
self._name = None
|
||||
self.update()
|
||||
|
||||
@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
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
@ -81,10 +68,7 @@ class RadioThermostat(ThermostatDevice):
|
|||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
# Move these to Thermostat Device and make them global
|
||||
return {
|
||||
"humidity": None,
|
||||
"target_humidity": None,
|
||||
"fan": self.device.fmode['human'],
|
||||
"mode": self.device.tmode['human']
|
||||
}
|
||||
|
@ -92,48 +76,38 @@ class RadioThermostat(ThermostatDevice):
|
|||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
return self.device.temp['raw']
|
||||
return round(self._current_temperature, 1)
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns current operation. head, cool idle """
|
||||
if self.device.tmode['human'] == 'Cool':
|
||||
return STATE_COOL
|
||||
elif self.device.tmode['human'] == 'Heat':
|
||||
return STATE_HEAT
|
||||
else:
|
||||
return STATE_IDLE
|
||||
return self._operation
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
|
||||
if self.operation == STATE_COOL:
|
||||
temp = self.device.t_cool['raw']
|
||||
elif self.operation == STATE_HEAT:
|
||||
temp = self.device.t_heat['raw']
|
||||
return round(self._target_temperature, 1)
|
||||
|
||||
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):
|
||||
""" Set new target temperature """
|
||||
if self.operation == STATE_COOL:
|
||||
if self._operation == STATE_COOL:
|
||||
self.device.t_cool = temperature
|
||||
elif self.operation == STATE_HEAT:
|
||||
elif self._operation == STATE_HEAT:
|
||||
self.device.t_heat = temperature
|
||||
|
||||
@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
|
||||
self.device.hold = 1
|
||||
|
||||
def set_time(self):
|
||||
""" Set device time """
|
||||
|
|
|
@ -137,3 +137,6 @@ SoCo==0.11.1
|
|||
|
||||
# PlexAPI (media_player.plex)
|
||||
https://github.com/adrienbrault/python-plexapi/archive/df2d0847e801d6d5cda920326d693cf75f304f1a.zip#python-plexapi==1.0.2
|
||||
|
||||
# Radio Thermostat (thermostat.radiotherm)
|
||||
radiotherm=1.2
|
||||
|
|
Loading…
Reference in New Issue