mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Merge branch 'pep257-thermostats' into dev
This commit is contained in:
commit
08233da8a7
@ -1,6 +1,4 @@
|
||||
"""
|
||||
homeassistant.components.thermostat
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Provides functionality to interact with thermostats.
|
||||
|
||||
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):
|
||||
""" Turn all or specified thermostat away mode on. """
|
||||
"""Turn all or specified thermostat away mode on."""
|
||||
data = {
|
||||
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):
|
||||
""" Set new target temperature. """
|
||||
"""Set new target temperature."""
|
||||
data = {ATTR_TEMPERATURE: temperature}
|
||||
|
||||
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):
|
||||
""" Turn all or specified thermostat fan mode on. """
|
||||
"""Turn all or specified thermostat fan mode on."""
|
||||
data = {
|
||||
ATTR_FAN: fan_mode
|
||||
}
|
||||
@ -85,7 +83,7 @@ def set_fan_mode(hass, fan_mode, entity_id=None):
|
||||
|
||||
# pylint: disable=too-many-branches
|
||||
def setup(hass, config):
|
||||
""" Setup thermostats. """
|
||||
"""Setup thermostats."""
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass,
|
||||
SCAN_INTERVAL, DISCOVERY_PLATFORMS)
|
||||
component.setup(config)
|
||||
@ -94,8 +92,7 @@ def setup(hass, config):
|
||||
os.path.join(os.path.dirname(__file__), 'services.yaml'))
|
||||
|
||||
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)
|
||||
|
||||
away_mode = service.data.get(ATTR_AWAY_MODE)
|
||||
@ -119,8 +116,7 @@ def setup(hass, config):
|
||||
descriptions.get(SERVICE_SET_AWAY_MODE))
|
||||
|
||||
def temperature_set_service(service):
|
||||
""" Set temperature on the target thermostats """
|
||||
|
||||
"""Set temperature on the target thermostats."""
|
||||
target_thermostats = component.extract_from_service(service)
|
||||
|
||||
temperature = util.convert(
|
||||
@ -141,8 +137,7 @@ def setup(hass, config):
|
||||
descriptions.get(SERVICE_SET_TEMPERATURE))
|
||||
|
||||
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)
|
||||
|
||||
fan_mode = service.data.get(ATTR_FAN)
|
||||
@ -169,19 +164,17 @@ def setup(hass, config):
|
||||
|
||||
|
||||
class ThermostatDevice(Entity):
|
||||
""" Represents a thermostat within Home Assistant. """
|
||||
"""Representation of a thermostat."""
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
""" Returns the current state. """
|
||||
"""Return the current state."""
|
||||
return self.target_temperature or STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def state_attributes(self):
|
||||
""" Returns optional state attributes. """
|
||||
|
||||
"""Return the optional state attributes."""
|
||||
data = {
|
||||
ATTR_CURRENT_TEMPERATURE:
|
||||
self._convert(self.current_temperature, 1),
|
||||
@ -210,83 +203,76 @@ class ThermostatDevice(Entity):
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement."""
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns current operation ie. heat, cool, idle """
|
||||
"""Return current operation ie. heat, cool, idle."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
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
|
||||
|
||||
@property
|
||||
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
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
"""
|
||||
Returns if away mode is on.
|
||||
Return None if no away mode available.
|
||||
"""
|
||||
"""Return true if away mode is on."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_fan_on(self):
|
||||
"""
|
||||
Returns if the fan is on
|
||||
Return None if not available.
|
||||
"""
|
||||
"""Return true if the fan is on."""
|
||||
return None
|
||||
|
||||
def set_temperate(self, temperature):
|
||||
""" Set new target temperature. """
|
||||
"""Set new target temperature."""
|
||||
pass
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
""" Turns away mode on. """
|
||||
"""Turn away mode on."""
|
||||
pass
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away mode off. """
|
||||
"""Turn away mode off."""
|
||||
pass
|
||||
|
||||
def turn_fan_on(self):
|
||||
""" Turns fan on. """
|
||||
"""Turn fan on."""
|
||||
pass
|
||||
|
||||
def turn_fan_off(self):
|
||||
""" Turns fan off. """
|
||||
"""Turn fan off."""
|
||||
pass
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
""" Return minimum temperature. """
|
||||
"""Return the minimum temperature."""
|
||||
return round(convert(7, TEMP_CELCIUS, self.unit_of_measurement))
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
""" Return maxmum temperature. """
|
||||
"""Return the maximum temperature."""
|
||||
return round(convert(35, TEMP_CELCIUS, self.unit_of_measurement))
|
||||
|
||||
def _convert(self, temp, round_dec=None):
|
||||
""" Convert temperature from this thermost into user preferred
|
||||
temperature. """
|
||||
"""Convert temperature into user preferred temperature."""
|
||||
if temp is None:
|
||||
return None
|
||||
|
||||
|
@ -18,9 +18,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
class DemoThermostat(ThermostatDevice):
|
||||
"""Represents a HeatControl thermostat."""
|
||||
"""Representation of a demo thermostat."""
|
||||
|
||||
def __init__(self, name, target_temperature, unit_of_measurement,
|
||||
away, current_temperature):
|
||||
"""Initialize the thermostat."""
|
||||
self._name = name
|
||||
self._target_temperature = target_temperature
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
@ -34,7 +36,7 @@ class DemoThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the thermostat."""
|
||||
"""Return the name of the thermostat."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
|
@ -1,6 +1,4 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.ecobee
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Platform for Ecobee Thermostats.
|
||||
|
||||
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):
|
||||
""" Setup the Ecobee Thermostat Platform. """
|
||||
"""Setup the Ecobee Thermostat Platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
data = ecobee.NETWORK
|
||||
@ -33,9 +31,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class Thermostat(ThermostatDevice):
|
||||
""" Thermostat class for Ecobee. """
|
||||
"""A thermostat class for Ecobee."""
|
||||
|
||||
def __init__(self, data, thermostat_index, hold_temp):
|
||||
"""Initialize the thermostat."""
|
||||
self.data = data
|
||||
self.thermostat_index = thermostat_index
|
||||
self.thermostat = self.data.ecobee.get_thermostat(
|
||||
@ -45,29 +44,29 @@ class Thermostat(ThermostatDevice):
|
||||
self.hold_temp = hold_temp
|
||||
|
||||
def update(self):
|
||||
""" Get the latest state from the thermostat. """
|
||||
"""Get the latest state from the thermostat."""
|
||||
self.data.update()
|
||||
self.thermostat = self.data.ecobee.get_thermostat(
|
||||
self.thermostat_index)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the Ecobee Thermostat. """
|
||||
"""Return the name of the Ecobee Thermostat."""
|
||||
return self.thermostat['name']
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return self.thermostat['runtime']['actualTemperature'] / 10
|
||||
|
||||
@property
|
||||
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':
|
||||
return self.target_temperature_low
|
||||
elif self.hvac_mode == 'cool':
|
||||
@ -78,27 +77,27 @@ class Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
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)
|
||||
|
||||
@property
|
||||
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)
|
||||
|
||||
@property
|
||||
def humidity(self):
|
||||
""" Returns the current humidity. """
|
||||
"""Return the current humidity."""
|
||||
return self.thermostat['runtime']['actualHumidity']
|
||||
|
||||
@property
|
||||
def desired_fan_mode(self):
|
||||
""" Returns the desired fan mode of operation. """
|
||||
"""Return the desired fan mode of operation."""
|
||||
return self.thermostat['runtime']['desiredFanMode']
|
||||
|
||||
@property
|
||||
def fan(self):
|
||||
""" Returns the current fan state. """
|
||||
"""Return the current fan state."""
|
||||
if 'fan' in self.thermostat['equipmentStatus']:
|
||||
return STATE_ON
|
||||
else:
|
||||
@ -106,7 +105,7 @@ class Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns current operation ie. heat, cool, idle """
|
||||
"""Return current operation ie. heat, cool, idle."""
|
||||
status = self.thermostat['equipmentStatus']
|
||||
if status == '':
|
||||
return STATE_IDLE
|
||||
@ -121,19 +120,19 @@ class Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def mode(self):
|
||||
""" Returns current mode ie. home, away, sleep """
|
||||
"""Return current mode ie. home, away, sleep."""
|
||||
mode = self.thermostat['program']['currentClimateRef']
|
||||
self._away = 'away' in mode
|
||||
return mode
|
||||
|
||||
@property
|
||||
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']
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
"""Return device specific state attributes."""
|
||||
# Move these to Thermostat Device and make them global
|
||||
return {
|
||||
"humidity": self.humidity,
|
||||
@ -144,11 +143,11 @@ class Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
""" Returns if away mode is on. """
|
||||
"""Return true if away mode is on."""
|
||||
return self._away
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
""" Turns away on. """
|
||||
"""Turn away on."""
|
||||
self._away = True
|
||||
if self.hold_temp:
|
||||
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")
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away off. """
|
||||
"""Turn away off."""
|
||||
self._away = False
|
||||
self.data.ecobee.resume_program(self.thermostat_index)
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
"""Set new target temperature."""
|
||||
temperature = int(temperature)
|
||||
low_temp = temperature - 1
|
||||
high_temp = temperature + 1
|
||||
@ -174,7 +173,7 @@ class Thermostat(ThermostatDevice):
|
||||
high_temp)
|
||||
|
||||
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)
|
||||
|
||||
# Home and Sleep mode aren't used in UI yet:
|
||||
|
@ -1,6 +1,4 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.heat_control
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for heat control units.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
@ -33,7 +31,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
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)
|
||||
heater_entity_id = config.get(CONF_HEATER)
|
||||
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
|
||||
class HeatControl(ThermostatDevice):
|
||||
""" Represents a HeatControl device. """
|
||||
"""Representation of a HeatControl device."""
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def __init__(self, hass, name, heater_entity_id, sensor_entity_id,
|
||||
min_temp, max_temp, target_temp):
|
||||
"""Initialize the thermostat."""
|
||||
self.hass = hass
|
||||
self._name = name
|
||||
self.heater_entity_id = heater_entity_id
|
||||
@ -75,42 +75,43 @@ class HeatControl(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name. """
|
||||
"""Return the name of the thermostat."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Returns the unit of measurement. """
|
||||
"""Return the unit of measurement."""
|
||||
return self._unit
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the sensor temperature. """
|
||||
"""Return the sensor temperature."""
|
||||
return self._cur_temp
|
||||
|
||||
@property
|
||||
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
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._target_temp
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature. """
|
||||
"""Set new target temperature."""
|
||||
self._target_temp = temperature
|
||||
self._control_heating()
|
||||
self.update_ha_state()
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
""" Return minimum temperature. """
|
||||
"""Return the minimum temperature."""
|
||||
# pylint: disable=no-member
|
||||
if self._min_temp:
|
||||
return self._min_temp
|
||||
@ -120,16 +121,16 @@ class HeatControl(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
""" Return maximum temperature. """
|
||||
"""Return the maximum temperature."""
|
||||
# pylint: disable=no-member
|
||||
if self._min_temp:
|
||||
return self._max_temp
|
||||
else:
|
||||
# get default temp from super class
|
||||
# Get default temp from super class
|
||||
return ThermostatDevice.max_temp.fget(self)
|
||||
|
||||
def _sensor_changed(self, entity_id, old_state, new_state):
|
||||
""" Called when temperature changes. """
|
||||
"""Called when temperature changes."""
|
||||
if new_state is None:
|
||||
return
|
||||
|
||||
@ -138,7 +139,7 @@ class HeatControl(ThermostatDevice):
|
||||
self.update_ha_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)
|
||||
|
||||
if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT):
|
||||
@ -161,7 +162,7 @@ class HeatControl(ThermostatDevice):
|
||||
self._unit = unit
|
||||
|
||||
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,
|
||||
self._target_temp):
|
||||
self._active = True
|
||||
@ -183,5 +184,5 @@ class HeatControl(ThermostatDevice):
|
||||
|
||||
@property
|
||||
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)
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.heatmiser
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for the PRT Heatmiser themostats using the V3 protocol.
|
||||
Support for the PRT Heatmiser themostats using the V3 protocol.
|
||||
|
||||
See https://github.com/andylockran/heatmiserV3 for more info on the
|
||||
heatmiserV3 module dependency.
|
||||
@ -24,8 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the heatmiser thermostat. """
|
||||
|
||||
"""Setup the heatmiser thermostat."""
|
||||
from heatmiserV3 import heatmiser, connection
|
||||
|
||||
ipaddress = str(config[CONF_IPADDRESS])
|
||||
@ -59,10 +56,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
""" Represents a HeatmiserV3 thermostat. """
|
||||
"""Representation of a HeatmiserV3 thermostat."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, heatmiser, device, name, serport):
|
||||
"""Initialize the thermostat."""
|
||||
self.heatmiser = heatmiser
|
||||
self.device = device
|
||||
self.serport = serport
|
||||
@ -75,17 +73,17 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the honeywell, if any. """
|
||||
"""Return the name of the thermostat, if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat uses."""
|
||||
"""Return the unit of measurement which this thermostat uses."""
|
||||
return TEMP_CELCIUS
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
if self.dcb is not None:
|
||||
low = self.dcb.get("floortemplow ")
|
||||
high = self.dcb.get("floortemphigh")
|
||||
@ -97,11 +95,11 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._target_temperature
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
"""Set new target temperature."""
|
||||
temperature = int(temperature)
|
||||
self.heatmiser.hmSendAddress(
|
||||
self._id,
|
||||
@ -112,7 +110,5 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
||||
self._target_temperature = int(temperature)
|
||||
|
||||
def update(self):
|
||||
self.dcb = self.heatmiser.hmReadAddress(
|
||||
self._id,
|
||||
'prt',
|
||||
self.serport)
|
||||
"""Get the latest data."""
|
||||
self.dcb = self.heatmiser.hmReadAddress(self._id, 'prt', self.serport)
|
||||
|
@ -1,8 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.homematic
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Homematic (HM-TC-IT-WM-W-EU, HM-CC-RT-DN) thermostats using
|
||||
Homegear or Homematic central (CCU1/CCU2).
|
||||
Support for Homematic (HM-TC-IT-WM-W-EU, HM-CC-RT-DN) thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
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):
|
||||
""" Sets up the Homematic thermostat. """
|
||||
|
||||
"""Setup the Homematic thermostat."""
|
||||
devices = []
|
||||
try:
|
||||
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
|
||||
class HomematicThermostat(ThermostatDevice):
|
||||
""" Represents a Homematic thermostat. """
|
||||
"""Representation of a Homematic thermostat."""
|
||||
|
||||
def __init__(self, device, _id, name, channel):
|
||||
"""Initialize the thermostat."""
|
||||
self.device = device
|
||||
self._id = _id
|
||||
self._channel = channel
|
||||
@ -80,39 +77,39 @@ class HomematicThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the Homematic device. """
|
||||
"""Return the name of the Homematic device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement that is used."""
|
||||
return TEMP_CELCIUS
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return self._current_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._target_temperature
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature. """
|
||||
"""Set new target temperature."""
|
||||
self.device.setValue(self._full_device_name,
|
||||
PROPERTY_SET_TEMPERATURE,
|
||||
temperature)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
"""Return the device specific state attributes."""
|
||||
return {"valve": self._valve,
|
||||
"battery": self._battery,
|
||||
"mode": self._mode}
|
||||
|
||||
def update(self):
|
||||
""" Update the data from the thermostat. """
|
||||
"""Update the data from the thermostat."""
|
||||
try:
|
||||
self._current_temperature = self.device.getValue(
|
||||
self._full_device_name,
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.honeywell
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Honeywell Round Connected and Honeywell Evohome thermostats.
|
||||
Support for Honeywell Round Connected and Honeywell Evohome thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.honeywell/
|
||||
@ -23,6 +21,7 @@ DEFAULT_AWAY_TEMP = 16
|
||||
|
||||
|
||||
def _setup_round(username, password, config, add_devices):
|
||||
"""Setup rounding function."""
|
||||
from evohomeclient import EvohomeClient
|
||||
|
||||
try:
|
||||
@ -52,6 +51,7 @@ def _setup_round(username, password, config, add_devices):
|
||||
# config will be used later
|
||||
# pylint: disable=unused-argument
|
||||
def _setup_us(username, password, config, add_devices):
|
||||
"""Setup user."""
|
||||
import somecomfort
|
||||
|
||||
try:
|
||||
@ -76,7 +76,7 @@ def _setup_us(username, password, config, add_devices):
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the honeywel thermostat. """
|
||||
"""Setup the honeywel thermostat."""
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
region = config.get('region', 'eu').lower()
|
||||
@ -96,10 +96,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class RoundThermostat(ThermostatDevice):
|
||||
""" Represents a Honeywell Round Connected thermostat. """
|
||||
"""Representation of a Honeywell Round Connected thermostat."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, device, zone_id, master, away_temp):
|
||||
"""Initialize the thermostat."""
|
||||
self.device = device
|
||||
self._current_temperature = None
|
||||
self._target_temperature = None
|
||||
@ -113,37 +114,38 @@ class RoundThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the honeywell, if any. """
|
||||
"""Return the name of the honeywell, if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_CELCIUS
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return self._current_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
if self._is_dhw:
|
||||
return None
|
||||
return self._target_temperature
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
"""Set new target temperature."""
|
||||
self.device.set_temperature(self._name, temperature)
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
""" Returns if away mode is on. """
|
||||
"""Return true if away mode is on."""
|
||||
return self._away
|
||||
|
||||
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
|
||||
it doesn't get overwritten when away mode is switched on.
|
||||
@ -152,11 +154,12 @@ class RoundThermostat(ThermostatDevice):
|
||||
self.device.set_temperature(self._name, self._away_temp)
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away off. """
|
||||
"""Turn away off."""
|
||||
self._away = False
|
||||
self.device.cancel_temp_override(self._name)
|
||||
|
||||
def update(self):
|
||||
"""Get the latest date."""
|
||||
try:
|
||||
# Only refresh if this is the "master" device,
|
||||
# others will pick up the cache
|
||||
@ -180,39 +183,45 @@ class RoundThermostat(ThermostatDevice):
|
||||
|
||||
|
||||
class HoneywellUSThermostat(ThermostatDevice):
|
||||
""" Represents a Honeywell US Thermostat. """
|
||||
"""Representation of a Honeywell US Thermostat."""
|
||||
|
||||
def __init__(self, client, device):
|
||||
"""Initialize the thermostat."""
|
||||
self._client = client
|
||||
self._device = device
|
||||
|
||||
@property
|
||||
def is_fan_on(self):
|
||||
"""Return true if fan is on."""
|
||||
return self._device.fan_running
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the honeywell, if any."""
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
return (TEMP_CELCIUS if self._device.temperature_unit == 'C'
|
||||
else TEMP_FAHRENHEIT)
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
"""Return the current temperature."""
|
||||
self._device.refresh()
|
||||
return self._device.current_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
"""Return the temperature we try to reach."""
|
||||
if self._device.system_mode == 'cool':
|
||||
return self._device.setpoint_cool
|
||||
else:
|
||||
return self._device.setpoint_heat
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set target temperature. """
|
||||
"""Set target temperature."""
|
||||
import somecomfort
|
||||
try:
|
||||
if self._device.system_mode == 'cool':
|
||||
@ -224,13 +233,15 @@ class HoneywellUSThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
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'),
|
||||
'fanmode': self._device.fan_mode,
|
||||
'system_mode': self._device.system_mode}
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
"""Turn away on."""
|
||||
pass
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
"""Turn away off."""
|
||||
pass
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.nest
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Nest thermostats.
|
||||
Support for Nest thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.nest/
|
||||
@ -18,8 +16,7 @@ DEPENDENCIES = ['nest']
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"Setup nest thermostat"
|
||||
|
||||
"""Setup the Nest thermostat."""
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
@ -35,15 +32,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class NestThermostat(ThermostatDevice):
|
||||
""" Represents a Nest thermostat. """
|
||||
"""Representation of a Nest thermostat."""
|
||||
|
||||
def __init__(self, structure, device):
|
||||
"""Initialize the thermostat."""
|
||||
self.structure = structure
|
||||
self.device = device
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the nest, if any. """
|
||||
"""Return the name of the nest, if any."""
|
||||
location = self.device.where
|
||||
name = self.device.name
|
||||
if location is None:
|
||||
@ -56,12 +54,12 @@ class NestThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_CELCIUS
|
||||
|
||||
@property
|
||||
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
|
||||
return {
|
||||
"humidity": self.device.humidity,
|
||||
@ -71,12 +69,12 @@ class NestThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return round(self.device.temperature, 1)
|
||||
|
||||
@property
|
||||
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:
|
||||
return STATE_COOL
|
||||
elif self.device.hvac_heater_state is True:
|
||||
@ -86,7 +84,7 @@ class NestThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
target = self.device.target
|
||||
|
||||
if self.device.mode == 'range':
|
||||
@ -108,25 +106,25 @@ class NestThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
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':
|
||||
return round(self.device.target[0], 1)
|
||||
return round(self.target_temperature, 1)
|
||||
|
||||
@property
|
||||
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':
|
||||
return round(self.device.target[1], 1)
|
||||
return round(self.target_temperature, 1)
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
""" Returns if away mode is on. """
|
||||
"""Return if away mode is on."""
|
||||
return self.structure.away
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
"""Set new target temperature."""
|
||||
if self.device.mode == 'range':
|
||||
if self.target_temperature == self.target_temperature_low:
|
||||
temperature = (temperature, self.target_temperature_high)
|
||||
@ -135,29 +133,29 @@ class NestThermostat(ThermostatDevice):
|
||||
self.device.target = temperature
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
""" Turns away on. """
|
||||
"""Turn away on."""
|
||||
self.structure.away = True
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away off. """
|
||||
"""Turn away off."""
|
||||
self.structure.away = False
|
||||
|
||||
@property
|
||||
def is_fan_on(self):
|
||||
""" Returns whether the fan is on """
|
||||
"""Return whether the fan is on."""
|
||||
return self.device.fan
|
||||
|
||||
def turn_fan_on(self):
|
||||
""" Turns fan on """
|
||||
"""Turn fan on."""
|
||||
self.device.fan = True
|
||||
|
||||
def turn_fan_off(self):
|
||||
""" Turns fan off """
|
||||
"""Turn fan off."""
|
||||
self.device.fan = False
|
||||
|
||||
@property
|
||||
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
|
||||
if temp is None:
|
||||
return super().min_temp
|
||||
@ -166,7 +164,7 @@ class NestThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
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
|
||||
if temp is None:
|
||||
return super().max_temp
|
||||
@ -174,5 +172,5 @@ class NestThermostat(ThermostatDevice):
|
||||
return temp
|
||||
|
||||
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
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.proliphix
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The Proliphix NT10e Thermostat is an ethernet connected thermostat.
|
||||
Support for Proliphix NT10e Thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
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):
|
||||
""" Sets up the Proliphix thermostats. """
|
||||
"""Setup the Proliphix thermostats."""
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
host = config.get(CONF_HOST)
|
||||
@ -30,9 +28,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class ProliphixThermostat(ThermostatDevice):
|
||||
""" Represents a Proliphix thermostat. """
|
||||
"""Representation a Proliphix thermostat."""
|
||||
|
||||
def __init__(self, pdp):
|
||||
"""Initialize the thermostat."""
|
||||
self._pdp = pdp
|
||||
# initial data
|
||||
self._pdp.update()
|
||||
@ -40,43 +39,43 @@ class ProliphixThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" Polling needed for thermostat.. """
|
||||
"""Polling needed for thermostat."""
|
||||
return True
|
||||
|
||||
def update(self):
|
||||
""" Update the data from the thermostat. """
|
||||
"""Update the data from the thermostat."""
|
||||
self._pdp.update()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the thermostat. """
|
||||
"""Return the name of the thermostat."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
"""Return the device specific state attributes."""
|
||||
return {
|
||||
"fan": self._pdp.fan_state
|
||||
}
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Returns the unit of measurement. """
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return self._pdp.cur_temp
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._pdp.setback_heat
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns the current state of the thermostat. """
|
||||
"""Return the current state of the thermostat."""
|
||||
state = self._pdp.hvac_state
|
||||
if state in (1, 2):
|
||||
return STATE_IDLE
|
||||
@ -86,5 +85,5 @@ class ProliphixThermostat(ThermostatDevice):
|
||||
return STATE_COOL
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature. """
|
||||
"""Set new target temperature."""
|
||||
self._pdp.setback_heat = temperature
|
||||
|
@ -1,7 +1,5 @@
|
||||
"""
|
||||
homeassistant.components.thermostat.radiotherm
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Radio Thermostat wifi-enabled home thermostats.
|
||||
Support for Radio Thermostat wifi-enabled home thermostats.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
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):
|
||||
""" Sets up the Radio Thermostat. """
|
||||
"""Setup the Radio Thermostat."""
|
||||
import radiotherm
|
||||
|
||||
hosts = []
|
||||
@ -48,9 +46,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class RadioThermostat(ThermostatDevice):
|
||||
""" Represent a Radio Thermostat. """
|
||||
"""Representation of a Radio Thermostat."""
|
||||
|
||||
def __init__(self, device, hold_temp):
|
||||
"""Initialize the thermostat."""
|
||||
self.device = device
|
||||
self.set_time()
|
||||
self._target_temperature = None
|
||||
@ -62,17 +61,17 @@ class RadioThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the Radio Thermostat. """
|
||||
"""Return the name of the Radio Thermostat."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
"""Return the device specific state attributes."""
|
||||
return {
|
||||
"fan": self.device.fmode['human'],
|
||||
"mode": self.device.tmode['human']
|
||||
@ -80,22 +79,21 @@ class RadioThermostat(ThermostatDevice):
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
"""Return the current temperature."""
|
||||
return round(self._current_temperature, 1)
|
||||
|
||||
@property
|
||||
def operation(self):
|
||||
""" Returns current operation. head, cool idle """
|
||||
"""Return the current operation. head, cool idle."""
|
||||
return self._operation
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
|
||||
"""Return the temperature we try to reach."""
|
||||
return round(self._target_temperature, 1)
|
||||
|
||||
def update(self):
|
||||
""" Update the data from the thermostat. """
|
||||
"""Update the data from the thermostat."""
|
||||
self._current_temperature = self.device.temp['raw']
|
||||
self._name = self.device.name['raw']
|
||||
if self.device.tmode['human'] == 'Cool':
|
||||
@ -108,7 +106,7 @@ class RadioThermostat(ThermostatDevice):
|
||||
self._operation = STATE_IDLE
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
"""Set new target temperature."""
|
||||
if self._operation == STATE_COOL:
|
||||
self.device.t_cool = temperature
|
||||
elif self._operation == STATE_HEAT:
|
||||
@ -119,7 +117,7 @@ class RadioThermostat(ThermostatDevice):
|
||||
self.device.hold = 0
|
||||
|
||||
def set_time(self):
|
||||
""" Set device time """
|
||||
"""Set device time."""
|
||||
now = datetime.datetime.now()
|
||||
self.device.time = {'day': now.weekday(),
|
||||
'hour': now.hour, 'minute': now.minute}
|
||||
|
Loading…
x
Reference in New Issue
Block a user