Update docstrings (#7361)

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update docstrings

* Update tomato.py

* Update isy994.py

* Lint + fix tests

* Lint
This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2017-04-29 22:04:49 -07:00
1 parent e22e70a01a
commit 3ee4d1060f
264 files changed
+1686 -1768

No files matched your search

+42 -42
View File
@@ -23,45 +23,45 @@ from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, STATE_UNKNOWN,
TEMP_CELSIUS)
DOMAIN = "climate"
DOMAIN = 'climate'
ENTITY_ID_FORMAT = DOMAIN + ".{}"
ENTITY_ID_FORMAT = DOMAIN + '.{}'
SCAN_INTERVAL = timedelta(seconds=60)
SERVICE_SET_AWAY_MODE = "set_away_mode"
SERVICE_SET_AUX_HEAT = "set_aux_heat"
SERVICE_SET_TEMPERATURE = "set_temperature"
SERVICE_SET_FAN_MODE = "set_fan_mode"
SERVICE_SET_HOLD_MODE = "set_hold_mode"
SERVICE_SET_OPERATION_MODE = "set_operation_mode"
SERVICE_SET_SWING_MODE = "set_swing_mode"
SERVICE_SET_HUMIDITY = "set_humidity"
SERVICE_SET_AWAY_MODE = 'set_away_mode'
SERVICE_SET_AUX_HEAT = 'set_aux_heat'
SERVICE_SET_TEMPERATURE = 'set_temperature'
SERVICE_SET_FAN_MODE = 'set_fan_mode'
SERVICE_SET_HOLD_MODE = 'set_hold_mode'
SERVICE_SET_OPERATION_MODE = 'set_operation_mode'
SERVICE_SET_SWING_MODE = 'set_swing_mode'
SERVICE_SET_HUMIDITY = 'set_humidity'
STATE_HEAT = "heat"
STATE_COOL = "cool"
STATE_IDLE = "idle"
STATE_AUTO = "auto"
STATE_DRY = "dry"
STATE_FAN_ONLY = "fan_only"
STATE_HEAT = 'heat'
STATE_COOL = 'cool'
STATE_IDLE = 'idle'
STATE_AUTO = 'auto'
STATE_DRY = 'dry'
STATE_FAN_ONLY = 'fan_only'
ATTR_CURRENT_TEMPERATURE = "current_temperature"
ATTR_MAX_TEMP = "max_temp"
ATTR_MIN_TEMP = "min_temp"
ATTR_TARGET_TEMP_HIGH = "target_temp_high"
ATTR_TARGET_TEMP_LOW = "target_temp_low"
ATTR_AWAY_MODE = "away_mode"
ATTR_AUX_HEAT = "aux_heat"
ATTR_FAN_MODE = "fan_mode"
ATTR_FAN_LIST = "fan_list"
ATTR_CURRENT_HUMIDITY = "current_humidity"
ATTR_HUMIDITY = "humidity"
ATTR_MAX_HUMIDITY = "max_humidity"
ATTR_MIN_HUMIDITY = "min_humidity"
ATTR_HOLD_MODE = "hold_mode"
ATTR_OPERATION_MODE = "operation_mode"
ATTR_OPERATION_LIST = "operation_list"
ATTR_SWING_MODE = "swing_mode"
ATTR_SWING_LIST = "swing_list"
ATTR_CURRENT_TEMPERATURE = 'current_temperature'
ATTR_MAX_TEMP = 'max_temp'
ATTR_MIN_TEMP = 'min_temp'
ATTR_TARGET_TEMP_HIGH = 'target_temp_high'
ATTR_TARGET_TEMP_LOW = 'target_temp_low'
ATTR_AWAY_MODE = 'away_mode'
ATTR_AUX_HEAT = 'aux_heat'
ATTR_FAN_MODE = 'fan_mode'
ATTR_FAN_LIST = 'fan_list'
ATTR_CURRENT_HUMIDITY = 'current_humidity'
ATTR_HUMIDITY = 'humidity'
ATTR_MAX_HUMIDITY = 'max_humidity'
ATTR_MIN_HUMIDITY = 'min_humidity'
ATTR_HOLD_MODE = 'hold_mode'
ATTR_OPERATION_MODE = 'operation_mode'
ATTR_OPERATION_LIST = 'operation_list'
ATTR_SWING_MODE = 'swing_mode'
ATTR_SWING_LIST = 'swing_list'
# The degree of precision for each platform
PRECISION_WHOLE = 1
@@ -273,7 +273,7 @@ def async_setup(hass, config):
@asyncio.coroutine
def async_aux_heat_set_service(service):
"""Set auxillary heater on target climate devices."""
"""Set auxiliary heater on target climate devices."""
target_climate = component.async_extract_from_service(service)
aux_heat = service.data.get(ATTR_AUX_HEAT)
@@ -467,12 +467,12 @@ class ClimateDevice(Entity):
@property
def unit_of_measurement(self):
"""The unit of measurement to display."""
"""Return the unit of measurement to display."""
return self.hass.config.units.temperature_unit
@property
def temperature_unit(self):
"""The unit of measurement used by the platform."""
"""Return the unit of measurement used by the platform."""
raise NotImplementedError
@property
@@ -492,7 +492,7 @@ class ClimateDevice(Entity):
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
return None
@property
@@ -537,7 +537,7 @@ class ClimateDevice(Entity):
@property
def fan_list(self):
"""List of available fan modes."""
"""Return the list of available fan modes."""
return None
@property
@@ -547,7 +547,7 @@ class ClimateDevice(Entity):
@property
def swing_list(self):
"""List of available swing modes."""
"""Return the list of available swing modes."""
return None
def set_temperature(self, **kwargs):
@@ -695,8 +695,8 @@ class ClimateDevice(Entity):
if temp is None or not isinstance(temp, Number):
return temp
if self.temperature_unit != self.unit_of_measurement:
temp = convert_temperature(temp, self.temperature_unit,
self.unit_of_measurement)
temp = convert_temperature(
temp, self.temperature_unit, self.unit_of_measurement)
# Round in the units appropriate
if self.precision == PRECISION_HALVES:
return round(temp * 2) / 2.0
+13 -13
View File
@@ -10,14 +10,14 @@ from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Demo climate devices."""
"""Set up the Demo climate devices."""
add_devices([
DemoClimate("HeatPump", 68, TEMP_FAHRENHEIT, None, None, 77,
"Auto Low", None, None, "Auto", "heat", None, None, None),
DemoClimate("Hvac", 21, TEMP_CELSIUS, True, None, 22, "On High",
67, 54, "Off", "cool", False, None, None),
DemoClimate("Ecobee", None, TEMP_CELSIUS, None, None, 23, "Auto Low",
None, None, "Auto", "auto", None, 24, 21)
DemoClimate('HeatPump', 68, TEMP_FAHRENHEIT, None, None, 77,
'Auto Low', None, None, 'Auto', 'heat', None, None, None),
DemoClimate('Hvac', 21, TEMP_CELSIUS, True, None, 22, 'On High',
67, 54, 'Off', 'cool', False, None, None),
DemoClimate('Ecobee', None, TEMP_CELSIUS, None, None, 23, 'Auto Low',
None, None, 'Auto', 'auto', None, 24, 21)
])
@@ -41,15 +41,15 @@ class DemoClimate(ClimateDevice):
self._current_operation = current_operation
self._aux = aux
self._current_swing_mode = current_swing_mode
self._fan_list = ["On Low", "On High", "Auto Low", "Auto High", "Off"]
self._operation_list = ["heat", "cool", "auto", "off"]
self._swing_list = ["Auto", "1", "2", "3", "Off"]
self._fan_list = ['On Low', 'On High', 'Auto Low', 'Auto High', 'Off']
self._operation_list = ['heat', 'cool', 'auto', 'off']
self._swing_list = ['Auto', '1', '2', '3', 'Off']
self._target_temperature_high = target_temp_high
self._target_temperature_low = target_temp_low
@property
def should_poll(self):
"""Polling not needed for a demo climate device."""
"""Return the polling state."""
return False
@property
@@ -99,7 +99,7 @@ class DemoClimate(ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
return self._operation_list
@property
@@ -124,7 +124,7 @@ class DemoClimate(ClimateDevice):
@property
def fan_list(self):
"""List of available fan modes."""
"""Return the list of available fan modes."""
return self._fan_list
def set_temperature(self, **kwargs):
+15 -16
View File
@@ -45,7 +45,7 @@ RESUME_PROGRAM_SCHEMA = vol.Schema({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Ecobee Thermostat Platform."""
"""Set up the Ecobee Thermostat Platform."""
if discovery_info is None:
return
data = ecobee.NETWORK
@@ -197,19 +197,19 @@ class Thermostat(ClimateDevice):
if event['holdClimateRef'] == 'away':
if int(event['endDate'][0:4]) - \
int(event['startDate'][0:4]) <= 1:
# a temporary hold from away climate is a hold
# A temporary hold from away climate is a hold
return 'away'
else:
# a premanent hold from away climate is away_mode
# A permanent hold from away climate is away_mode
return None
elif event['holdClimateRef'] != "":
# any other hold based on climate
# Any other hold based on climate
return event['holdClimateRef']
else:
# any hold not based on a climate is a temp hold
# Any hold not based on a climate is a temp hold
return TEMPERATURE_HOLD
elif event['type'].startswith('auto'):
# all auto modes are treated as holds
# All auto modes are treated as holds
return event['type'][4:].lower()
elif event['type'] == 'vacation':
self.vacation = event['name']
@@ -300,17 +300,16 @@ class Thermostat(ClimateDevice):
return
elif hold_mode == 'None' or hold_mode is None:
if hold == VACATION_HOLD:
self.data.ecobee.delete_vacation(self.thermostat_index,
self.vacation)
self.data.ecobee.delete_vacation(
self.thermostat_index, self.vacation)
else:
self.data.ecobee.resume_program(self.thermostat_index)
else:
if hold_mode == TEMPERATURE_HOLD:
self.set_temp_hold(int(self.current_temperature))
else:
self.data.ecobee.set_climate_hold(self.thermostat_index,
hold_mode,
self.hold_preference())
self.data.ecobee.set_climate_hold(
self.thermostat_index, hold_mode, self.hold_preference())
self.update_without_throttle = True
def set_auto_temp_hold(self, heat_temp, cool_temp):
@@ -356,7 +355,7 @@ class Thermostat(ClimateDevice):
self.set_temp_hold(int(temp))
else:
_LOGGER.error(
'Missing valid arguments for set_temperature in %s', kwargs)
"Missing valid arguments for set_temperature in %s", kwargs)
def set_operation_mode(self, operation_mode):
"""Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
@@ -365,14 +364,14 @@ class Thermostat(ClimateDevice):
def set_fan_min_on_time(self, fan_min_on_time):
"""Set the minimum fan on time."""
self.data.ecobee.set_fan_min_on_time(self.thermostat_index,
fan_min_on_time)
self.data.ecobee.set_fan_min_on_time(
self.thermostat_index, fan_min_on_time)
self.update_without_throttle = True
def resume_program(self, resume_all):
"""Resume the thermostat schedule program."""
self.data.ecobee.resume_program(self.thermostat_index,
str(resume_all).lower())
self.data.ecobee.resume_program(
self.thermostat_index, str(resume_all).lower())
self.update_without_throttle = True
def hold_preference(self):
+11 -11
View File
@@ -21,15 +21,15 @@ REQUIREMENTS = ['python-eq3bt==0.1.5']
_LOGGER = logging.getLogger(__name__)
STATE_BOOST = "boost"
STATE_AWAY = "away"
STATE_MANUAL = "manual"
STATE_BOOST = 'boost'
STATE_AWAY = 'away'
STATE_MANUAL = 'manual'
ATTR_STATE_WINDOW_OPEN = "window_open"
ATTR_STATE_VALVE = "valve"
ATTR_STATE_LOCKED = "is_locked"
ATTR_STATE_LOW_BAT = "low_battery"
ATTR_STATE_AWAY_END = "away_end"
ATTR_STATE_WINDOW_OPEN = 'window_open'
ATTR_STATE_VALVE = 'valve'
ATTR_STATE_LOCKED = 'is_locked'
ATTR_STATE_LOW_BAT = 'low_battery'
ATTR_STATE_AWAY_END = 'away_end'
DEVICE_SCHEMA = vol.Schema({
vol.Required(CONF_MAC): cv.string,
@@ -42,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the eQ-3 BLE thermostats."""
"""Set up the eQ-3 BLE thermostats."""
devices = []
for name, device_cfg in config[CONF_DEVICES].items():
@@ -112,14 +112,14 @@ class EQ3BTSmartThermostat(ClimateDevice):
@property
def current_operation(self):
"""Current mode."""
"""Return the current operation mode."""
if self._thermostat.mode < 0:
return None
return self.modes[self._thermostat.mode]
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
return [x for x in self.modes.values()]
def set_operation_mode(self, operation_mode):
@@ -14,7 +14,8 @@ from homeassistant.components import switch
from homeassistant.components.climate import (
STATE_HEAT, STATE_COOL, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA)
from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE)
ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE,
CONF_NAME)
from homeassistant.helpers import condition
from homeassistant.helpers.event import (
async_track_state_change, async_track_time_interval)
@@ -27,7 +28,6 @@ DEPENDENCIES = ['switch', 'sensor']
DEFAULT_TOLERANCE = 0.3
DEFAULT_NAME = 'Generic Thermostat'
CONF_NAME = 'name'
CONF_HEATER = 'heater'
CONF_SENSOR = 'target_sensor'
CONF_MIN_TEMP = 'min_temp'
@@ -56,7 +56,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup the generic thermostat."""
"""Set up the generic thermostat platform."""
name = config.get(CONF_NAME)
heater_entity_id = config.get(CONF_HEATER)
sensor_entity_id = config.get(CONF_SENSOR)
@@ -74,7 +74,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
class GenericThermostat(ClimateDevice):
"""Representation of a GenericThermostat device."""
"""Representation of a Generic Thermostat device."""
def __init__(self, hass, name, heater_entity_id, sensor_entity_id,
min_temp, max_temp, target_temp, ac_mode, min_cycle_duration,
@@ -110,7 +110,7 @@ class GenericThermostat(ClimateDevice):
@property
def should_poll(self):
"""No polling needed."""
"""Return the polling state."""
return False
@property
@@ -175,7 +175,7 @@ class GenericThermostat(ClimateDevice):
@asyncio.coroutine
def _async_sensor_changed(self, entity_id, old_state, new_state):
"""Called when temperature changes."""
"""Handle temperature changes."""
if new_state is None:
return
@@ -185,14 +185,14 @@ class GenericThermostat(ClimateDevice):
@callback
def _async_switch_changed(self, entity_id, old_state, new_state):
"""Called when heater switch changes state."""
"""Handle heater switch state changes."""
if new_state is None:
return
self.hass.async_add_job(self.async_update_ha_state())
@callback
def _async_keep_alive(self, time):
"""Called at constant intervals for keep-alive purposes."""
"""Call at constant intervals for keep-alive purposes."""
if self.current_operation in [STATE_COOL, STATE_HEAT]:
switch.async_turn_on(self.hass, self.heater_entity_id)
else:
@@ -35,7 +35,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
# pylint: disable=unused-variable
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the heatmiser thermostat."""
"""Set up the heatmiser thermostat."""
from heatmiserV3 import heatmiser, connection
ipaddress = config.get(CONF_IPADDRESS)
+11 -14
View File
@@ -14,17 +14,17 @@ DEPENDENCIES = ['homematic']
_LOGGER = logging.getLogger(__name__)
STATE_MANUAL = "manual"
STATE_BOOST = "boost"
STATE_COMFORT = "comfort"
STATE_LOWERING = "lowering"
STATE_MANUAL = 'manual'
STATE_BOOST = 'boost'
STATE_COMFORT = 'comfort'
STATE_LOWERING = 'lowering'
HM_STATE_MAP = {
"AUTO_MODE": STATE_AUTO,
"MANU_MODE": STATE_MANUAL,
"BOOST_MODE": STATE_BOOST,
"COMFORT_MODE": STATE_COMFORT,
"LOWERING_MODE": STATE_LOWERING
'AUTO_MODE': STATE_AUTO,
'MANU_MODE': STATE_MANUAL,
'BOOST_MODE': STATE_BOOST,
'COMFORT_MODE': STATE_COMFORT,
'LOWERING_MODE': STATE_LOWERING
}
HM_TEMP_MAP = [
@@ -41,7 +41,7 @@ HM_CONTROL_MODE = 'CONTROL_MODE'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Homematic thermostat platform."""
"""Set up the Homematic thermostat platform."""
if discovery_info is None:
return
@@ -76,10 +76,9 @@ class HMThermostat(HMDevice, ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
op_list = []
# generate list
for mode in self._hmdevice.ACTIONNODE:
if mode in HM_STATE_MAP:
op_list.append(HM_STATE_MAP.get(mode))
@@ -132,11 +131,9 @@ class HMThermostat(HMDevice, ClimateDevice):
def _init_data_struct(self):
"""Generate a data dict (self._data) from the Homematic metadata."""
# Add state to data dict
self._state = next(iter(self._hmdevice.WRITENODE.keys()))
self._data[self._state] = STATE_UNKNOWN
# support state
if HM_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE:
self._data[HM_CONTROL_MODE] = STATE_UNKNOWN
+18 -19
View File
@@ -8,13 +8,12 @@ import logging
import socket
import datetime
import voluptuous as vol
import requests
import voluptuous as vol
from homeassistant.components.climate import (ClimateDevice, PLATFORM_SCHEMA,
ATTR_FAN_MODE, ATTR_FAN_LIST,
ATTR_OPERATION_MODE,
ATTR_OPERATION_LIST)
from homeassistant.components.climate import (
ClimateDevice, PLATFORM_SCHEMA, ATTR_FAN_MODE, ATTR_FAN_LIST,
ATTR_OPERATION_MODE, ATTR_OPERATION_LIST)
from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, TEMP_CELSIUS, TEMP_FAHRENHEIT,
ATTR_TEMPERATURE)
@@ -54,7 +53,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Honeywell thermostat."""
"""Set up the Honeywell thermostat."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
region = config.get(CONF_REGION)
@@ -66,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
def _setup_round(username, password, config, add_devices):
"""Setup rounding function."""
"""Set up the rounding function."""
from evohomeclient import EvohomeClient
away_temp = config.get(CONF_AWAY_TEMPERATURE)
@@ -87,16 +86,16 @@ def _setup_round(username, password, config, add_devices):
# config will be used later
def _setup_us(username, password, config, add_devices):
"""Setup user."""
"""Set up the user."""
import somecomfort
try:
client = somecomfort.SomeComfort(username, password)
except somecomfort.AuthError:
_LOGGER.error('Failed to login to honeywell account %s', username)
_LOGGER.error("Failed to login to honeywell account %s", username)
return False
except somecomfort.SomeComfortError as ex:
_LOGGER.error('Failed to initialize honeywell client: %s', str(ex))
_LOGGER.error("Failed to initialize honeywell client: %s", str(ex))
return False
dev_id = config.get('thermostat')
@@ -199,7 +198,7 @@ class RoundThermostat(ClimateDevice):
except StopIteration:
_LOGGER.error("Did not receive any temperature data from the "
"evohomeclient API.")
"evohomeclient API")
return
self._current_temperature = data['temp']
@@ -289,7 +288,7 @@ class HoneywellUSThermostat(ClimateDevice):
"setpoint_{}".format(mode),
temperature)
except somecomfort.SomeComfortError:
_LOGGER.error('Temperature %.1f out of range', temperature)
_LOGGER.error("Temperature %.1f out of range", temperature)
@property
def device_state_attributes(self):
@@ -369,8 +368,8 @@ class HoneywellUSThermostat(ClimateDevice):
raise exp
if not self._retry():
raise exp
_LOGGER.error("SomeComfort update failed, Retrying "
"- Error: %s", exp)
_LOGGER.error(
"SomeComfort update failed, Retrying - Error: %s", exp)
def _retry(self):
"""Recreate a new somecomfort client.
@@ -380,14 +379,14 @@ class HoneywellUSThermostat(ClimateDevice):
"""
import somecomfort
try:
self._client = somecomfort.SomeComfort(self._username,
self._password)
self._client = somecomfort.SomeComfort(
self._username, self._password)
except somecomfort.AuthError:
_LOGGER.error('Failed to login to honeywell account %s',
_LOGGER.error("Failed to login to honeywell account %s",
self._username)
return False
except somecomfort.SomeComfortError as ex:
_LOGGER.error('Failed to initialize honeywell client: %s',
_LOGGER.error("Failed to initialize honeywell client: %s",
str(ex))
return False
@@ -397,7 +396,7 @@ class HoneywellUSThermostat(ClimateDevice):
if device.name == self._device.name]
if len(devices) != 1:
_LOGGER.error('Failed to find device %s', self._device.name)
_LOGGER.error("Failed to find device %s", self._device.name)
return False
self._device = devices[0]
+1 -1
View File
@@ -61,7 +61,7 @@ class KNXThermostat(KNXMultiAddressDevice, ClimateDevice):
@property
def should_poll(self):
"""Polling is needed for the KNX thermostat."""
"""Return the polling state, is needed for the KNX thermostat."""
return True
@property
+6 -8
View File
@@ -20,7 +20,7 @@ STATE_VACATION = 'vacation'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Iterate through all MAX! Devices and add thermostats to HASS."""
"""Iterate through all MAX! Devices and add thermostats."""
cube = hass.data[MAXCUBE_HANDLE].cube
devices = []
@@ -29,9 +29,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
name = '{} {}'.format(
cube.room_by_id(device.room_id).name, device.name)
# Only add thermostats and wallthermostats
if cube.is_thermostat(device) or cube.is_wallthermostat(device):
# Add device to HASS
devices.append(MaxCubeClimate(hass, name, device.rf_address))
if devices:
@@ -52,12 +50,12 @@ class MaxCubeClimate(ClimateDevice):
@property
def should_poll(self):
"""Polling is required."""
"""Return the polling state."""
return True
@property
def name(self):
"""Return the name of the ClimateDevice."""
"""Return the name of the climate device."""
return self._name
@property
@@ -93,7 +91,7 @@ class MaxCubeClimate(ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
return self._operation_list
@property
@@ -148,7 +146,7 @@ class MaxCubeClimate(ClimateDevice):
@staticmethod
def map_mode_hass_max(operation_mode):
"""Map HASS Operation Modes to MAX! Operation Modes."""
"""Map Home Assistant Operation Modes to MAX! Operation Modes."""
from maxcube.device import \
MAX_DEVICE_MODE_AUTOMATIC, \
MAX_DEVICE_MODE_MANUAL, \
@@ -170,7 +168,7 @@ class MaxCubeClimate(ClimateDevice):
@staticmethod
def map_mode_max_hass(mode):
"""Map MAX! Operation Modes to HASS Operation Modes."""
"""Map MAX! Operation Modes to Home Assistant Operation Modes."""
from maxcube.device import \
MAX_DEVICE_MODE_AUTOMATIC, \
MAX_DEVICE_MODE_MANUAL, \
+23 -15
View File
@@ -1,8 +1,8 @@
"""
mysensors platform that offers a Climate(MySensors-HVAC) component.
MySensors platform that offers a Climate (MySensors-HVAC) component.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/climate.mysensors
https://home-assistant.io/components/climate.mysensors/
"""
import logging
@@ -14,14 +14,22 @@ from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
_LOGGER = logging.getLogger(__name__)
DICT_HA_TO_MYS = {STATE_COOL: "CoolOn", STATE_HEAT: "HeatOn",
STATE_AUTO: "AutoChangeOver", STATE_OFF: "Off"}
DICT_MYS_TO_HA = {"CoolOn": STATE_COOL, "HeatOn": STATE_HEAT,
"AutoChangeOver": STATE_AUTO, "Off": STATE_OFF}
DICT_HA_TO_MYS = {
STATE_AUTO: 'AutoChangeOver',
STATE_COOL: 'CoolOn',
STATE_HEAT: 'HeatOn',
STATE_OFF: 'Off',
}
DICT_MYS_TO_HA = {
'AutoChangeOver': STATE_AUTO,
'CoolOn': STATE_COOL,
'HeatOn': STATE_HEAT,
'Off': STATE_OFF,
}
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the mysensors climate."""
"""Set up the mysensors climate."""
if discovery_info is None:
return
@@ -43,7 +51,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
"""Representation of a MySensorsHVAC hvac."""
"""Representation of a MySensors HVAC."""
@property
def assumed_state(self):
@@ -105,7 +113,7 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
@property
def fan_list(self):
"""List of available fan modes."""
return ["Auto", "Min", "Normal", "Max"]
return ['Auto', 'Min', 'Normal', 'Max']
def set_temperature(self, **kwargs):
"""Set new target temperature."""
@@ -140,8 +148,8 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
def set_fan_mode(self, fan):
"""Set new target temperature."""
set_req = self.gateway.const.SetReq
self.gateway.set_child_value(self.node_id, self.child_id,
set_req.V_HVAC_SPEED, fan)
self.gateway.set_child_value(
self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan)
if self.gateway.optimistic:
# optimistically assume that switch has changed state
self._values[set_req.V_HVAC_SPEED] = fan
@@ -150,9 +158,9 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
def set_operation_mode(self, operation_mode):
"""Set new target temperature."""
set_req = self.gateway.const.SetReq
self.gateway.set_child_value(self.node_id, self.child_id,
set_req.V_HVAC_FLOW_STATE,
DICT_HA_TO_MYS[operation_mode])
self.gateway.set_child_value(
self.node_id, self.child_id, set_req.V_HVAC_FLOW_STATE,
DICT_HA_TO_MYS[operation_mode])
if self.gateway.optimistic:
# optimistically assume that switch has changed state
self._values[set_req.V_HVAC_FLOW_STATE] = operation_mode
@@ -165,7 +173,7 @@ class MySensorsHVAC(mysensors.MySensorsDeviceEntity, ClimateDevice):
child = node.children[self.child_id]
for value_type, value in child.values.items():
_LOGGER.debug(
'%s: value_type %s, value = %s', self._name, value_type, value)
"%s: value_type %s, value = %s", self._name, value_type, value)
if value_type == set_req.V_HVAC_FLOW_STATE:
self._values[value_type] = DICT_MYS_TO_HA[value]
else:
+1 -3
View File
@@ -30,12 +30,10 @@ STATE_HEAT_COOL = 'heat-cool'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Nest thermostat."""
"""Set up the Nest thermostat."""
if discovery_info is None:
return
_LOGGER.debug("Setting up nest thermostat")
temp_unit = hass.config.units.temperature_unit
add_devices(
+1 -2
View File
@@ -37,7 +37,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_callback_devices, discovery_info=None):
"""Setup the NetAtmo Thermostat."""
"""Set up the NetAtmo Thermostat."""
netatmo = get_component('netatmo')
device = config.get(CONF_RELAY)
@@ -150,7 +150,6 @@ class ThermostatData(object):
self.current_temperature = None
self.target_temperature = None
self.setpoint_mode = None
# self.operation =
def get_module_names(self):
"""Return all module available on the API as a list."""
+7 -15
View File
@@ -19,15 +19,12 @@ from homeassistant.const import (CONF_HOST, CONF_USERNAME, CONF_PASSWORD,
CONF_PORT, TEMP_CELSIUS, CONF_NAME)
import homeassistant.helpers.config_validation as cv
# Home Assistant depends on 3rd party packages for API specific code.
REQUIREMENTS = ['oemthermostat==1.1']
_LOGGER = logging.getLogger(__name__)
# Local configs
CONF_AWAY_TEMP = 'away_temp'
# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default="Thermostat"): cv.string,
@@ -39,11 +36,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup oemthermostat."""
"""Set up the oemthermostat platform."""
from oemthermostat import Thermostat
# Assign configuration variables. The configuration check takes care they
# are present.
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
port = config.get(CONF_PORT)
@@ -51,20 +46,17 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
password = config.get(CONF_PASSWORD)
away_temp = config.get(CONF_AWAY_TEMP)
# If creating the class raises an exception, it failed to connect or
# something else went wrong.
try:
therm = Thermostat(host, port=port,
username=username, password=password)
therm = Thermostat(
host, port=port, username=username, password=password)
except (ValueError, AssertionError, requests.RequestException):
return False
# Add devices
add_devices((ThermostatDevice(hass, therm, name, away_temp), ), True)
class ThermostatDevice(ClimateDevice):
"""Interface class for the oemthermostat module and HA."""
"""Interface class for the oemthermostat modul."""
def __init__(self, hass, thermostat, name, away_temp):
"""Initialize the device."""
@@ -87,12 +79,12 @@ class ThermostatDevice(ClimateDevice):
@property
def name(self):
"""Name of this Thermostat."""
"""Return the name of this Thermostat."""
return self._name
@property
def temperature_unit(self):
"""The unit of measurement used by the platform."""
"""Return the unit of measurement used by the platform."""
return TEMP_CELSIUS
@property
@@ -114,7 +106,7 @@ class ThermostatDevice(ClimateDevice):
return self._setpoint
def set_temperature(self, **kwargs):
"""Change the setpoint of the thermostat."""
"""Set the temperature."""
# If we are setting the temp, then we don't want away mode anymore.
self.turn_away_mode_off()
@@ -25,7 +25,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Proliphix thermostats."""
"""Set up the Proliphix thermostats."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
host = config.get(CONF_HOST)
@@ -43,7 +43,6 @@ class ProliphixThermostat(ClimateDevice):
def __init__(self, pdp):
"""Initialize the thermostat."""
self._pdp = pdp
# initial data
self._pdp.update()
self._name = self._pdp.name
@@ -40,7 +40,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Radio Thermostat."""
"""Set up the Radio Thermostat."""
import radiotherm
hosts = []
+4 -4
View File
@@ -87,7 +87,7 @@ class TadoClimate(ClimateDevice):
def __init__(self, store, zone_name, zone_id, data_id,
min_temp, max_temp, ac_mode,
tolerance=0.3):
"""Initialization of Tado climate device."""
"""Initialize of Tado climate device."""
self._store = store
self._data_id = data_id
@@ -113,7 +113,7 @@ class TadoClimate(ClimateDevice):
@property
def name(self):
"""Return the name of the sensor."""
"""Return the name of the device."""
return self.zone_name
@property
@@ -133,12 +133,12 @@ class TadoClimate(ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes (readable)."""
"""Return the list of available operation modes (readable)."""
return list(OPERATION_LIST.values())
@property
def temperature_unit(self):
"""The unit of measurement used by the platform."""
"""Return the unit of measurement used by the platform."""
return self._unit
@property
+12 -12
View File
@@ -20,12 +20,12 @@ DEPENDENCIES = ['vera']
_LOGGER = logging.getLogger(__name__)
OPERATION_LIST = ["Heat", "Cool", "Auto Changeover", "Off"]
FAN_OPERATION_LIST = ["On", "Auto", "Cycle"]
OPERATION_LIST = ['Heat', 'Cool', 'Auto Changeover', 'Off']
FAN_OPERATION_LIST = ['On', 'Auto', 'Cycle']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Find and return Vera thermostats."""
"""Set up of Vera thermostats."""
add_devices_callback(
VeraThermostat(device, VERA_CONTROLLER) for
device in VERA_DEVICES['climate'])
@@ -43,19 +43,19 @@ class VeraThermostat(VeraDevice, ClimateDevice):
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""
mode = self.vera_device.get_hvac_mode()
if mode == "HeatOn":
if mode == 'HeatOn':
return OPERATION_LIST[0] # heat
elif mode == "CoolOn":
elif mode == 'CoolOn':
return OPERATION_LIST[1] # cool
elif mode == "AutoChangeOver":
elif mode == 'AutoChangeOver':
return OPERATION_LIST[2] # auto
elif mode == "Off":
elif mode == 'Off':
return OPERATION_LIST[3] # off
return "Off"
return 'Off'
@property
def operation_list(self):
"""List of available operation modes."""
"""Return the list of available operation modes."""
return OPERATION_LIST
@property
@@ -72,7 +72,7 @@ class VeraThermostat(VeraDevice, ClimateDevice):
@property
def fan_list(self):
"""List of available fan modes."""
"""Return a list of available fan modes."""
return FAN_OPERATION_LIST
def set_fan_mode(self, mode):
@@ -86,13 +86,13 @@ class VeraThermostat(VeraDevice, ClimateDevice):
@property
def current_power_w(self):
"""Current power usage in W."""
"""Return the current power usage in W."""
power = self.vera_device.power
if power:
return convert(power, float, 0.0)
def update(self):
"""Called by the vera device callback to update state."""
"""Handle state updates."""
self._state = self.vera_device.get_hvac_mode()
@property
+2 -2
View File
@@ -30,7 +30,7 @@ ATTR_OCCUPIED = "occupied"
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Wink thermostat."""
"""Set up the Wink thermostat."""
import pywink
temp_unit = hass.config.units.temperature_unit
for climate in pywink.get_thermostats():
@@ -449,7 +449,7 @@ class WinkAC(WinkDevice, ClimateDevice):
@property
def fan_list(self):
"""List of available fan modes."""
"""Return a list of available fan modes."""
return [SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def set_fan_mode(self, mode):
+7 -7
View File
@@ -33,7 +33,7 @@ DEVICE_MAPPINGS = {
def get_device(hass, values, **kwargs):
"""Create zwave entity device."""
"""Create Z-Wave entity device."""
temp_unit = hass.config.units.temperature_unit
return ZWaveClimate(values, temp_unit)
@@ -65,13 +65,13 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
int(self.node.product_id, 16))
if specific_sensor_key in DEVICE_MAPPINGS:
if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_ZXT_120:
_LOGGER.debug("Remotec ZXT-120 Zwave Thermostat"
" workaround")
_LOGGER.debug(
"Remotec ZXT-120 Zwave Thermostat workaround")
self._zxt_120 = 1
self.update_properties()
def update_properties(self):
"""Callback on data changes for node values."""
"""Handle the data changes for node values."""
# Operation Mode
if self.values.mode:
self._current_operation = self.values.mode.data
@@ -134,7 +134,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
@property
def fan_list(self):
"""List of available fan modes."""
"""Return a list of available fan modes."""
return self._fan_list
@property
@@ -144,7 +144,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
@property
def swing_list(self):
"""List of available swing modes."""
"""Return a list of available swing modes."""
return self._swing_list
@property
@@ -169,7 +169,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
@property
def operation_list(self):
"""List of available operation modes."""
"""Return a list of available operation modes."""
return self._operation_list
@property