Merge branch 'pep257-thermostats' into dev

This commit is contained in:
Fabian Affolter 2016-03-08 08:11:38 +01:00
commit 08233da8a7
10 changed files with 171 additions and 184 deletions

View File

@ -1,6 +1,4 @@
""" """
homeassistant.components.thermostat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Provides functionality to interact with thermostats. Provides functionality to interact with thermostats.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
@ -50,7 +48,7 @@ DISCOVERY_PLATFORMS = {
def set_away_mode(hass, away_mode, entity_id=None): def set_away_mode(hass, away_mode, entity_id=None):
""" Turn all or specified thermostat away mode on. """ """Turn all or specified thermostat away mode on."""
data = { data = {
ATTR_AWAY_MODE: away_mode ATTR_AWAY_MODE: away_mode
} }
@ -62,7 +60,7 @@ def set_away_mode(hass, away_mode, entity_id=None):
def set_temperature(hass, temperature, entity_id=None): def set_temperature(hass, temperature, entity_id=None):
""" Set new target temperature. """ """Set new target temperature."""
data = {ATTR_TEMPERATURE: temperature} data = {ATTR_TEMPERATURE: temperature}
if entity_id is not None: if entity_id is not None:
@ -72,7 +70,7 @@ def set_temperature(hass, temperature, entity_id=None):
def set_fan_mode(hass, fan_mode, entity_id=None): def set_fan_mode(hass, fan_mode, entity_id=None):
""" Turn all or specified thermostat fan mode on. """ """Turn all or specified thermostat fan mode on."""
data = { data = {
ATTR_FAN: fan_mode ATTR_FAN: fan_mode
} }
@ -85,7 +83,7 @@ def set_fan_mode(hass, fan_mode, entity_id=None):
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
def setup(hass, config): def setup(hass, config):
""" Setup thermostats. """ """Setup thermostats."""
component = EntityComponent(_LOGGER, DOMAIN, hass, component = EntityComponent(_LOGGER, DOMAIN, hass,
SCAN_INTERVAL, DISCOVERY_PLATFORMS) SCAN_INTERVAL, DISCOVERY_PLATFORMS)
component.setup(config) component.setup(config)
@ -94,8 +92,7 @@ def setup(hass, config):
os.path.join(os.path.dirname(__file__), 'services.yaml')) os.path.join(os.path.dirname(__file__), 'services.yaml'))
def away_mode_set_service(service): def away_mode_set_service(service):
""" Set away mode on target thermostats """ """Set away mode on target thermostats."""
target_thermostats = component.extract_from_service(service) target_thermostats = component.extract_from_service(service)
away_mode = service.data.get(ATTR_AWAY_MODE) away_mode = service.data.get(ATTR_AWAY_MODE)
@ -119,8 +116,7 @@ def setup(hass, config):
descriptions.get(SERVICE_SET_AWAY_MODE)) descriptions.get(SERVICE_SET_AWAY_MODE))
def temperature_set_service(service): def temperature_set_service(service):
""" Set temperature on the target thermostats """ """Set temperature on the target thermostats."""
target_thermostats = component.extract_from_service(service) target_thermostats = component.extract_from_service(service)
temperature = util.convert( temperature = util.convert(
@ -141,8 +137,7 @@ def setup(hass, config):
descriptions.get(SERVICE_SET_TEMPERATURE)) descriptions.get(SERVICE_SET_TEMPERATURE))
def fan_mode_set_service(service): def fan_mode_set_service(service):
""" Set fan mode on target thermostats """ """Set fan mode on target thermostats."""
target_thermostats = component.extract_from_service(service) target_thermostats = component.extract_from_service(service)
fan_mode = service.data.get(ATTR_FAN) fan_mode = service.data.get(ATTR_FAN)
@ -169,19 +164,17 @@ def setup(hass, config):
class ThermostatDevice(Entity): class ThermostatDevice(Entity):
""" Represents a thermostat within Home Assistant. """ """Representation of a thermostat."""
# pylint: disable=no-self-use # pylint: disable=no-self-use
@property @property
def state(self): def state(self):
""" Returns the current state. """ """Return the current state."""
return self.target_temperature or STATE_UNKNOWN return self.target_temperature or STATE_UNKNOWN
@property @property
def state_attributes(self): def state_attributes(self):
""" Returns optional state attributes. """ """Return the optional state attributes."""
data = { data = {
ATTR_CURRENT_TEMPERATURE: ATTR_CURRENT_TEMPERATURE:
self._convert(self.current_temperature, 1), self._convert(self.current_temperature, 1),
@ -210,83 +203,76 @@ class ThermostatDevice(Entity):
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement."""
raise NotImplementedError raise NotImplementedError
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
raise NotImplementedError raise NotImplementedError
@property @property
def operation(self): def operation(self):
""" Returns current operation ie. heat, cool, idle """ """Return current operation ie. heat, cool, idle."""
return None return None
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
raise NotImplementedError raise NotImplementedError
@property @property
def target_temperature_low(self): def target_temperature_low(self):
""" Returns the lower bound temperature we try to reach. """ """Return the lower bound temperature we try to reach."""
return self.target_temperature return self.target_temperature
@property @property
def target_temperature_high(self): def target_temperature_high(self):
""" Returns the upper bound temperature we try to reach. """ """Return the upper bound temperature we try to reach."""
return self.target_temperature return self.target_temperature
@property @property
def is_away_mode_on(self): def is_away_mode_on(self):
""" """Return true if away mode is on."""
Returns if away mode is on.
Return None if no away mode available.
"""
return None return None
@property @property
def is_fan_on(self): def is_fan_on(self):
""" """Return true if the fan is on."""
Returns if the fan is on
Return None if not available.
"""
return None return None
def set_temperate(self, temperature): def set_temperate(self, temperature):
""" Set new target temperature. """ """Set new target temperature."""
pass pass
def turn_away_mode_on(self): def turn_away_mode_on(self):
""" Turns away mode on. """ """Turn away mode on."""
pass pass
def turn_away_mode_off(self): def turn_away_mode_off(self):
""" Turns away mode off. """ """Turn away mode off."""
pass pass
def turn_fan_on(self): def turn_fan_on(self):
""" Turns fan on. """ """Turn fan on."""
pass pass
def turn_fan_off(self): def turn_fan_off(self):
""" Turns fan off. """ """Turn fan off."""
pass pass
@property @property
def min_temp(self): def min_temp(self):
""" Return minimum temperature. """ """Return the minimum temperature."""
return round(convert(7, TEMP_CELCIUS, self.unit_of_measurement)) return round(convert(7, TEMP_CELCIUS, self.unit_of_measurement))
@property @property
def max_temp(self): def max_temp(self):
""" Return maxmum temperature. """ """Return the maximum temperature."""
return round(convert(35, TEMP_CELCIUS, self.unit_of_measurement)) return round(convert(35, TEMP_CELCIUS, self.unit_of_measurement))
def _convert(self, temp, round_dec=None): def _convert(self, temp, round_dec=None):
""" Convert temperature from this thermost into user preferred """Convert temperature into user preferred temperature."""
temperature. """
if temp is None: if temp is None:
return None return None

View File

@ -18,9 +18,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
class DemoThermostat(ThermostatDevice): class DemoThermostat(ThermostatDevice):
"""Represents a HeatControl thermostat.""" """Representation of a demo thermostat."""
def __init__(self, name, target_temperature, unit_of_measurement, def __init__(self, name, target_temperature, unit_of_measurement,
away, current_temperature): away, current_temperature):
"""Initialize the thermostat."""
self._name = name self._name = name
self._target_temperature = target_temperature self._target_temperature = target_temperature
self._unit_of_measurement = unit_of_measurement self._unit_of_measurement = unit_of_measurement
@ -34,7 +36,7 @@ class DemoThermostat(ThermostatDevice):
@property @property
def name(self): def name(self):
"""Return the thermostat.""" """Return the name of the thermostat."""
return self._name return self._name
@property @property

View File

@ -1,6 +1,4 @@
""" """
homeassistant.components.thermostat.ecobee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Platform for Ecobee Thermostats. Platform for Ecobee Thermostats.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -20,7 +18,7 @@ _CONFIGURING = {}
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Setup the Ecobee Thermostat Platform. """ """Setup the Ecobee Thermostat Platform."""
if discovery_info is None: if discovery_info is None:
return return
data = ecobee.NETWORK data = ecobee.NETWORK
@ -33,9 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class Thermostat(ThermostatDevice): class Thermostat(ThermostatDevice):
""" Thermostat class for Ecobee. """ """A thermostat class for Ecobee."""
def __init__(self, data, thermostat_index, hold_temp): def __init__(self, data, thermostat_index, hold_temp):
"""Initialize the thermostat."""
self.data = data self.data = data
self.thermostat_index = thermostat_index self.thermostat_index = thermostat_index
self.thermostat = self.data.ecobee.get_thermostat( self.thermostat = self.data.ecobee.get_thermostat(
@ -45,29 +44,29 @@ class Thermostat(ThermostatDevice):
self.hold_temp = hold_temp self.hold_temp = hold_temp
def update(self): def update(self):
""" Get the latest state from the thermostat. """ """Get the latest state from the thermostat."""
self.data.update() self.data.update()
self.thermostat = self.data.ecobee.get_thermostat( self.thermostat = self.data.ecobee.get_thermostat(
self.thermostat_index) self.thermostat_index)
@property @property
def name(self): def name(self):
""" Returns the name of the Ecobee Thermostat. """ """Return the name of the Ecobee Thermostat."""
return self.thermostat['name'] return self.thermostat['name']
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement."""
return TEMP_FAHRENHEIT return TEMP_FAHRENHEIT
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return self.thermostat['runtime']['actualTemperature'] / 10 return self.thermostat['runtime']['actualTemperature'] / 10
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
if self.hvac_mode == 'heat' or self.hvac_mode == 'auxHeatOnly': if self.hvac_mode == 'heat' or self.hvac_mode == 'auxHeatOnly':
return self.target_temperature_low return self.target_temperature_low
elif self.hvac_mode == 'cool': elif self.hvac_mode == 'cool':
@ -78,27 +77,27 @@ class Thermostat(ThermostatDevice):
@property @property
def target_temperature_low(self): def target_temperature_low(self):
""" Returns the lower bound temperature we try to reach. """ """Return the lower bound temperature we try to reach."""
return int(self.thermostat['runtime']['desiredHeat'] / 10) return int(self.thermostat['runtime']['desiredHeat'] / 10)
@property @property
def target_temperature_high(self): def target_temperature_high(self):
""" Returns the upper bound temperature we try to reach. """ """Return the upper bound temperature we try to reach."""
return int(self.thermostat['runtime']['desiredCool'] / 10) return int(self.thermostat['runtime']['desiredCool'] / 10)
@property @property
def humidity(self): def humidity(self):
""" Returns the current humidity. """ """Return the current humidity."""
return self.thermostat['runtime']['actualHumidity'] return self.thermostat['runtime']['actualHumidity']
@property @property
def desired_fan_mode(self): def desired_fan_mode(self):
""" Returns the desired fan mode of operation. """ """Return the desired fan mode of operation."""
return self.thermostat['runtime']['desiredFanMode'] return self.thermostat['runtime']['desiredFanMode']
@property @property
def fan(self): def fan(self):
""" Returns the current fan state. """ """Return the current fan state."""
if 'fan' in self.thermostat['equipmentStatus']: if 'fan' in self.thermostat['equipmentStatus']:
return STATE_ON return STATE_ON
else: else:
@ -106,7 +105,7 @@ class Thermostat(ThermostatDevice):
@property @property
def operation(self): def operation(self):
""" Returns current operation ie. heat, cool, idle """ """Return current operation ie. heat, cool, idle."""
status = self.thermostat['equipmentStatus'] status = self.thermostat['equipmentStatus']
if status == '': if status == '':
return STATE_IDLE return STATE_IDLE
@ -121,19 +120,19 @@ class Thermostat(ThermostatDevice):
@property @property
def mode(self): def mode(self):
""" Returns current mode ie. home, away, sleep """ """Return current mode ie. home, away, sleep."""
mode = self.thermostat['program']['currentClimateRef'] mode = self.thermostat['program']['currentClimateRef']
self._away = 'away' in mode self._away = 'away' in mode
return mode return mode
@property @property
def hvac_mode(self): def hvac_mode(self):
""" Return current hvac mode ie. auto, auxHeatOnly, cool, heat, off """ """Return current hvac mode ie. auto, auxHeatOnly, cool, heat, off."""
return self.thermostat['settings']['hvacMode'] return self.thermostat['settings']['hvacMode']
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """Return device specific state attributes."""
# Move these to Thermostat Device and make them global # Move these to Thermostat Device and make them global
return { return {
"humidity": self.humidity, "humidity": self.humidity,
@ -144,11 +143,11 @@ class Thermostat(ThermostatDevice):
@property @property
def is_away_mode_on(self): def is_away_mode_on(self):
""" Returns if away mode is on. """ """Return true if away mode is on."""
return self._away return self._away
def turn_away_mode_on(self): def turn_away_mode_on(self):
""" Turns away on. """ """Turn away on."""
self._away = True self._away = True
if self.hold_temp: if self.hold_temp:
self.data.ecobee.set_climate_hold(self.thermostat_index, self.data.ecobee.set_climate_hold(self.thermostat_index,
@ -157,12 +156,12 @@ class Thermostat(ThermostatDevice):
self.data.ecobee.set_climate_hold(self.thermostat_index, "away") self.data.ecobee.set_climate_hold(self.thermostat_index, "away")
def turn_away_mode_off(self): def turn_away_mode_off(self):
""" Turns away off. """ """Turn away off."""
self._away = False self._away = False
self.data.ecobee.resume_program(self.thermostat_index) self.data.ecobee.resume_program(self.thermostat_index)
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """Set new target temperature."""
temperature = int(temperature) temperature = int(temperature)
low_temp = temperature - 1 low_temp = temperature - 1
high_temp = temperature + 1 high_temp = temperature + 1
@ -174,7 +173,7 @@ class Thermostat(ThermostatDevice):
high_temp) high_temp)
def set_hvac_mode(self, mode): def set_hvac_mode(self, mode):
""" Set HVAC mode (auto, auxHeatOnly, cool, heat, off) """ """Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
self.data.ecobee.set_hvac_mode(self.thermostat_index, mode) self.data.ecobee.set_hvac_mode(self.thermostat_index, mode)
# Home and Sleep mode aren't used in UI yet: # Home and Sleep mode aren't used in UI yet:

View File

@ -1,6 +1,4 @@
""" """
homeassistant.components.thermostat.heat_control
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for heat control units. Adds support for heat control units.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
@ -33,7 +31,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the heat control thermostat. """ """Setup the heat control thermostat."""
name = config.get(CONF_NAME, DEFAULT_NAME) name = config.get(CONF_NAME, DEFAULT_NAME)
heater_entity_id = config.get(CONF_HEATER) heater_entity_id = config.get(CONF_HEATER)
sensor_entity_id = config.get(CONF_SENSOR) sensor_entity_id = config.get(CONF_SENSOR)
@ -52,10 +50,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class HeatControl(ThermostatDevice): class HeatControl(ThermostatDevice):
""" Represents a HeatControl device. """ """Representation of a HeatControl device."""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, hass, name, heater_entity_id, sensor_entity_id, def __init__(self, hass, name, heater_entity_id, sensor_entity_id,
min_temp, max_temp, target_temp): min_temp, max_temp, target_temp):
"""Initialize the thermostat."""
self.hass = hass self.hass = hass
self._name = name self._name = name
self.heater_entity_id = heater_entity_id self.heater_entity_id = heater_entity_id
@ -75,42 +75,43 @@ class HeatControl(ThermostatDevice):
@property @property
def should_poll(self): def should_poll(self):
"""No polling needed."""
return False return False
@property @property
def name(self): def name(self):
""" Returns the name. """ """Return the name of the thermostat."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Returns the unit of measurement. """ """Return the unit of measurement."""
return self._unit return self._unit
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the sensor temperature. """ """Return the sensor temperature."""
return self._cur_temp return self._cur_temp
@property @property
def operation(self): def operation(self):
""" Returns current operation ie. heat, cool, idle """ """Return current operation ie. heat, cool, idle."""
return STATE_HEAT if self._active and self._is_heating else STATE_IDLE return STATE_HEAT if self._active and self._is_heating else STATE_IDLE
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return self._target_temp return self._target_temp
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature. """ """Set new target temperature."""
self._target_temp = temperature self._target_temp = temperature
self._control_heating() self._control_heating()
self.update_ha_state() self.update_ha_state()
@property @property
def min_temp(self): def min_temp(self):
""" Return minimum temperature. """ """Return the minimum temperature."""
# pylint: disable=no-member # pylint: disable=no-member
if self._min_temp: if self._min_temp:
return self._min_temp return self._min_temp
@ -120,16 +121,16 @@ class HeatControl(ThermostatDevice):
@property @property
def max_temp(self): def max_temp(self):
""" Return maximum temperature. """ """Return the maximum temperature."""
# pylint: disable=no-member # pylint: disable=no-member
if self._min_temp: if self._min_temp:
return self._max_temp return self._max_temp
else: else:
# get default temp from super class # Get default temp from super class
return ThermostatDevice.max_temp.fget(self) return ThermostatDevice.max_temp.fget(self)
def _sensor_changed(self, entity_id, old_state, new_state): def _sensor_changed(self, entity_id, old_state, new_state):
""" Called when temperature changes. """ """Called when temperature changes."""
if new_state is None: if new_state is None:
return return
@ -138,7 +139,7 @@ class HeatControl(ThermostatDevice):
self.update_ha_state() self.update_ha_state()
def _update_temp(self, state): def _update_temp(self, state):
""" Update thermostat with latest state from sensor. """ """Update thermostat with latest state from sensor."""
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT): if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT):
@ -161,7 +162,7 @@ class HeatControl(ThermostatDevice):
self._unit = unit self._unit = unit
def _control_heating(self): def _control_heating(self):
""" Check if we need to turn heating on or off. """ """Check if we need to turn heating on or off."""
if not self._active and None not in (self._cur_temp, if not self._active and None not in (self._cur_temp,
self._target_temp): self._target_temp):
self._active = True self._active = True
@ -183,5 +184,5 @@ class HeatControl(ThermostatDevice):
@property @property
def _is_heating(self): def _is_heating(self):
""" If the heater is currently heating. """ """If the heater is currently heating."""
return switch.is_on(self.hass, self.heater_entity_id) return switch.is_on(self.hass, self.heater_entity_id)

View File

@ -1,7 +1,5 @@
""" """
homeassistant.components.thermostat.heatmiser Support for the PRT Heatmiser themostats using the V3 protocol.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for the PRT Heatmiser themostats using the V3 protocol.
See https://github.com/andylockran/heatmiserV3 for more info on the See https://github.com/andylockran/heatmiserV3 for more info on the
heatmiserV3 module dependency. heatmiserV3 module dependency.
@ -24,8 +22,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the heatmiser thermostat. """ """Setup the heatmiser thermostat."""
from heatmiserV3 import heatmiser, connection from heatmiserV3 import heatmiser, connection
ipaddress = str(config[CONF_IPADDRESS]) ipaddress = str(config[CONF_IPADDRESS])
@ -59,10 +56,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class HeatmiserV3Thermostat(ThermostatDevice): class HeatmiserV3Thermostat(ThermostatDevice):
""" Represents a HeatmiserV3 thermostat. """ """Representation of a HeatmiserV3 thermostat."""
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
def __init__(self, heatmiser, device, name, serport): def __init__(self, heatmiser, device, name, serport):
"""Initialize the thermostat."""
self.heatmiser = heatmiser self.heatmiser = heatmiser
self.device = device self.device = device
self.serport = serport self.serport = serport
@ -75,17 +73,17 @@ class HeatmiserV3Thermostat(ThermostatDevice):
@property @property
def name(self): def name(self):
""" Returns the name of the honeywell, if any. """ """Return the name of the thermostat, if any."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat uses.""" """Return the unit of measurement which this thermostat uses."""
return TEMP_CELCIUS return TEMP_CELCIUS
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
if self.dcb is not None: if self.dcb is not None:
low = self.dcb.get("floortemplow ") low = self.dcb.get("floortemplow ")
high = self.dcb.get("floortemphigh") high = self.dcb.get("floortemphigh")
@ -97,11 +95,11 @@ class HeatmiserV3Thermostat(ThermostatDevice):
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return self._target_temperature return self._target_temperature
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """Set new target temperature."""
temperature = int(temperature) temperature = int(temperature)
self.heatmiser.hmSendAddress( self.heatmiser.hmSendAddress(
self._id, self._id,
@ -112,7 +110,5 @@ class HeatmiserV3Thermostat(ThermostatDevice):
self._target_temperature = int(temperature) self._target_temperature = int(temperature)
def update(self): def update(self):
self.dcb = self.heatmiser.hmReadAddress( """Get the latest data."""
self._id, self.dcb = self.heatmiser.hmReadAddress(self._id, 'prt', self.serport)
'prt',
self.serport)

View File

@ -1,8 +1,5 @@
""" """
homeassistant.components.thermostat.homematic Support for Homematic (HM-TC-IT-WM-W-EU, HM-CC-RT-DN) thermostats.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Homematic (HM-TC-IT-WM-W-EU, HM-CC-RT-DN) thermostats using
Homegear or Homematic central (CCU1/CCU2).
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.homematic/ https://home-assistant.io/components/thermostat.homematic/
@ -29,8 +26,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Homematic thermostat. """ """Setup the Homematic thermostat."""
devices = [] devices = []
try: try:
homegear = ServerProxy(config[CONF_ADDRESS]) homegear = ServerProxy(config[CONF_ADDRESS])
@ -62,9 +58,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
class HomematicThermostat(ThermostatDevice): class HomematicThermostat(ThermostatDevice):
""" Represents a Homematic thermostat. """ """Representation of a Homematic thermostat."""
def __init__(self, device, _id, name, channel): def __init__(self, device, _id, name, channel):
"""Initialize the thermostat."""
self.device = device self.device = device
self._id = _id self._id = _id
self._channel = channel self._channel = channel
@ -80,39 +77,39 @@ class HomematicThermostat(ThermostatDevice):
@property @property
def name(self): def name(self):
""" Returns the name of the Homematic device. """ """Return the name of the Homematic device."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement that is used."""
return TEMP_CELCIUS return TEMP_CELCIUS
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return self._current_temperature return self._current_temperature
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return self._target_temperature return self._target_temperature
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature. """ """Set new target temperature."""
self.device.setValue(self._full_device_name, self.device.setValue(self._full_device_name,
PROPERTY_SET_TEMPERATURE, PROPERTY_SET_TEMPERATURE,
temperature) temperature)
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """Return the device specific state attributes."""
return {"valve": self._valve, return {"valve": self._valve,
"battery": self._battery, "battery": self._battery,
"mode": self._mode} "mode": self._mode}
def update(self): def update(self):
""" Update the data from the thermostat. """ """Update the data from the thermostat."""
try: try:
self._current_temperature = self.device.getValue( self._current_temperature = self.device.getValue(
self._full_device_name, self._full_device_name,

View File

@ -1,7 +1,5 @@
""" """
homeassistant.components.thermostat.honeywell Support for Honeywell Round Connected and Honeywell Evohome thermostats.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Honeywell Round Connected and Honeywell Evohome thermostats.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.honeywell/ https://home-assistant.io/components/thermostat.honeywell/
@ -23,6 +21,7 @@ DEFAULT_AWAY_TEMP = 16
def _setup_round(username, password, config, add_devices): def _setup_round(username, password, config, add_devices):
"""Setup rounding function."""
from evohomeclient import EvohomeClient from evohomeclient import EvohomeClient
try: try:
@ -52,6 +51,7 @@ def _setup_round(username, password, config, add_devices):
# config will be used later # config will be used later
# pylint: disable=unused-argument # pylint: disable=unused-argument
def _setup_us(username, password, config, add_devices): def _setup_us(username, password, config, add_devices):
"""Setup user."""
import somecomfort import somecomfort
try: try:
@ -76,7 +76,7 @@ def _setup_us(username, password, config, add_devices):
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the honeywel thermostat. """ """Setup the honeywel thermostat."""
username = config.get(CONF_USERNAME) username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD) password = config.get(CONF_PASSWORD)
region = config.get('region', 'eu').lower() region = config.get('region', 'eu').lower()
@ -96,10 +96,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class RoundThermostat(ThermostatDevice): class RoundThermostat(ThermostatDevice):
""" Represents a Honeywell Round Connected thermostat. """ """Representation of a Honeywell Round Connected thermostat."""
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
def __init__(self, device, zone_id, master, away_temp): def __init__(self, device, zone_id, master, away_temp):
"""Initialize the thermostat."""
self.device = device self.device = device
self._current_temperature = None self._current_temperature = None
self._target_temperature = None self._target_temperature = None
@ -113,50 +114,52 @@ class RoundThermostat(ThermostatDevice):
@property @property
def name(self): def name(self):
""" Returns the name of the honeywell, if any. """ """Return the name of the honeywell, if any."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement."""
return TEMP_CELCIUS return TEMP_CELCIUS
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return self._current_temperature return self._current_temperature
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
if self._is_dhw: if self._is_dhw:
return None return None
return self._target_temperature return self._target_temperature
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """Set new target temperature."""
self.device.set_temperature(self._name, temperature) self.device.set_temperature(self._name, temperature)
@property @property
def is_away_mode_on(self): def is_away_mode_on(self):
""" Returns if away mode is on. """ """Return true if away mode is on."""
return self._away return self._away
def turn_away_mode_on(self): def turn_away_mode_on(self):
""" Turns away on. """Turn away on.
Evohome does have a proprietary away mode, but it doesn't really work
the way it should. For example: If you set a temperature manually Evohome does have a proprietary away mode, but it doesn't really work
it doesn't get overwritten when away mode is switched on. the way it should. For example: If you set a temperature manually
""" it doesn't get overwritten when away mode is switched on.
"""
self._away = True self._away = True
self.device.set_temperature(self._name, self._away_temp) self.device.set_temperature(self._name, self._away_temp)
def turn_away_mode_off(self): def turn_away_mode_off(self):
""" Turns away off. """ """Turn away off."""
self._away = False self._away = False
self.device.cancel_temp_override(self._name) self.device.cancel_temp_override(self._name)
def update(self): def update(self):
"""Get the latest date."""
try: try:
# Only refresh if this is the "master" device, # Only refresh if this is the "master" device,
# others will pick up the cache # others will pick up the cache
@ -180,39 +183,45 @@ class RoundThermostat(ThermostatDevice):
class HoneywellUSThermostat(ThermostatDevice): class HoneywellUSThermostat(ThermostatDevice):
""" Represents a Honeywell US Thermostat. """ """Representation of a Honeywell US Thermostat."""
def __init__(self, client, device): def __init__(self, client, device):
"""Initialize the thermostat."""
self._client = client self._client = client
self._device = device self._device = device
@property @property
def is_fan_on(self): def is_fan_on(self):
"""Return true if fan is on."""
return self._device.fan_running return self._device.fan_running
@property @property
def name(self): def name(self):
"""Return the name of the honeywell, if any."""
return self._device.name return self._device.name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
"""Return the unit of measurement."""
return (TEMP_CELCIUS if self._device.temperature_unit == 'C' return (TEMP_CELCIUS if self._device.temperature_unit == 'C'
else TEMP_FAHRENHEIT) else TEMP_FAHRENHEIT)
@property @property
def current_temperature(self): def current_temperature(self):
"""Return the current temperature."""
self._device.refresh() self._device.refresh()
return self._device.current_temperature return self._device.current_temperature
@property @property
def target_temperature(self): def target_temperature(self):
"""Return the temperature we try to reach."""
if self._device.system_mode == 'cool': if self._device.system_mode == 'cool':
return self._device.setpoint_cool return self._device.setpoint_cool
else: else:
return self._device.setpoint_heat return self._device.setpoint_heat
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set target temperature. """ """Set target temperature."""
import somecomfort import somecomfort
try: try:
if self._device.system_mode == 'cool': if self._device.system_mode == 'cool':
@ -224,13 +233,15 @@ class HoneywellUSThermostat(ThermostatDevice):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Return device specific state attributes. """ """Return the device specific state attributes."""
return {'fan': (self.is_fan_on and 'running' or 'idle'), return {'fan': (self.is_fan_on and 'running' or 'idle'),
'fanmode': self._device.fan_mode, 'fanmode': self._device.fan_mode,
'system_mode': self._device.system_mode} 'system_mode': self._device.system_mode}
def turn_away_mode_on(self): def turn_away_mode_on(self):
"""Turn away on."""
pass pass
def turn_away_mode_off(self): def turn_away_mode_off(self):
"""Turn away off."""
pass pass

View File

@ -1,7 +1,5 @@
""" """
homeassistant.components.thermostat.nest Support for Nest thermostats.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Nest thermostats.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.nest/ https://home-assistant.io/components/thermostat.nest/
@ -18,8 +16,7 @@ DEPENDENCIES = ['nest']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"Setup nest thermostat" """Setup the Nest thermostat."""
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
try: try:
@ -35,15 +32,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class NestThermostat(ThermostatDevice): class NestThermostat(ThermostatDevice):
""" Represents a Nest thermostat. """ """Representation of a Nest thermostat."""
def __init__(self, structure, device): def __init__(self, structure, device):
"""Initialize the thermostat."""
self.structure = structure self.structure = structure
self.device = device self.device = device
@property @property
def name(self): def name(self):
""" Returns the name of the nest, if any. """ """Return the name of the nest, if any."""
location = self.device.where location = self.device.where
name = self.device.name name = self.device.name
if location is None: if location is None:
@ -56,12 +54,12 @@ class NestThermostat(ThermostatDevice):
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement."""
return TEMP_CELCIUS return TEMP_CELCIUS
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """Return the device specific state attributes."""
# Move these to Thermostat Device and make them global # Move these to Thermostat Device and make them global
return { return {
"humidity": self.device.humidity, "humidity": self.device.humidity,
@ -71,12 +69,12 @@ class NestThermostat(ThermostatDevice):
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return round(self.device.temperature, 1) return round(self.device.temperature, 1)
@property @property
def operation(self): def operation(self):
""" Returns current operation ie. heat, cool, idle """ """Return current operation ie. heat, cool, idle."""
if self.device.hvac_ac_state is True: if self.device.hvac_ac_state is True:
return STATE_COOL return STATE_COOL
elif self.device.hvac_heater_state is True: elif self.device.hvac_heater_state is True:
@ -86,7 +84,7 @@ class NestThermostat(ThermostatDevice):
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
target = self.device.target target = self.device.target
if self.device.mode == 'range': if self.device.mode == 'range':
@ -108,25 +106,25 @@ class NestThermostat(ThermostatDevice):
@property @property
def target_temperature_low(self): def target_temperature_low(self):
""" Returns the lower bound temperature we try to reach. """ """Return the lower bound temperature we try to reach."""
if self.device.mode == 'range': if self.device.mode == 'range':
return round(self.device.target[0], 1) return round(self.device.target[0], 1)
return round(self.target_temperature, 1) return round(self.target_temperature, 1)
@property @property
def target_temperature_high(self): def target_temperature_high(self):
""" Returns the upper bound temperature we try to reach. """ """Return the upper bound temperature we try to reach."""
if self.device.mode == 'range': if self.device.mode == 'range':
return round(self.device.target[1], 1) return round(self.device.target[1], 1)
return round(self.target_temperature, 1) return round(self.target_temperature, 1)
@property @property
def is_away_mode_on(self): def is_away_mode_on(self):
""" Returns if away mode is on. """ """Return if away mode is on."""
return self.structure.away return self.structure.away
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature """ """Set new target temperature."""
if self.device.mode == 'range': if self.device.mode == 'range':
if self.target_temperature == self.target_temperature_low: if self.target_temperature == self.target_temperature_low:
temperature = (temperature, self.target_temperature_high) temperature = (temperature, self.target_temperature_high)
@ -135,29 +133,29 @@ class NestThermostat(ThermostatDevice):
self.device.target = temperature self.device.target = temperature
def turn_away_mode_on(self): def turn_away_mode_on(self):
""" Turns away on. """ """Turn away on."""
self.structure.away = True self.structure.away = True
def turn_away_mode_off(self): def turn_away_mode_off(self):
""" Turns away off. """ """Turn away off."""
self.structure.away = False self.structure.away = False
@property @property
def is_fan_on(self): def is_fan_on(self):
""" Returns whether the fan is on """ """Return whether the fan is on."""
return self.device.fan return self.device.fan
def turn_fan_on(self): def turn_fan_on(self):
""" Turns fan on """ """Turn fan on."""
self.device.fan = True self.device.fan = True
def turn_fan_off(self): def turn_fan_off(self):
""" Turns fan off """ """Turn fan off."""
self.device.fan = False self.device.fan = False
@property @property
def min_temp(self): def min_temp(self):
""" Identifies min_temp in Nest API or defaults if not available. """ """Identify min_temp in Nest API or defaults if not available."""
temp = self.device.away_temperature.low temp = self.device.away_temperature.low
if temp is None: if temp is None:
return super().min_temp return super().min_temp
@ -166,7 +164,7 @@ class NestThermostat(ThermostatDevice):
@property @property
def max_temp(self): def max_temp(self):
""" Identifies mxn_temp in Nest API or defaults if not available. """ """Identify max_temp in Nest API or defaults if not available."""
temp = self.device.away_temperature.high temp = self.device.away_temperature.high
if temp is None: if temp is None:
return super().max_temp return super().max_temp
@ -174,5 +172,5 @@ class NestThermostat(ThermostatDevice):
return temp return temp
def update(self): def update(self):
""" Python-nest has its own mechanism for staying up to date. """ """Python-nest has its own mechanism for staying up to date."""
pass pass

View File

@ -1,7 +1,5 @@
""" """
homeassistant.components.thermostat.proliphix Support for Proliphix NT10e Thermostats.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Proliphix NT10e Thermostat is an ethernet connected thermostat.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.proliphix/ https://home-assistant.io/components/thermostat.proliphix/
@ -15,7 +13,7 @@ REQUIREMENTS = ['proliphix==0.1.0']
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Proliphix thermostats. """ """Setup the Proliphix thermostats."""
username = config.get(CONF_USERNAME) username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD) password = config.get(CONF_PASSWORD)
host = config.get(CONF_HOST) host = config.get(CONF_HOST)
@ -30,9 +28,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ProliphixThermostat(ThermostatDevice): class ProliphixThermostat(ThermostatDevice):
""" Represents a Proliphix thermostat. """ """Representation a Proliphix thermostat."""
def __init__(self, pdp): def __init__(self, pdp):
"""Initialize the thermostat."""
self._pdp = pdp self._pdp = pdp
# initial data # initial data
self._pdp.update() self._pdp.update()
@ -40,43 +39,43 @@ class ProliphixThermostat(ThermostatDevice):
@property @property
def should_poll(self): def should_poll(self):
""" Polling needed for thermostat.. """ """Polling needed for thermostat."""
return True return True
def update(self): def update(self):
""" Update the data from the thermostat. """ """Update the data from the thermostat."""
self._pdp.update() self._pdp.update()
@property @property
def name(self): def name(self):
""" Returns the name of the thermostat. """ """Return the name of the thermostat."""
return self._name return self._name
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """Return the device specific state attributes."""
return { return {
"fan": self._pdp.fan_state "fan": self._pdp.fan_state
} }
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Returns the unit of measurement. """ """Return the unit of measurement."""
return TEMP_FAHRENHEIT return TEMP_FAHRENHEIT
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return self._pdp.cur_temp return self._pdp.cur_temp
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return self._pdp.setback_heat return self._pdp.setback_heat
@property @property
def operation(self): def operation(self):
""" Returns the current state of the thermostat. """ """Return the current state of the thermostat."""
state = self._pdp.hvac_state state = self._pdp.hvac_state
if state in (1, 2): if state in (1, 2):
return STATE_IDLE return STATE_IDLE
@ -86,5 +85,5 @@ class ProliphixThermostat(ThermostatDevice):
return STATE_COOL return STATE_COOL
def set_temperature(self, temperature): def set_temperature(self, temperature):
""" Set new target temperature. """ """Set new target temperature."""
self._pdp.setback_heat = temperature self._pdp.setback_heat = temperature

View File

@ -1,7 +1,5 @@
""" """
homeassistant.components.thermostat.radiotherm Support for Radio Thermostat wifi-enabled home thermostats.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds support for Radio Thermostat wifi-enabled home thermostats.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/thermostat.radiotherm/ https://home-assistant.io/components/thermostat.radiotherm/
@ -20,7 +18,7 @@ _LOGGER = logging.getLogger(__name__)
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. """ """Setup the Radio Thermostat."""
import radiotherm import radiotherm
hosts = [] hosts = []
@ -48,9 +46,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class RadioThermostat(ThermostatDevice): class RadioThermostat(ThermostatDevice):
""" Represent a Radio Thermostat. """ """Representation of a Radio Thermostat."""
def __init__(self, device, hold_temp): def __init__(self, device, hold_temp):
"""Initialize the thermostat."""
self.device = device self.device = device
self.set_time() self.set_time()
self._target_temperature = None self._target_temperature = None
@ -62,17 +61,17 @@ class RadioThermostat(ThermostatDevice):
@property @property
def name(self): def name(self):
""" Returns the name of the Radio Thermostat. """ """Return the name of the Radio Thermostat."""
return self._name return self._name
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement this thermostat expresses itself in. """ """Return the unit of measurement."""
return TEMP_FAHRENHEIT return TEMP_FAHRENHEIT
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Returns device specific state attributes. """ """Return the device specific state attributes."""
return { return {
"fan": self.device.fmode['human'], "fan": self.device.fmode['human'],
"mode": self.device.tmode['human'] "mode": self.device.tmode['human']
@ -80,22 +79,21 @@ class RadioThermostat(ThermostatDevice):
@property @property
def current_temperature(self): def current_temperature(self):
""" Returns the current temperature. """ """Return the current temperature."""
return round(self._current_temperature, 1) return round(self._current_temperature, 1)
@property @property
def operation(self): def operation(self):
""" Returns current operation. head, cool idle """ """Return the current operation. head, cool idle."""
return self._operation return self._operation
@property @property
def target_temperature(self): def target_temperature(self):
""" Returns the temperature we try to reach. """ """Return the temperature we try to reach."""
return round(self._target_temperature, 1) return round(self._target_temperature, 1)
def update(self): def update(self):
""" Update the data from the thermostat. """ """Update the data from the thermostat."""
self._current_temperature = self.device.temp['raw'] self._current_temperature = self.device.temp['raw']
self._name = self.device.name['raw'] self._name = self.device.name['raw']
if self.device.tmode['human'] == 'Cool': if self.device.tmode['human'] == 'Cool':
@ -108,7 +106,7 @@ class RadioThermostat(ThermostatDevice):
self._operation = STATE_IDLE 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:
@ -119,7 +117,7 @@ class RadioThermostat(ThermostatDevice):
self.device.hold = 0 self.device.hold = 0
def set_time(self): def set_time(self):
""" Set device time """ """Set device time."""
now = datetime.datetime.now() now = datetime.datetime.now()
self.device.time = {'day': now.weekday(), self.device.time = {'day': now.weekday(),
'hour': now.hour, 'minute': now.minute} 'hour': now.hour, 'minute': now.minute}