From 27d524893750278f62503b3f28299fd48d2fbc95 Mon Sep 17 00:00:00 2001 From: Todd Ingarfield Date: Mon, 19 Oct 2015 15:33:23 -0500 Subject: [PATCH 01/88] Fix configuration for multiple hosts and add example configuration.yaml section --- homeassistant/components/thermostat/radiotherm.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 3acd3ef8986..6cd886149be 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -2,6 +2,18 @@ homeassistant.components.thermostat.radiotherm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adds support for Radio Thermostat wifi-enabled home thermostats + +Config: + +Example: +thermostat: + platform: radiotherm + host: + - 192.168.99.137 + - 192.168.99.202 + +Configure two thermostats via the configuration.yaml + """ import logging import datetime @@ -22,7 +34,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): hosts = [] if CONF_HOST in config: - hosts = [config[CONF_HOST]] + hosts = config[CONF_HOST] else: hosts.append(radiotherm.discover.discover_address()) From 9464e2a13bbbaa3f9cc59b03668bb756e629d2b0 Mon Sep 17 00:00:00 2001 From: Todd Ingarfield Date: Mon, 19 Oct 2015 16:18:45 -0500 Subject: [PATCH 02/88] Add hass configuration parameter hold_temp & config documentation --- .../components/thermostat/radiotherm.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 6cd886149be..3de6fafd75d 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -4,15 +4,23 @@ homeassistant.components.thermostat.radiotherm Adds support for Radio Thermostat wifi-enabled home thermostats Config: +thermostat: + platform: radiotherm + hold_temp: boolean to control if hass temp adjustments hold(True) or are temporary(False) + host: list of thermostat host/ips to control Example: thermostat: platform: radiotherm + hold_temp: True host: - 192.168.99.137 - 192.168.99.202 -Configure two thermostats via the configuration.yaml +Configure two thermostats via the configuration.yaml. Temperature settings sent from +hass will be sent to thermostat and then hold at that temp. Set to False if you set +a thermostat schedule on the tstat itself and just want hass to send temporary temp +changes. """ import logging @@ -25,6 +33,8 @@ from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT) REQUIREMENTS = ['radiotherm==1.2'] +HOLD_TEMP = 'hold_temp' + def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the Radio Thermostat. """ @@ -42,12 +52,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None): logger.error("no radiotherm thermostats detected") return + hold_temp = config.get(HOLD_TEMP, False) tstats = [] for host in hosts: try: tstat = radiotherm.get_thermostat(host) - tstats.append(RadioThermostat(tstat)) + tstats.append(RadioThermostat(tstat, hold_temp)) except (URLError, OSError): logger.exception( "Unable to connect to Radio Thermostat: %s", host) @@ -58,13 +69,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class RadioThermostat(ThermostatDevice): """ Represent a Radio Thermostat. """ - def __init__(self, device): + def __init__(self, device, hold_temp): self.device = device self.set_time() self._target_temperature = None self._current_temperature = None self._operation = STATE_IDLE self._name = None + self.hold_temp = hold_temp self.update() @property @@ -119,7 +131,10 @@ class RadioThermostat(ThermostatDevice): self.device.t_cool = temperature elif self._operation == STATE_HEAT: self.device.t_heat = temperature - self.device.hold = 1 + if self.hold_temp: + self.device.hold = 1 + else: + self.device.hold = 0 def set_time(self): """ Set device time """ From 661f4c594e749d512c78af5ff89804b8c7cc7e20 Mon Sep 17 00:00:00 2001 From: Todd Ingarfield Date: Mon, 19 Oct 2015 16:54:42 -0500 Subject: [PATCH 03/88] formatting --- homeassistant/components/thermostat/radiotherm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 3de6fafd75d..831fd18f009 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -6,7 +6,8 @@ Adds support for Radio Thermostat wifi-enabled home thermostats Config: thermostat: platform: radiotherm - hold_temp: boolean to control if hass temp adjustments hold(True) or are temporary(False) + hold_temp: boolean to control if hass temp adjustments hold(True) or are + temporary(False) host: list of thermostat host/ips to control Example: @@ -17,10 +18,10 @@ thermostat: - 192.168.99.137 - 192.168.99.202 -Configure two thermostats via the configuration.yaml. Temperature settings sent from -hass will be sent to thermostat and then hold at that temp. Set to False if you set -a thermostat schedule on the tstat itself and just want hass to send temporary temp -changes. +Configure two thermostats via the configuration.yaml. Temperature settings +sent from hass will be sent to thermostat and then hold at that temp. Set +to False if you set a thermostat schedule on the tstat itself and just want +hass to send temporary temp changes. """ import logging From 293ed275ab4a659248dbf0e70d5ee5c674a45757 Mon Sep 17 00:00:00 2001 From: Nolan Gilley Date: Tue, 20 Oct 2015 14:29:22 -0400 Subject: [PATCH 04/88] Added support for specifying units in the configuration file. If no units are specified in the config file it will use location to determine the units. --- homeassistant/components/sensor/forecast.py | 94 ++++++++++++--------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/homeassistant/components/sensor/forecast.py b/homeassistant/components/sensor/forecast.py index 2c966530967..8fe39c67114 100644 --- a/homeassistant/components/sensor/forecast.py +++ b/homeassistant/components/sensor/forecast.py @@ -24,6 +24,7 @@ sensor: - pressure - visibility - ozone + units: si, us, ca, uk, uk2 or auto(default) Variables: @@ -33,15 +34,16 @@ To retrieve this value log into your account at http://forecast.io/. You can make 1000 requests per day. This means that you could create every 1.4 minute one. -monitored_conditions -*Required -An array specifying the conditions to monitor. - monitored_conditions *Required Conditions to monitor. See the configuration example above for a list of all available conditions to monitor. +units +*Optional +Specify the unit system. Default to 'auto' which is based on location. +Other options are us, si, ca, uk, and uk2. For more info see API link below. + Details for the API : https://developer.forecast.io/docs/v2 """ import logging @@ -55,23 +57,26 @@ except ImportError: forecastio = None from homeassistant.util import Throttle -from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS, TEMP_FAHRENHEIT) +from homeassistant.const import (CONF_API_KEY) from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) + +# Sensor types are defined like so: +# Name, si unit, us unit, ca unit, uk unit, uk2 unit SENSOR_TYPES = { - 'summary': ['Summary', ''], - 'precip_type': ['Precip', ''], - 'precip_intensity': ['Precip intensity', 'mm'], - 'temperature': ['Temperature', ''], - 'dew_point': ['Dew point', '°C'], - 'wind_speed': ['Wind Speed', 'm/s'], - 'wind_bearing': ['Wind Bearing', '°'], - 'cloud_cover': ['Cloud coverage', '%'], - 'humidity': ['Humidity', '%'], - 'pressure': ['Pressure', 'mBar'], - 'visibility': ['Visibility', 'km'], - 'ozone': ['Ozone', 'DU'], + 'summary': ['Summary', '', '', '', '', ''], + 'precip_type': ['Precip', '', '', '', '', ''], + 'precip_intensity': ['Precip intensity', 'mm', 'in', 'mm', 'mm', 'mm'], + 'temperature': ['Temperature', '°C', '°F', '°C', '°C', '°C'], + 'dew_point': ['Dew point', '°C', '°F', '°C', '°C', '°C'], + 'wind_speed': ['Wind Speed', 'm/s', 'mph', 'km/h', 'mph', 'mph'], + 'wind_bearing': ['Wind Bearing', '°', '°', '°', '°', '°'], + 'cloud_cover': ['Cloud coverage', '%', '%', '%', '%', '%'], + 'humidity': ['Humidity', '%', '%', '%', '%', '%'], + 'pressure': ['Pressure', 'mBar', 'mBar', 'mBar', 'mBar', 'mBar'], + 'visibility': ['Visibility', 'km', 'm', 'km', 'km', 'm'], + 'ozone': ['Ozone', 'DU', 'DU', 'DU', 'DU', 'DU'], } # Return cached results if last scan was less then this time ago @@ -90,9 +95,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.error("Latitude or longitude not set in Home Assistant config") return False - SENSOR_TYPES['temperature'][1] = hass.config.temperature_unit - unit = hass.config.temperature_unit - try: forecast = forecastio.load_forecast(config.get(CONF_API_KEY, None), hass.config.latitude, @@ -104,16 +106,21 @@ def setup_platform(hass, config, add_devices, discovery_info=None): "Please check your settings for Forecast.io.") return False + units = config.get('units') + if units is None: + units = 'auto' + data = ForeCastData(config.get(CONF_API_KEY, None), hass.config.latitude, - hass.config.longitude) + hass.config.longitude, + units) dev = [] for variable in config['monitored_conditions']: if variable not in SENSOR_TYPES: _LOGGER.error('Sensor type: "%s" does not exist', variable) else: - dev.append(ForeCastSensor(data, variable, unit)) + dev.append(ForeCastSensor(data, variable)) add_devices(dev) @@ -122,14 +129,23 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class ForeCastSensor(Entity): """ Implements an Forecast.io sensor. """ - def __init__(self, weather_data, sensor_type, unit): + def __init__(self, weather_data, sensor_type): self.client_name = 'Weather' self._name = SENSOR_TYPES[sensor_type][0] self.forecast_client = weather_data - self._unit = unit self.type = sensor_type self._state = None - self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] + self._unit_system = self.forecast_client.unit_system + if self._unit_system == 'si': + self._unit_of_measurement = SENSOR_TYPES[self.type][1] + elif self._unit_system == 'us': + self._unit_of_measurement = SENSOR_TYPES[self.type][2] + elif self._unit_system == 'ca': + self._unit_of_measurement = SENSOR_TYPES[self.type][3] + elif self._unit_system == 'uk': + self._unit_of_measurement = SENSOR_TYPES[self.type][4] + elif self._unit_system == 'uk2': + self._unit_of_measurement = SENSOR_TYPES[self.type][5] self.update() @property @@ -146,6 +162,11 @@ class ForeCastSensor(Entity): """ Unit of measurement of this entity, if any. """ return self._unit_of_measurement + @property + def unit_system(self): + """ Unit system of this entity. """ + return self._unit_system + # pylint: disable=too-many-branches def update(self): """ Gets the latest data from Forecast.io and updates the states. """ @@ -169,19 +190,9 @@ class ForeCastSensor(Entity): else: self._state = data.precipType elif self.type == 'dew_point': - if self._unit == TEMP_CELCIUS: - self._state = round(data.dewPoint, 1) - elif self._unit == TEMP_FAHRENHEIT: - self._state = round(data.dewPoint * 1.8 + 32.0, 1) - else: - self._state = round(data.dewPoint, 1) + self._state = round(data.dewPoint, 1) elif self.type == 'temperature': - if self._unit == TEMP_CELCIUS: - self._state = round(data.temperature, 1) - elif self._unit == TEMP_FAHRENHEIT: - self._state = round(data.temperature * 1.8 + 32.0, 1) - else: - self._state = round(data.temperature, 1) + self._state = round(data.temperature, 1) elif self.type == 'wind_speed': self._state = data.windSpeed elif self.type == 'wind_bearing': @@ -196,6 +207,7 @@ class ForeCastSensor(Entity): self._state = data.visibility elif self.type == 'ozone': self._state = round(data.ozone, 1) + except forecastio.utils.PropertyUnavailable: pass @@ -203,11 +215,14 @@ class ForeCastSensor(Entity): class ForeCastData(object): """ Gets the latest data from Forecast.io. """ - def __init__(self, api_key, latitude, longitude): + def __init__(self, api_key, latitude, longitude, units): self._api_key = api_key self.latitude = latitude self.longitude = longitude self.data = None + self.unit_system = None + self.units = units + self.update() @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): @@ -216,5 +231,6 @@ class ForeCastData(object): forecast = forecastio.load_forecast(self._api_key, self.latitude, self.longitude, - units='si') + units=self.units) self.data = forecast.currently() + self.unit_system = forecast.json['flags']['units'] From f8590f7d1d874d53927e34feb53f4068ed631694 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 18 Oct 2015 01:25:36 +0200 Subject: [PATCH 05/88] Include resource in error message --- homeassistant/components/switch/arest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/arest.py b/homeassistant/components/switch/arest.py index b043fe9e896..c7a7103e7e2 100644 --- a/homeassistant/components/switch/arest.py +++ b/homeassistant/components/switch/arest.py @@ -28,8 +28,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): "Add http:// to your URL.") return False except requests.exceptions.ConnectionError: - _LOGGER.error("No route to device. " - "Please check the IP address in the configuration file.") + _LOGGER.error("No route to device at %s. " + "Please check the IP address in the configuration file.", + resource) return False dev = [] From bbed4a262cef1acc305d08d670c275115140c7b8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 18 Oct 2015 18:22:05 +0200 Subject: [PATCH 06/88] Fix typo --- homeassistant/components/thermostat/heat_control.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/thermostat/heat_control.py b/homeassistant/components/thermostat/heat_control.py index c1dab1173d7..f14d1b16f16 100644 --- a/homeassistant/components/thermostat/heat_control.py +++ b/homeassistant/components/thermostat/heat_control.py @@ -192,9 +192,7 @@ class HeatControl(ThermostatDevice): @property def is_away_mode_on(self): - """ - Returns if away mode is on. - """ + """ Returns if away mode is on. """ return self._away def turn_away_mode_on(self): @@ -212,5 +210,5 @@ class HeatControl(ThermostatDevice): @property def max_temp(self): - """ Return maxmum temperature. """ + """ Return maximum temperature. """ return self._max_temp From f45e0eabe3762b6cfb87a44227f9beb5e7224e4d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 18 Oct 2015 19:45:24 +0200 Subject: [PATCH 07/88] Add link to docs --- homeassistant/components/thermostat/nest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index 656becd6a21..4179d1a1c70 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -2,6 +2,9 @@ homeassistant.components.thermostat.nest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adds support for Nest thermostats. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/thermostat.nest.html """ import socket import logging @@ -44,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ]) except socket.error: logger.error( - "Connection error logging into the nest web service" + "Connection error logging into the nest web service." ) From 4d5c9581bf5cfd976a1db3de8c5eaee552c5e6dd Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 18 Oct 2015 20:05:53 +0200 Subject: [PATCH 08/88] Add link to docs --- .../components/thermostat/heat_control.py | 55 +------------------ 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/homeassistant/components/thermostat/heat_control.py b/homeassistant/components/thermostat/heat_control.py index f14d1b16f16..b783b210606 100644 --- a/homeassistant/components/thermostat/heat_control.py +++ b/homeassistant/components/thermostat/heat_control.py @@ -3,59 +3,8 @@ homeassistant.components.thermostat.heat_control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adds support for a thermostat. -Specify a start time, end time and a target temperature. -If the the current temperature is lower than the target temperature, -and the time is between start time and end time, the heater will -be turned on. Opposite if the the temperature is higher than the -target temperature the heater will be turned off. - -If away mode is activated the target temperature is sat to a min -temperature (min_temp in config). The min temperature is also used -as target temperature when no other temperature is specified. - -If the heater is manually turned on, the target temperature will -be sat to 100*C. Meaning the thermostat probably will never turn -off the heater. -If the heater is manually turned off, the target temperature will -be sat according to normal rules. (Based on target temperature -for given time intervals and the min temperature.) - -A target temperature sat with the set_temperature function will -override all other rules for the target temperature. - -Config: - -[thermostat] -platform=heat_control - -name = Name of thermostat - -heater = entity_id for heater switch, - must be a toggle device - -target_sensor = entity_id for temperature sensor, - target_sensor.state must be temperature - -time_temp = start_time-end_time:target_temp, - -min_temp = minimum temperature, used when away mode is - active or no other temperature specified. - -Example: -[thermostat] -platform=heat_control -name = Stue -heater = switch.Ovn_stue -target_sensor = tellstick_sensor.Stue_temperature -time_temp = 0700-0745:17,1500-1850:20 -min_temp = 10 - -For the example the heater will turn on at 0700 if the temperature -is lower than 17*C away mode is false. Between 0700 and 0745 the -target temperature will be 17*C. Between 0745 and 1500 no temperature -is specified. so the min_temp of 10*C will be used. From 1500 to 1850 -the target temperature is 20*, but if away mode is true the target -temperature will be sat to 10*C +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/thermostat.heat_control.html """ import logging import datetime From 74700e4b1035d3d3a794f2f32adafc6ee33907e0 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:17:03 +0200 Subject: [PATCH 09/88] Add link to doc and remove configuration details --- .../components/sensor/openweathermap.py | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/homeassistant/components/sensor/openweathermap.py b/homeassistant/components/sensor/openweathermap.py index 9d33264ea70..d4510a0668c 100644 --- a/homeassistant/components/sensor/openweathermap.py +++ b/homeassistant/components/sensor/openweathermap.py @@ -3,43 +3,8 @@ homeassistant.components.sensor.openweathermap ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OpenWeatherMap (OWM) service. -Configuration: - -To use the OpenWeatherMap sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: openweathermap - api_key: YOUR_APP_KEY - forecast: 0 or 1 - monitored_conditions: - - weather - - temperature - - wind_speed - - humidity - - pressure - - clouds - - rain - - snow - -Variables: - -api_key -*Required -To retrieve this value log into your account at http://openweathermap.org/ - -forecast -*Optional -Enables the forecast. The default is to display the current conditions. - -monitored_conditions -*Required -Conditions to monitor. See the configuration example above for a -list of all available conditions to monitor. - -Details for the API : http://bugs.openweathermap.org/projects/api/wiki - -Only metric measurements are supported at the moment. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.openweathermap.html """ import logging from datetime import timedelta From 0e8e4a73fe96d296322cf4e78c817a36abc997c5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:19:28 +0200 Subject: [PATCH 10/88] Remove configuration details --- homeassistant/components/sensor/glances.py | 45 ---------------------- 1 file changed, 45 deletions(-) diff --git a/homeassistant/components/sensor/glances.py b/homeassistant/components/sensor/glances.py index f6031b5a131..0d20c329f41 100644 --- a/homeassistant/components/sensor/glances.py +++ b/homeassistant/components/sensor/glances.py @@ -3,51 +3,6 @@ homeassistant.components.sensor.glances ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gathers system information of hosts which running glances. -Configuration: - -To use the glances sensor you will need to add something like the following -to your configuration.yaml file. - -sensor: - platform: glances - name: Glances sensor - host: IP_ADDRESS - port: 61208 - resources: - - 'disk_use_percent' - - 'disk_use' - - 'disk_free' - - 'memory_use_percent' - - 'memory_use' - - 'memory_free' - - 'swap_use_percent' - - 'swap_use' - - 'swap_free' - - 'processor_load' - - 'process_running' - - 'process_total' - - 'process_thread' - - 'process_sleeping' - -Variables: - -name -*Optional -The name of the sensor. Default is 'Glances Sensor'. - -host -*Required -The IP address of your host, e.g. 192.168.1.32. - -port -*Optional -The network port to connect to. Default is 61208. - -resources -*Required -Resources to monitor on the host. See the configuration example above for a -list of all available conditions to monitor. - For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.glances.html """ From f5a62f83812379086065befb4a7b53865d12703d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:21:29 +0200 Subject: [PATCH 11/88] Remove configuration details --- homeassistant/components/sensor/dht.py | 34 ++------------------------ 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/homeassistant/components/sensor/dht.py b/homeassistant/components/sensor/dht.py index 2ce0b12be38..218b1b7c3bc 100644 --- a/homeassistant/components/sensor/dht.py +++ b/homeassistant/components/sensor/dht.py @@ -2,39 +2,9 @@ homeassistant.components.sensor.dht ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adafruit DHT temperature and humidity sensor. -You need a Python3 compatible version of the Adafruit_Python_DHT library -(e.g. https://github.com/mala-zaba/Adafruit_Python_DHT, -also see requirements.txt). -As this requires access to the GPIO, you will need to run home-assistant -as root. -Configuration: - -To use the Adafruit DHT sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: dht - sensor: DHT22 - pin: 23 - monitored_conditions: - - temperature - - humidity - -Variables: - -sensor -*Required -The sensor type, DHT11, DHT22 or AM2302 - -pin -*Required -The pin the sensor is connected to, something like -'P8_11' for Beaglebone, '23' for Raspberry Pi - -monitored_conditions -*Optional -Conditions to monitor. Available conditions are temperature and humidity. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.dht.html """ import logging from datetime import timedelta From c473d426e39d337ab590710a18b67a41d9ddb86b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:24:11 +0200 Subject: [PATCH 12/88] Remove configuration details --- homeassistant/components/sensor/efergy.py | 43 ++--------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/homeassistant/components/sensor/efergy.py b/homeassistant/components/sensor/efergy.py index aed685dce67..8bc8a668cca 100644 --- a/homeassistant/components/sensor/efergy.py +++ b/homeassistant/components/sensor/efergy.py @@ -4,47 +4,8 @@ homeassistant.components.sensor.efergy Monitors home energy use as measured by an efergy engage hub using its (unofficial, undocumented) API. -Configuration: - -To use the efergy sensor you will need to add something like the following -to your configuration.yaml file. - -sensor: - platform: efergy - app_token: APP_TOKEN - utc_offset: UTC_OFFSET - monitored_variables: - - type: instant_readings - - type: budget - - type: cost - period: day - currency: $ - -Variables: - -api_key -*Required -To get a new App Token, log in to your efergy account, go -to the Settings page, click on App tokens, and click "Add token". - -utc_offset -*Required for some variables -Some variables (currently only the daily_cost) require that the -negative number of minutes your timezone is ahead/behind UTC time. - -monitored_variables -*Required -An array specifying the variables to monitor. - -period -*Optional -Some variables take a period argument. Valid options are "day", "week", -"month", and "year". - -currency -*Optional -This is used to display the cost/period as the unit when monitoring the -cost. It should correspond to the actual currency used in your dashboard. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.efergy.html """ import logging from requests import get From 8c544a89c9526825d37c2dc869b7d3b56d833699 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:25:01 +0200 Subject: [PATCH 13/88] Remove configuration details --- .../components/sensor/command_sensor.py | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/homeassistant/components/sensor/command_sensor.py b/homeassistant/components/sensor/command_sensor.py index a6e6c19fdb8..fc651fcc157 100644 --- a/homeassistant/components/sensor/command_sensor.py +++ b/homeassistant/components/sensor/command_sensor.py @@ -3,41 +3,6 @@ homeassistant.components.sensor.command_sensor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to configure custom shell commands to turn a value for a sensor. -Configuration: - -To use the command_line sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: command_sensor - name: "Command sensor" - command: sensor_command - unit_of_measurement: "°C" - correction_factor: 0.0001 - decimal_places: 0 - -Variables: - -name -*Optional -Name of the command sensor. - -command -*Required -The action to take to get the value. - -unit_of_measurement -*Optional -Defines the units of measurement of the sensor, if any. - -correction_factor -*Optional -A float value to do some basic calculations. - -decimal_places -*Optional -Number of decimal places of the value. Default is 0. - For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.command_sensor.html """ From c1a73d250ab5f6c55e97664f682a0de17479d6a8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:27:40 +0200 Subject: [PATCH 14/88] Add link to component --- homeassistant/components/sensor/zwave.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/sensor/zwave.py b/homeassistant/components/sensor/zwave.py index b63e64156a3..0cd136421a0 100644 --- a/homeassistant/components/sensor/zwave.py +++ b/homeassistant/components/sensor/zwave.py @@ -2,6 +2,9 @@ homeassistant.components.sensor.zwave ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Interfaces with Z-Wave sensors. + +For more details about the zwave component, please refer to the documentation +at https://home-assistant.io/components/zwave.html """ # pylint: disable=import-error from openzwave.network import ZWaveNetwork From 5a21b677a18b4e3cb68c20328149ce9f2bb7412b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:29:19 +0200 Subject: [PATCH 15/88] Add link to component --- homeassistant/components/sensor/wink.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/sensor/wink.py b/homeassistant/components/sensor/wink.py index 39c8ce4671f..51422eab4ba 100644 --- a/homeassistant/components/sensor/wink.py +++ b/homeassistant/components/sensor/wink.py @@ -2,6 +2,9 @@ homeassistant.components.sensor.wink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Wink sensors. + +For more details about the wink component, please refer to the documentation +at https://home-assistant.io/components/wink.html """ import logging From 02cfc70ad521662a34239d8ddd7b2ea18e91bbe3 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 21:31:25 +0200 Subject: [PATCH 16/88] Add link to component --- homeassistant/components/sensor/verisure.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/verisure.py b/homeassistant/components/sensor/verisure.py index 47efa197870..89c0778ead2 100644 --- a/homeassistant/components/sensor/verisure.py +++ b/homeassistant/components/sensor/verisure.py @@ -1,7 +1,10 @@ """ homeassistant.components.sensor.verisure -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Interfaces with Verisure sensors. + +For more details about the verisure component, please refer to the +documentation at https://home-assistant.io/components/verisure.html """ import logging From 72ad1387f09100fd98ddc0186638d429c548121a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:07:24 +0200 Subject: [PATCH 17/88] Move configuration details to docs --- homeassistant/components/light/vera.py | 48 ++------------------------ 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index f41bfb56685..dc447f2e4b5 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -1,52 +1,10 @@ """ homeassistant.components.light.vera ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Support for Vera lights. This component is useful if you wish for switches -connected to your Vera controller to appear as lights in Home Assistant. -All switches will be added as a light unless you exclude them in the config. - -Configuration: - -To use the Vera lights you will need to add something like the following to -your configuration.yaml file. - -light: - platform: vera - vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - 12: - name: My awesome switch - exclude: true - 13: - name: Another switch - -Variables: - -vera_controller_url -*Required -This is the base URL of your vera controller including the port number if not -running on 80. Example: http://192.168.1.21:3480/ - -device_data -*Optional -This contains an array additional device info for your Vera devices. It is not -required and if not specified all lights configured in your Vera controller -will be added with default values. You should use the id of your vera device -as the key for the device within device_data. - -These are the variables for the device_data array: - -name -*Optional -This parameter allows you to override the name of your Vera device in the HA -interface, if not specified the value configured for the device in your Vera -will be used. - -exclude -*Optional -This parameter allows you to exclude the specified device from Home Assistant, -it should be set to "true" if you want this device excluded. +Support for Vera lights. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/light.vera.html """ import logging from requests.exceptions import RequestException From 5e56eae28f464e02f9437ce7187dd7ebbc79752c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:08:06 +0200 Subject: [PATCH 18/88] Move configuration details to docs --- homeassistant/components/sensor/vera.py | 44 ++----------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index b02e3acdea0..ec8896f5c07 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -3,48 +3,8 @@ homeassistant.components.sensor.vera ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Vera sensors. -Configuration: - -To use the Vera sensors you will need to add something like the following to -your configuration.yaml file. - -sensor: - platform: vera - vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - 12: - name: My awesome sensor - exclude: true - 13: - name: Another sensor - -Variables: - -vera_controller_url -*Required -This is the base URL of your vera controller including the port number if not -running on 80, e.g. http://192.168.1.21:3480/ - - -device_data -*Optional -This contains an array additional device info for your Vera devices. It is not -required and if not specified all sensors configured in your Vera controller -will be added with default values. You should use the id of your vera device -as the key for the device within device_data. - -These are the variables for the device_data array: - -name -*Optional -This parameter allows you to override the name of your Vera device in the HA -interface, if not specified the value configured for the device in your Vera -will be used. - -exclude -*Optional -This parameter allows you to exclude the specified device from Home Assistant, -it should be set to "true" if you want this device excluded. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.vera.html """ import logging from requests.exceptions import RequestException From f945a3a69245f25eb664c14b666de29a9c51a7d4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:08:20 +0200 Subject: [PATCH 19/88] Move configuration details to docs --- homeassistant/components/switch/vera.py | 42 ++----------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 548e6ca89a9..ecf922e8cfa 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -3,46 +3,8 @@ homeassistant.components.switch.vera ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Vera switches. -Configuration: -To use the Vera lights you will need to add something like the following to -your configuration.yaml file. - -switch: - platform: vera - vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - 12: - name: My awesome switch - exclude: true - 13: - name: Another Switch - -Variables: - -vera_controller_url -*Required -This is the base URL of your vera controller including the port number if not -running on 80. Example: http://192.168.1.21:3480/ - -device_data -*Optional -This contains an array additional device info for your Vera devices. It is not -required and if not specified all lights configured in your Vera controller -will be added with default values. You should use the id of your vera device -as the key for the device within device_data. - -These are the variables for the device_data array: - -name -*Optional -This parameter allows you to override the name of your Vera device in the HA -interface, if not specified the value configured for the device in your Vera -will be used. - -exclude -*Optional -This parameter allows you to exclude the specified device from homeassistant, -it should be set to "true" if you want this device excluded. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.vera.html """ import logging import time From ef129639bdbfa9d8386d3bb12a55c1f2ac4b7919 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:12:00 +0200 Subject: [PATCH 20/88] Remove configuration details --- .../components/sensor/transmission.py | 45 +------------------ 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/homeassistant/components/sensor/transmission.py b/homeassistant/components/sensor/transmission.py index 992a8838f3f..8c47f2dbb6f 100644 --- a/homeassistant/components/sensor/transmission.py +++ b/homeassistant/components/sensor/transmission.py @@ -3,49 +3,8 @@ homeassistant.components.sensor.transmission ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monitors Transmission BitTorrent client API. -Configuration: - -To use the Transmission sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: transmission - name: Transmission - host: 192.168.1.26 - port: 9091 - username: YOUR_USERNAME - password: YOUR_PASSWORD - monitored_variables: - - 'current_status' - - 'download_speed' - - 'upload_speed' - -Variables: - -host -*Required -This is the IP address of your Transmission daemon, e.g. 192.168.1.32 - -port -*Optional -The port your Transmission daemon uses, defaults to 9091. Example: 8080 - -username -*Required -Your Transmission username. - -password -*Required -Your Transmission password. - -name -*Optional -The name to use when displaying this Transmission instance. - -monitored_variables -*Required -Variables to monitor. See the configuration example above for a -list of all available variables to monitor. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.transmission.html """ from homeassistant.util import Throttle from datetime import timedelta From aed61cecff178d8b59f34ea01b4575d1ea0daf4f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:14:51 +0200 Subject: [PATCH 21/88] Remove configuration details --- homeassistant/components/sensor/temper.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/sensor/temper.py b/homeassistant/components/sensor/temper.py index c7943f0cc06..712b626406b 100644 --- a/homeassistant/components/sensor/temper.py +++ b/homeassistant/components/sensor/temper.py @@ -3,13 +3,8 @@ homeassistant.components.sensor.temper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for getting temperature from TEMPer devices. -Configuration: - -To use the temper sensors you will need to add something like the following to -your configuration.yaml file. - -sensor: - platform: temper +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.temper.html """ import logging from homeassistant.helpers.entity import Entity From 52b4c3b5a2e633b209c933dce772f695ed8ec83c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:15:53 +0200 Subject: [PATCH 22/88] Remove configuration details --- homeassistant/components/sensor/time_date.py | 23 ++------------------ 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/sensor/time_date.py b/homeassistant/components/sensor/time_date.py index 77011c3afad..8f0e4995356 100644 --- a/homeassistant/components/sensor/time_date.py +++ b/homeassistant/components/sensor/time_date.py @@ -3,27 +3,8 @@ homeassistant.components.sensor.time_date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Date and Time service. -Configuration: - -To use the Date and Time sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: time_date - display_options: - - 'time' - - 'date' - - 'date_time' - - 'time_date' - - 'time_utc' - - 'beat' - -Variables: - -display_options -*Required -The variable you wish to display. See the configuration example above for a -list of all available variables. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.time_date.html """ import logging From 5580309d98fd3cbf4fd5750caf2571db87cefcb2 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:19:04 +0200 Subject: [PATCH 23/88] Remove configuration details --- .../components/switch/hikvisioncam.py | 37 ++----------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/switch/hikvisioncam.py b/homeassistant/components/switch/hikvisioncam.py index 6ab82df482a..41def00daa2 100644 --- a/homeassistant/components/switch/hikvisioncam.py +++ b/homeassistant/components/switch/hikvisioncam.py @@ -3,39 +3,8 @@ homeassistant.components.switch.hikvision ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support turning on/off motion detection on Hikvision cameras. -Note: Currently works using default https port only. - -CGI API Guide: http://bit.ly/1RuyUuF - -Configuration: - -To use the Hikvision motion detection switch you will need to add something -like the following to your config/configuration.yaml - -switch: - platform: hikvisioncam - name: Hikvision Cam 1 Motion Detection - host: 192.168.1.32 - username: YOUR_USERNAME - password: YOUR_PASSWORD - -Variables: - -host -*Required -This is the IP address of your Hikvision camera. Example: 192.168.1.32 - -username -*Required -Your Hikvision camera username. - -password -*Required -Your Hikvision camera username. - -name -*Optional -The name to use when displaying this switch instance. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.hikvision.html """ from homeassistant.helpers.entity import ToggleEntity from homeassistant.const import STATE_ON, STATE_OFF @@ -55,7 +24,7 @@ REQUIREMENTS = ['hikvision==0.4'] def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Setup Hikvision Camera config. """ + """ Setup Hikvision camera. """ host = config.get(CONF_HOST, None) port = config.get('port', "80") From 761f225c8610430478f9a312a9423183de5dd7b1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 20 Oct 2015 22:20:03 +0200 Subject: [PATCH 24/88] Update link --- homeassistant/components/sensor/sabnzbd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index 7aeb14b27f5..98fa11d77a1 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -4,7 +4,7 @@ homeassistant.components.sensor.sabnzbd Monitors SABnzbd NZB client API. For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/light.sabnzbd.html +https://home-assistant.io/components/sensor.sabnzbd.html """ from homeassistant.util import Throttle from datetime import timedelta From b20a757454ae1b3a30b02f111de0f7bdce09a579 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:44:29 +0200 Subject: [PATCH 25/88] Remove configuration details --- homeassistant/components/wink.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index c05d9502ca7..5c304b5ee98 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -3,20 +3,8 @@ homeassistant.components.wink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connects to a Wink hub and loads relevant components to control its devices. -Configuration: - -To use the Wink component you will need to add something like the following -to your configuration.yaml file. - -wink: - access_token: YOUR_ACCESS_TOKEN - -Variables: - -access_token -*Required -Please check https://home-assistant.io/components/wink.html for further -details. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/wink.html """ import logging From da31b54d0691ea1096ec3cd72c7ff27aacdc109d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:45:08 +0200 Subject: [PATCH 26/88] Add link to docs --- homeassistant/components/light/wink.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/light/wink.py b/homeassistant/components/light/wink.py index 98988c20688..40b5b1883fc 100644 --- a/homeassistant/components/light/wink.py +++ b/homeassistant/components/light/wink.py @@ -2,6 +2,9 @@ homeassistant.components.light.wink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Wink lights. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/light.wink.html """ import logging From 916214959882ad8e54dac661e8ad6ebf7548ebba Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:47:12 +0200 Subject: [PATCH 27/88] Add link to docs --- homeassistant/components/sensor/wink.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/wink.py b/homeassistant/components/sensor/wink.py index 51422eab4ba..b998735e38c 100644 --- a/homeassistant/components/sensor/wink.py +++ b/homeassistant/components/sensor/wink.py @@ -4,7 +4,7 @@ homeassistant.components.sensor.wink Support for Wink sensors. For more details about the wink component, please refer to the documentation -at https://home-assistant.io/components/wink.html +at https://home-assistant.io/components/sensor.wink.html """ import logging @@ -25,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): if token is None: logging.getLogger(__name__).error( - "Missing wink access_token - " - "get one at https://winkbearertoken.appspot.com/") + "Missing wink access_token. " + "Get one at https://winkbearertoken.appspot.com/") return pywink.set_bearer_token(token) @@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class WinkSensorDevice(Entity): - """ Represents a wink sensor. """ + """ Represents a Wink sensor. """ def __init__(self, wink): self.wink = wink From 7ec1424825bf84d127352ff2567e9221c154af4e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:47:31 +0200 Subject: [PATCH 28/88] Add link to docs --- homeassistant/components/switch/wink.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/switch/wink.py b/homeassistant/components/switch/wink.py index da708d2a1f7..45168cfa0d0 100644 --- a/homeassistant/components/switch/wink.py +++ b/homeassistant/components/switch/wink.py @@ -1,8 +1,10 @@ """ homeassistant.components.switch.wink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Support for Wink switches. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.wink.html """ import logging @@ -23,8 +25,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): if token is None: logging.getLogger(__name__).error( - "Missing wink access_token - " - "get one at https://winkbearertoken.appspot.com/") + "Missing wink access_token. " + "Get one at https://winkbearertoken.appspot.com/") return pywink.set_bearer_token(token) From 7e23c241daa1a07a6cf2abefdcfae1ddc42dd4a9 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:49:25 +0200 Subject: [PATCH 29/88] Update docstring --- homeassistant/components/wink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 5c304b5ee98..4027daacc0c 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -59,7 +59,7 @@ def setup(hass, config): class WinkToggleDevice(ToggleEntity): - """ Represents a Wink switch within Home Assistant. """ + """ Represents a Wink toogle (switch) device. """ def __init__(self, wink): self.wink = wink From 3d4af8c2297ace529671d9bcb626636d845f0aaf Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 10:56:32 +0200 Subject: [PATCH 30/88] Remove configuration details --- .../components/switch/transmission.py | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/switch/transmission.py b/homeassistant/components/switch/transmission.py index 8288ed8456b..96f4a47483b 100644 --- a/homeassistant/components/switch/transmission.py +++ b/homeassistant/components/switch/transmission.py @@ -3,40 +3,8 @@ homeassistant.components.switch.transmission ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enable or disable Transmission BitTorrent client Turtle Mode. -Configuration: - -To use the Transmission switch you will need to add something like the -following to your configuration.yaml file. - -switch: - platform: transmission - name: Transmission - host: 192.168.1.26 - port: 9091 - username: YOUR_USERNAME - password: YOUR_PASSWORD - -Variables: - -host -*Required -This is the IP address of your Transmission daemon. Example: 192.168.1.32 - -port -*Optional -The port your Transmission daemon uses, defaults to 9091. Example: 8080 - -username -*Optional -Your Transmission username, if you use authentication. - -password -*Optional -Your Transmission username, if you use authentication. - -name -*Optional -The name to use when displaying this Transmission instance. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.transmission.html """ from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD from homeassistant.const import STATE_ON, STATE_OFF From 0d0eb7e7c04c19ee31376a1f1b8acf33393731b8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 16:10:47 +0200 Subject: [PATCH 31/88] Add link to docs --- homeassistant/components/light/tellstick.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/light/tellstick.py b/homeassistant/components/light/tellstick.py index 819dce499e9..22747c4fb04 100644 --- a/homeassistant/components/light/tellstick.py +++ b/homeassistant/components/light/tellstick.py @@ -2,6 +2,9 @@ homeassistant.components.light.tellstick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Tellstick lights. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/light.tellstick.html """ import logging # pylint: disable=no-name-in-module, import-error From 490e9ee95df38e8989a5f83d0dec5d1726bbb3f1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 16:37:41 +0200 Subject: [PATCH 32/88] Add link to docs --- homeassistant/components/sensor/tellstick.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/sensor/tellstick.py b/homeassistant/components/sensor/tellstick.py index 6ec24d18ef1..ecd991e5413 100644 --- a/homeassistant/components/sensor/tellstick.py +++ b/homeassistant/components/sensor/tellstick.py @@ -3,24 +3,8 @@ homeassistant.components.sensor.tellstick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Shows sensor values from Tellstick sensors. -Possible config keys: - -id of the sensor: Name the sensor with ID -135=Outside - -only_named: Only show the named sensors -only_named=1 - -temperature_scale: The scale of the temperature value -temperature_scale=°C - -datatype_mask: mask to determine which sensor values to show based on -https://tellcore-py.readthedocs.org - /en/v1.0.4/constants.html#module-tellcore.constants - -datatype_mask=1 # only show temperature -datatype_mask=12 # only show rain rate and rain total -datatype_mask=127 # show all sensor values +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.tellstick.html """ import logging from collections import namedtuple From cfb3384ee31945d0afef6c558b873d956247e791 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 16:38:33 +0200 Subject: [PATCH 33/88] Add link to docs --- homeassistant/components/switch/tellstick.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/switch/tellstick.py b/homeassistant/components/switch/tellstick.py index 1a0f7097b52..20bfa295820 100644 --- a/homeassistant/components/switch/tellstick.py +++ b/homeassistant/components/switch/tellstick.py @@ -3,11 +3,8 @@ homeassistant.components.switch.tellstick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Tellstick switches. -Because the tellstick sends its actions via radio and from most -receivers it's impossible to know if the signal was received or not. -Therefore you can configure the switch to try to send each signal repeatedly -with the config parameter signal_repetitions (default is 1). -signal_repetitions: 3 +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.tellstick.html """ import logging From bddd02bd588bae5d04cb0997704652dbe98647bf Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 16:45:45 +0200 Subject: [PATCH 34/88] Remove configuration details --- homeassistant/components/arduino.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/arduino.py b/homeassistant/components/arduino.py index cbb319e2541..02be44359f5 100644 --- a/homeassistant/components/arduino.py +++ b/homeassistant/components/arduino.py @@ -4,26 +4,8 @@ components.arduino Arduino component that connects to a directly attached Arduino board which runs with the Firmata firmware. -Configuration: - -To use the Arduino board you will need to add something like the following -to your configuration.yaml file. - -arduino: - port: /dev/ttyACM0 - -Variables: - -port -*Required -The port where is your board connected to your Home Assistant system. -If you are using an original Arduino the port will be named ttyACM*. The exact -number can be determined with 'ls /dev/ttyACM*' or check your 'dmesg'/ -'journalctl -f' output. Keep in mind that Arduino clones are often using a -different name for the port (e.g. '/dev/ttyUSB*'). - -A word of caution: The Arduino is not storing states. This means that with -every initialization the pins are set to off/low. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/arduino.html """ import logging From 89964ad793328bde9ee123021fc8d4d5142a4af8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 16:46:31 +0200 Subject: [PATCH 35/88] Remove configuration details --- homeassistant/components/sensor/arduino.py | 32 ++-------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/homeassistant/components/sensor/arduino.py b/homeassistant/components/sensor/arduino.py index f6c44d3f60e..61a0890ec10 100644 --- a/homeassistant/components/sensor/arduino.py +++ b/homeassistant/components/sensor/arduino.py @@ -4,36 +4,8 @@ homeassistant.components.sensor.arduino Support for getting information from Arduino pins. Only analog pins are supported. -Configuration: - -To use the arduino sensor you will need to add something like the following -to your configuration.yaml file. - -sensor: - platform: arduino - pins: - 7: - name: Door switch - type: analog - 0: - name: Brightness - type: analog - -Variables: - -pins -*Required -An array specifying the digital pins to use on the Arduino board. - -These are the variables for the pins array: - -name -*Required -The name for the pin that will be used in the frontend. - -type -*Required -The type of the pin: 'analog'. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.arduino.html """ import logging From e10fd0d28b238d78a1b924927ece975162cba02a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 19:36:52 +0200 Subject: [PATCH 36/88] Remove configuration details --- homeassistant/components/sensor/mqtt.py | 39 ++++--------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/sensor/mqtt.py b/homeassistant/components/sensor/mqtt.py index 37540820fcc..25073d6fa3a 100644 --- a/homeassistant/components/sensor/mqtt.py +++ b/homeassistant/components/sensor/mqtt.py @@ -1,39 +1,10 @@ -# -*- coding: utf-8 -*- """ homeassistant.components.sensor.mqtt -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to configure a MQTT sensor. -This generic sensor implementation uses the MQTT message payload -as the sensor value. If messages in this state_topic are published -with RETAIN flag, the sensor will receive an instant update with -last known value. Otherwise, the initial state will be undefined. - -sensor: - platform: mqtt - name: "MQTT Sensor" - state_topic: "home/bedroom/temperature" - qos: 0 - unit_of_measurement: "ºC" - -Variables: - -name -*Optional -The name of the sensor. Default is 'MQTT Sensor'. - -state_topic -*Required -The MQTT topic subscribed to receive sensor values. - -qos -*Optional -The maximum QoS level of the state topic. Default is 0. - -unit_of_measurement -*Optional -Defines the units of measurement of the sensor, if any. - +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.mqtt.html """ import logging @@ -50,7 +21,7 @@ DEPENDENCIES = ['mqtt'] # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Add MQTT Sensor """ + """ Add MQTT Sensor. """ if config.get('state_topic') is None: _LOGGER.error("Missing required variable: state_topic") @@ -66,7 +37,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): # pylint: disable=too-many-arguments, too-many-instance-attributes class MqttSensor(Entity): - """ Represents a sensor that can be updated using MQTT """ + """ Represents a sensor that can be updated using MQTT. """ def __init__(self, hass, name, state_topic, qos, unit_of_measurement): self._state = "-" self._hass = hass From a2e8fcbc77d47dcbc809c117e238b261350bc3b5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 19:37:34 +0200 Subject: [PATCH 37/88] Remove newline --- homeassistant/components/sensor/mqtt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/sensor/mqtt.py b/homeassistant/components/sensor/mqtt.py index 25073d6fa3a..42d94261fb8 100644 --- a/homeassistant/components/sensor/mqtt.py +++ b/homeassistant/components/sensor/mqtt.py @@ -6,7 +6,6 @@ Allows to configure a MQTT sensor. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.mqtt.html """ - import logging from homeassistant.helpers.entity import Entity import homeassistant.components.mqtt as mqtt From 7b60f6ca7767750a51bc159f6b4315f836e0bcb1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 19:43:24 +0200 Subject: [PATCH 38/88] Remove configuration details --- homeassistant/components/switch/mqtt.py | 71 +++---------------------- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/homeassistant/components/switch/mqtt.py b/homeassistant/components/switch/mqtt.py index 73618bd9277..b8a550dba70 100644 --- a/homeassistant/components/switch/mqtt.py +++ b/homeassistant/components/switch/mqtt.py @@ -1,70 +1,11 @@ -# -*- coding: utf-8 -*- """ homeassistant.components.switch.mqtt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to configure a MQTT switch. -In an ideal scenario, the MQTT device will have a state topic to publish -state changes. If these messages are published with RETAIN flag, the MQTT -switch will receive an instant state update after subscription and will -start with correct state. Otherwise, the initial state of the switch will -be false/off. - -When a state topic is not available, the switch will work in optimistic mode. -In this mode, the switch will immediately change state after every command. -Otherwise, the switch will wait for state confirmation from device -(message from state_topic). - -Optimistic mode can be forced, even if state topic is available. -Try to enable it, if experiencing incorrect switch operation. - - -Configuration: - -switch: - platform: mqtt - name: "Bedroom Switch" - state_topic: "home/bedroom/switch1" - command_topic: "home/bedroom/switch1/set" - qos: 0 - payload_on: "ON" - payload_off: "OFF" - optimistic: false - -Variables: - -name -*Optional -The name of the switch. Default is 'MQTT Switch'. - -state_topic -*Optional -The MQTT topic subscribed to receive state updates. -If not specified, optimistic mode will be forced. - -command_topic -*Required -The MQTT topic to publish commands to change the switch state. - -qos -*Optional -The maximum QoS level of the state topic. Default is 0. -This QoS will also be used to publishing messages. - -payload_on -*Optional -The payload that represents enabled state. Default is "ON". - -payload_off -*Optional -The payload that represents disabled state. Default is "OFF". - -optimistic -*Optional -Flag that defines if switch works in optimistic mode. Default is false. - +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.mqtt.html """ - import logging import homeassistant.components.mqtt as mqtt from homeassistant.components.switch import SwitchDevice @@ -82,7 +23,7 @@ DEPENDENCIES = ['mqtt'] # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): - """ Add MQTT Switch """ + """ Add MQTT Switch. """ if config.get('command_topic') is None: _LOGGER.error("Missing required variable: command_topic") @@ -101,7 +42,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): # pylint: disable=too-many-arguments, too-many-instance-attributes class MqttSwitch(SwitchDevice): - """ Represents a switch that can be togggled using MQTT """ + """ Represents a switch that can be togggled using MQTT. """ def __init__(self, hass, name, state_topic, command_topic, qos, payload_on, payload_off, optimistic): self._state = False @@ -133,12 +74,12 @@ class MqttSwitch(SwitchDevice): @property def should_poll(self): - """ No polling needed """ + """ No polling needed. """ return False @property def name(self): - """ The name of the switch """ + """ The name of the switch. """ return self._name @property From 352d3532e7ca5c18d977db8d76842833a5b83b7f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 21:11:18 +0200 Subject: [PATCH 39/88] Remove configuration details --- homeassistant/components/modbus.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/modbus.py b/homeassistant/components/modbus.py index 844e59ea189..19571518112 100644 --- a/homeassistant/components/modbus.py +++ b/homeassistant/components/modbus.py @@ -3,27 +3,8 @@ homeassistant.components.modbus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modbus component, using pymodbus (python3 branch). -Configuration: - -To use the Modbus component you will need to add something like the following -to your configuration.yaml file. - -#Modbus TCP -modbus: - type: tcp - host: 127.0.0.1 - port: 2020 - -#Modbus RTU -modbus: - type: serial - method: rtu - port: /dev/ttyUSB0 - baudrate: 9600 - stopbits: 1 - bytesize: 8 - parity: N - +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/modbus.html """ import logging From e615755eb9c1ea519e44c77d4f7fef32bbd8800a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 21:11:51 +0200 Subject: [PATCH 40/88] Remove configuration details --- homeassistant/components/sensor/modbus.py | 46 +---------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/homeassistant/components/sensor/modbus.py b/homeassistant/components/sensor/modbus.py index ac2a5e444d1..2363022791e 100644 --- a/homeassistant/components/sensor/modbus.py +++ b/homeassistant/components/sensor/modbus.py @@ -3,50 +3,8 @@ homeassistant.components.modbus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Modbus sensors. -Configuration: - -To use the Modbus sensors you will need to add something like the following to -your configuration.yaml file. - -sensor: - platform: modbus - slave: 1 - registers: - 16: - name: My integer sensor - unit: C - 24: - bits: - 0: - name: My boolean sensor - 2: - name: My other boolean sensor - coils: - 0: - name: My coil switch - -Variables: - -slave -*Required -Slave number (ignored and can be omitted if not serial Modbus). - -unit -*Required -Unit to attach to value (optional, ignored for boolean sensors). - -registers -*Required -Contains a list of relevant registers to read from. It can contain a -"bits" section, listing relevant bits. - -coils -*Optional -Contains a list of relevant coils to read from. - -Note: -- Each named register will create an integer sensor. -- Each named bit will create a boolean sensor. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.modbus.html """ import logging From ba13f134426d113405bdfbc8905d1f6ed6f9c29a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 21:12:25 +0200 Subject: [PATCH 41/88] Remove configuration details --- homeassistant/components/switch/modbus.py | 30 ++--------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/switch/modbus.py b/homeassistant/components/switch/modbus.py index 5a00b9cb174..1273f85f356 100644 --- a/homeassistant/components/switch/modbus.py +++ b/homeassistant/components/switch/modbus.py @@ -3,35 +3,9 @@ homeassistant.components.switch.modbus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Modbus switches. -Configuration: - -To use the Modbus switches you will need to add something like the following to -your configuration.yaml file. - -sensor: - platform: modbus - slave: 1 - registers: - 24: - bits: - 0: - name: My switch - 2: - name: My other switch - coils: - 0: - name: My coil switch - -VARIABLES: - - - "slave" = slave number (ignored and can be omitted if not serial Modbus) - - "registers" contains a list of relevant registers to read from - - it must contain a "bits" section, listing relevant bits - - "coils" contains a list of relevant coils to read from/write to - - - each named bit will create a switch +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.modbus.html """ - import logging import homeassistant.components.modbus as modbus From 4ff1b0fdb260ac7782c66f231df3cb2d3e4ea2e7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 21:26:16 +0200 Subject: [PATCH 42/88] Add link to docs --- homeassistant/components/zwave.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/zwave.py b/homeassistant/components/zwave.py index ef7e7308959..86d65d1c42e 100644 --- a/homeassistant/components/zwave.py +++ b/homeassistant/components/zwave.py @@ -2,6 +2,9 @@ homeassistant.components.zwave ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connects Home Assistant to a Z-Wave network. + +For configuration details please visit the documentation for this component at +https://home-assistant.io/components/zwave.html """ from pprint import pprint From d45074f9dc34194d7d6d6ae144a076c3369f5efa Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 22:53:09 +0200 Subject: [PATCH 43/88] Remove configuration details --- homeassistant/components/switch/arduino.py | 32 ++-------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/homeassistant/components/switch/arduino.py b/homeassistant/components/switch/arduino.py index b38cc290b23..337fa6c8af3 100644 --- a/homeassistant/components/switch/arduino.py +++ b/homeassistant/components/switch/arduino.py @@ -4,36 +4,8 @@ homeassistant.components.switch.arduino Support for switching Arduino pins on and off. So far only digital pins are supported. -Configuration: - -To use the arduino switch you will need to add something like the following -to your configuration.yaml file. - -switch: - platform: arduino - pins: - 11: - name: Fan Office - type: digital - 12: - name: Light Desk - type: digital - -Variables: - -pins -*Required -An array specifying the digital pins to use on the Arduino board. - -These are the variables for the pins array: - -name -*Required -The name for the pin that will be used in the frontend. - -type -*Required -The type of the pin: 'digital'. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.arduino.html """ import logging From 3c34f3dac2458ac082b7018e1bdfa0b82d815961 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 22:53:26 +0200 Subject: [PATCH 44/88] Remove configuration details --- homeassistant/components/zone.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/zone.py b/homeassistant/components/zone.py index aac3bdbcb8e..9ec7829316d 100644 --- a/homeassistant/components/zone.py +++ b/homeassistant/components/zone.py @@ -1,25 +1,10 @@ """ homeassistant.components.zone ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Allows defintion of zones in Home Assistant. -zone: - name: School - latitude: 32.8773367 - longitude: -117.2494053 - # Optional radius in meters (default: 100) - radius: 250 - # Optional icon to show instead of name - # See https://www.google.com/design/icons/ - # Example: home, work, group-work, shopping-cart, social:people - icon: group-work - -zone 2: - name: Work - latitude: 32.8753367 - longitude: -117.2474053 - +For configuration details please visit the documentation for this component at +https://home-assistant.io/components/zone.html """ import logging From 0b7c4075191f92a4c3e8e29df901332bb21a0f10 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 22:54:42 +0200 Subject: [PATCH 45/88] Remove configuration details --- homeassistant/components/switch/edimax.py | 31 ++--------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/switch/edimax.py b/homeassistant/components/switch/edimax.py index 2f38084ed9d..68542094526 100644 --- a/homeassistant/components/switch/edimax.py +++ b/homeassistant/components/switch/edimax.py @@ -3,35 +3,8 @@ homeassistant.components.switch.edimax ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for Edimax switches. -Configuration: - -To use the Edimax switch you will need to add something like the following to -your configuration.yaml file. - -switch: - platform: edimax - host: 192.168.1.32 - username: YOUR_USERNAME - password: YOUR_PASSWORD - name: Edimax Smart Plug - -Variables: - -host -*Required -This is the IP address of your Edimax switch. Example: 192.168.1.32 - -username -*Required -Your username to access your Edimax switch. - -password -*Required -Your password. - -name -*Optional -The name to use when displaying this switch instance. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.edimax.html """ import logging From 07a75c5eeb8f3c400447a75398166783af7e5c95 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 23:05:13 +0200 Subject: [PATCH 46/88] Remove configuration details --- homeassistant/components/sensor/rpi_gpio.py | 35 ++------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/homeassistant/components/sensor/rpi_gpio.py b/homeassistant/components/sensor/rpi_gpio.py index 03e3482eb07..53039f96409 100644 --- a/homeassistant/components/sensor/rpi_gpio.py +++ b/homeassistant/components/sensor/rpi_gpio.py @@ -1,41 +1,10 @@ -# -*- coding: utf-8 -*- """ homeassistant.components.sensor.rpi_gpio ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to configure a binary state sensor using RPi GPIO. -To avoid having to run Home Assistant as root when using this component, -run a Raspbian version released at or after September 29, 2015. -sensor: - platform: rpi_gpio - pull_mode: "UP" - value_high: "Active" - value_low: "Inactive" - ports: - 11: PIR Office - 12: PIR Bedroom - -Variables: - -pull_mode -*Optional -The internal pull to use (UP or DOWN). Default is UP. - -value_high -*Optional -The value of the sensor when the port is HIGH. Default is "HIGH". - -value_low -*Optional -The value of the sensor when the port is LOW. Default is "LOW". - -bouncetime -*Optional -The time in milliseconds for port debouncing. Default is 50ms. - -ports -*Required -An array specifying the GPIO ports to use and the name to use in the frontend. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.rpi_gpio.html """ import logging from homeassistant.helpers.entity import Entity From 0fda89e98364d7ee2dfe3ce5e95001371f350c14 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 23:05:38 +0200 Subject: [PATCH 47/88] Remove configuration details --- .../components/switch/command_switch.py | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/homeassistant/components/switch/command_switch.py b/homeassistant/components/switch/command_switch.py index 3a1964ad4d0..211f1c95600 100644 --- a/homeassistant/components/switch/command_switch.py +++ b/homeassistant/components/switch/command_switch.py @@ -1,37 +1,8 @@ -# -*- coding: utf-8 -*- """ homeassistant.components.switch.command_switch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to configure custom shell commands to turn a switch on/off. -Configuration: - -To use the command_line switch you will need to add something like the -following to your configuration.yaml file. - -switch: - platform: command_switch - switches: - name_of_the_switch: - oncmd: switch_command on for name_of_the_switch - offcmd: switch_command off for name_of_the_switch - -Variables: - -These are the variables for the switches array: - -name_of_the_switch -*Required -Name of the command switch. Multiple entries are possible. - -oncmd -*Required -The action to take for on. - -offcmd -*Required -The action to take for off. - For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.command_switch.html """ From 780148914938fef0848cde81c2bdd424d67b94ea Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 21 Oct 2015 23:05:54 +0200 Subject: [PATCH 48/88] Remove configuration details --- homeassistant/components/switch/rpi_gpio.py | 26 ++------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/switch/rpi_gpio.py b/homeassistant/components/switch/rpi_gpio.py index 08c7ff35255..9dbb8380b94 100644 --- a/homeassistant/components/switch/rpi_gpio.py +++ b/homeassistant/components/switch/rpi_gpio.py @@ -3,31 +3,9 @@ homeassistant.components.switch.rpi_gpio ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Allows to control the GPIO pins of a Raspberry Pi. -Note: To use RPi GPIO, Home Assistant must be run as root. - -Configuration: - -To use the Raspberry GPIO switches you will need to add something like the -following to your configuration.yaml file. - -switch: - platform: rpi_gpio - invert_logic: false - ports: - 11: Fan Office - 12: Light Desk - -Variables: - -invert_logic -*Optional -If true, inverts the output logic to ACTIVE LOW. Default is false (ACTIVE HIGH) - -ports -*Required -An array specifying the GPIO ports to use and the name to use in the frontend. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/switch.rpi_gpio.html """ - import logging try: import RPi.GPIO as GPIO From 3d972abdabb087b7384cc8ef73f4d109629abd54 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 22 Oct 2015 22:04:37 -0700 Subject: [PATCH 49/88] Clean up the heat control thermostat --- .../components/thermostat/__init__.py | 5 +- .../components/thermostat/heat_control.py | 257 +++++++----------- homeassistant/helpers/temperature.py | 2 +- tests/components/thermostat/__init__.py | 0 .../thermostat/test_heat_control.py | 115 ++++++++ 5 files changed, 216 insertions(+), 163 deletions(-) create mode 100644 tests/components/thermostat/__init__.py create mode 100644 tests/components/thermostat/test_heat_control.py diff --git a/homeassistant/components/thermostat/__init__.py b/homeassistant/components/thermostat/__init__.py index b021ec86c35..89f00da3318 100644 --- a/homeassistant/components/thermostat/__init__.py +++ b/homeassistant/components/thermostat/__init__.py @@ -14,7 +14,8 @@ import homeassistant.util as util from homeassistant.helpers.entity import Entity from homeassistant.helpers.temperature import convert from homeassistant.const import ( - ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, TEMP_CELCIUS) + ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_ON, STATE_OFF, STATE_UNKNOWN, + TEMP_CELCIUS) DOMAIN = "thermostat" DEPENDENCIES = [] @@ -125,7 +126,7 @@ class ThermostatDevice(Entity): @property def state(self): """ Returns the current state. """ - return self.target_temperature + return self.target_temperature or STATE_UNKNOWN @property def device_state_attributes(self): diff --git a/homeassistant/components/thermostat/heat_control.py b/homeassistant/components/thermostat/heat_control.py index c1dab1173d7..b87ca327b55 100644 --- a/homeassistant/components/thermostat/heat_control.py +++ b/homeassistant/components/thermostat/heat_control.py @@ -1,216 +1,153 @@ """ homeassistant.components.thermostat.heat_control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Adds support for a thermostat. -Specify a start time, end time and a target temperature. -If the the current temperature is lower than the target temperature, -and the time is between start time and end time, the heater will -be turned on. Opposite if the the temperature is higher than the -target temperature the heater will be turned off. - -If away mode is activated the target temperature is sat to a min -temperature (min_temp in config). The min temperature is also used -as target temperature when no other temperature is specified. - -If the heater is manually turned on, the target temperature will -be sat to 100*C. Meaning the thermostat probably will never turn -off the heater. -If the heater is manually turned off, the target temperature will -be sat according to normal rules. (Based on target temperature -for given time intervals and the min temperature.) - -A target temperature sat with the set_temperature function will -override all other rules for the target temperature. - -Config: - -[thermostat] -platform=heat_control - -name = Name of thermostat - -heater = entity_id for heater switch, - must be a toggle device - -target_sensor = entity_id for temperature sensor, - target_sensor.state must be temperature - -time_temp = start_time-end_time:target_temp, - -min_temp = minimum temperature, used when away mode is - active or no other temperature specified. - -Example: -[thermostat] -platform=heat_control -name = Stue -heater = switch.Ovn_stue -target_sensor = tellstick_sensor.Stue_temperature -time_temp = 0700-0745:17,1500-1850:20 -min_temp = 10 - -For the example the heater will turn on at 0700 if the temperature -is lower than 17*C away mode is false. Between 0700 and 0745 the -target temperature will be 17*C. Between 0745 and 1500 no temperature -is specified. so the min_temp of 10*C will be used. From 1500 to 1850 -the target temperature is 20*, but if away mode is true the target -temperature will be sat to 10*C +Thermostat based on a sensor and a switch connected to a heater. """ import logging -import datetime -import homeassistant.components as core import homeassistant.util as util -from homeassistant.components.thermostat import ThermostatDevice +from homeassistant.components import switch +from homeassistant.components.thermostat import (ThermostatDevice, STATE_IDLE, + STATE_HEAT) from homeassistant.helpers.event import track_state_change -from homeassistant.const import TEMP_CELCIUS, STATE_ON, STATE_OFF +from homeassistant.const import ( + ATTR_UNIT_OF_MEASUREMENT, TEMP_CELCIUS, TEMP_FAHRENHEIT) + +DEPENDENCIES = ['switch', 'sensor'] TOL_TEMP = 0.3 +CONF_NAME = 'name' +DEFAULT_NAME = 'Heat Control' +CONF_HEATER = 'heater' +CONF_SENSOR = 'target_sensor' + +_LOGGER = logging.getLogger(__name__) + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the heat control thermostat. """ - logger = logging.getLogger(__name__) + name = config.get(CONF_NAME, DEFAULT_NAME) + heater_entity_id = config.get(CONF_HEATER) + sensor_entity_id = config.get(CONF_SENSOR) - add_devices([HeatControl(hass, config, logger)]) + if None in (heater_entity_id, sensor_entity_id): + _LOGGER.error('Missing required key %s or %s', CONF_HEATER, + CONF_SENSOR) + return False + + add_devices([HeatControl(hass, name, heater_entity_id, sensor_entity_id)]) # pylint: disable=too-many-instance-attributes class HeatControl(ThermostatDevice): """ Represents a HeatControl device. """ - def __init__(self, hass, config, logger): - - self.logger = logger + def __init__(self, hass, name, heater_entity_id, sensor_entity_id): self.hass = hass - self.heater_entity_id = config.get("heater") + self._name = name + self.heater_entity_id = heater_entity_id - self.name_device = config.get("name") - self.target_sensor_entity_id = config.get("target_sensor") + self._active = False + self._cur_temp = None + self._target_temp = None + self._unit = None - self.time_temp = [] - if config.get("time_temp"): - for time_temp in list(config.get("time_temp").split(",")): - time, temp = time_temp.split(':') - time_start, time_end = time.split('-') - start_time = datetime.datetime.time( - datetime.datetime.strptime(time_start, '%H%M')) - end_time = datetime.datetime.time( - datetime.datetime.strptime(time_end, '%H%M')) - self.time_temp.append((start_time, end_time, float(temp))) + track_state_change(hass, sensor_entity_id, self._sensor_changed) - self._min_temp = util.convert(config.get("min_temp"), float, 0) - self._max_temp = util.convert(config.get("max_temp"), float, 100) + sensor_state = hass.states.get(sensor_entity_id) + if sensor_state: + self._update_temp(sensor_state) - self._manual_sat_temp = None - self._away = False - self._heater_manual_changed = True - - track_state_change(hass, self.heater_entity_id, - self._heater_turned_on, - STATE_OFF, STATE_ON) - track_state_change(hass, self.heater_entity_id, - self._heater_turned_off, - STATE_ON, STATE_OFF) + @property + def should_poll(self): + return False @property def name(self): """ Returns the name. """ - return self.name_device + return self._name @property def unit_of_measurement(self): """ Returns the unit of measurement. """ - return TEMP_CELCIUS + return self._unit @property def current_temperature(self): - """ Returns the current temperature. """ - target_sensor = self.hass.states.get(self.target_sensor_entity_id) - if target_sensor: - return float(target_sensor.state) - else: - return None + return self._cur_temp + + @property + def operation(self): + """ Returns 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. """ - if self._manual_sat_temp: - return self._manual_sat_temp - elif self._away: - return self.min_temp - else: - now = datetime.datetime.time(datetime.datetime.now()) - for (start_time, end_time, temp) in self.time_temp: - if start_time < now and end_time > now: - return temp - return self.min_temp + return self._target_temp def set_temperature(self, temperature): """ Set new target temperature. """ - if temperature is None: - self._manual_sat_temp = None - else: - self._manual_sat_temp = float(temperature) + self._target_temp = temperature + self._control_heating() + self.update_ha_state() - def update(self): - """ Update current thermostat. """ - heater = self.hass.states.get(self.heater_entity_id) - if heater is None: - self.logger.error("No heater available") + def _sensor_changed(self, entity_id, old_state, new_state): + """ Called when temperature changes. """ + if new_state is None: return - current_temperature = self.current_temperature - if current_temperature is None: - self.logger.error("No temperature available") + self._update_temp(new_state) + self._control_heating() + self.update_ha_state() + + def _update_temp(self, state): + """ Update thermostat with latest state from sensor. """ + unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) + + if unit not in (TEMP_CELCIUS, TEMP_FAHRENHEIT): + self._cur_temp = None + self._unit = None + _LOGGER.error('Sensor has unsupported unit: %s (allowed: %s, %s)', + unit, TEMP_CELCIUS, TEMP_FAHRENHEIT) return - if (current_temperature - self.target_temperature) > \ - TOL_TEMP and heater.state is STATE_ON: - self._heater_manual_changed = False - core.turn_off(self.hass, self.heater_entity_id) - elif (self.target_temperature - self.current_temperature) > TOL_TEMP \ - and heater.state is STATE_OFF: - self._heater_manual_changed = False - core.turn_on(self.hass, self.heater_entity_id) + temp = util.convert(state.state, float) - def _heater_turned_on(self, entity_id, old_state, new_state): - """ Heater is turned on. """ - if not self._heater_manual_changed: - pass - else: - self.set_temperature(self.max_temp) + if temp is None: + self._cur_temp = None + self._unit = None + _LOGGER.error('Unable to parse sensor temperature: %s', + state.state) + return - self._heater_manual_changed = True + self._cur_temp = temp + self._unit = unit - def _heater_turned_off(self, entity_id, old_state, new_state): - """ Heater is turned off. """ - if self._heater_manual_changed: - self.set_temperature(None) + def _control_heating(self): + """ 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 + _LOGGER.info('Obtained current and target temperature. ' + 'Heat control active.') + + if not self._active: + return + + too_cold = self._target_temp - self._cur_temp > TOL_TEMP + is_heating = self._is_heating + + if too_cold and not is_heating: + _LOGGER.info('Turning on heater %s', self.heater_entity_id) + switch.turn_on(self.hass, self.heater_entity_id) + elif not too_cold and is_heating: + _LOGGER.info('Turning off heater %s', self.heater_entity_id) + switch.turn_off(self.hass, self.heater_entity_id) @property - def is_away_mode_on(self): - """ - Returns if away mode is on. - """ - return self._away - - def turn_away_mode_on(self): - """ Turns away mode on. """ - self._away = True - - def turn_away_mode_off(self): - """ Turns away mode off. """ - self._away = False - - @property - def min_temp(self): - """ Return minimum temperature. """ - return self._min_temp - - @property - def max_temp(self): - """ Return maxmum temperature. """ - return self._max_temp + def _is_heating(self): + return switch.is_on(self.hass, self.heater_entity_id) diff --git a/homeassistant/helpers/temperature.py b/homeassistant/helpers/temperature.py index eaf1f78d927..4a867ab2f2e 100644 --- a/homeassistant/helpers/temperature.py +++ b/homeassistant/helpers/temperature.py @@ -11,7 +11,7 @@ import homeassistant.util.temperature as temp_util def convert(temperature, unit, to_unit): """ Converts temperature to correct unit. """ - if unit == to_unit: + if unit == to_unit or unit is None or to_unit is None: return temperature elif unit == TEMP_CELCIUS: return temp_util.celcius_to_fahrenheit(temperature) diff --git a/tests/components/thermostat/__init__.py b/tests/components/thermostat/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/components/thermostat/test_heat_control.py b/tests/components/thermostat/test_heat_control.py new file mode 100644 index 00000000000..f0b487ae86c --- /dev/null +++ b/tests/components/thermostat/test_heat_control.py @@ -0,0 +1,115 @@ +""" +tests.components.thermostat.test_heat_control +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Tests heat control thermostat. +""" +import unittest + +from homeassistant.const import ( + ATTR_UNIT_OF_MEASUREMENT, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, + STATE_ON, + STATE_OFF, + TEMP_CELCIUS, +) +import homeassistant.core as ha +from homeassistant.components import switch, thermostat + + +entity = 'thermostat.test' +ent_sensor = 'sensor.test' +ent_switch = 'switch.test' + + +class TestThermostatHeatControl(unittest.TestCase): + """ Test the Heat Control thermostat. """ + + def setUp(self): # pylint: disable=invalid-name + self.hass = ha.HomeAssistant() + self.hass.config.temperature_unit = TEMP_CELCIUS + thermostat.setup(self.hass, {'thermostat': { + 'platform': 'heat_control', + 'name': 'test', + 'heater': ent_switch, + 'target_sensor': ent_sensor + }}) + + def tearDown(self): # pylint: disable=invalid-name + """ Stop down stuff we started. """ + self.hass.stop() + + def test_setup_defaults_to_unknown(self): + self.assertEqual('unknown', self.hass.states.get(entity).state) + + def test_set_target_temp(self): + thermostat.set_temperature(self.hass, 30) + self.hass.pool.block_till_done() + self.assertEqual('30.0', self.hass.states.get(entity).state) + + def test_set_target_temp_turns_on_heater(self): + self._setup_switch(False) + self._setup_sensor(25) + self.hass.pool.block_till_done() + thermostat.set_temperature(self.hass, 30) + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + call = self.calls[0] + self.assertEqual('switch', call.domain) + self.assertEqual(SERVICE_TURN_ON, call.service) + self.assertEqual(ent_switch, call.data['entity_id']) + + def test_set_target_temp_turns_off_heater(self): + self._setup_switch(True) + self._setup_sensor(30) + self.hass.pool.block_till_done() + thermostat.set_temperature(self.hass, 25) + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + call = self.calls[0] + self.assertEqual('switch', call.domain) + self.assertEqual(SERVICE_TURN_OFF, call.service) + self.assertEqual(ent_switch, call.data['entity_id']) + + def test_set_temp_change_turns_on_heater(self): + self._setup_switch(False) + thermostat.set_temperature(self.hass, 30) + self.hass.pool.block_till_done() + self._setup_sensor(25) + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + call = self.calls[0] + self.assertEqual('switch', call.domain) + self.assertEqual(SERVICE_TURN_ON, call.service) + self.assertEqual(ent_switch, call.data['entity_id']) + + def test_temp_change_turns_off_heater(self): + self._setup_switch(True) + thermostat.set_temperature(self.hass, 25) + self.hass.pool.block_till_done() + self._setup_sensor(30) + self.hass.pool.block_till_done() + self.assertEqual(1, len(self.calls)) + call = self.calls[0] + self.assertEqual('switch', call.domain) + self.assertEqual(SERVICE_TURN_OFF, call.service) + self.assertEqual(ent_switch, call.data['entity_id']) + + def _setup_sensor(self, temp, unit=TEMP_CELCIUS): + """ Setup the test sensor. """ + self.hass.states.set(ent_sensor, temp, { + ATTR_UNIT_OF_MEASUREMENT: unit + }) + + def _setup_switch(self, is_on): + """ Setup the test switch. """ + self.hass.states.set(ent_switch, STATE_ON if is_on else STATE_OFF) + self.calls = [] + + def log_call(call): + """ Log service calls. """ + self.calls.append(call) + + self.hass.services.register('switch', SERVICE_TURN_ON, log_call) + self.hass.services.register('switch', SERVICE_TURN_OFF, log_call) From c2d75efb4de608b315d77d1c62ab01bbf6baf3d6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 22 Oct 2015 22:14:40 -0700 Subject: [PATCH 50/88] Add missing docstring to heat control thermo --- homeassistant/components/thermostat/heat_control.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/thermostat/heat_control.py b/homeassistant/components/thermostat/heat_control.py index b87ca327b55..bfec48fea3d 100644 --- a/homeassistant/components/thermostat/heat_control.py +++ b/homeassistant/components/thermostat/heat_control.py @@ -150,4 +150,5 @@ class HeatControl(ThermostatDevice): @property def _is_heating(self): + """ If the heater is currently heating. """ return switch.is_on(self.hass, self.heater_entity_id) From dd787ea5cede20fa51fc0a291fb7db51e9f37e22 Mon Sep 17 00:00:00 2001 From: Nolan Gilley Date: Fri, 23 Oct 2015 10:10:44 -0400 Subject: [PATCH 51/88] remove suggestion for uk unit system. change default to use si or us based on default temperature. added more sensor types. --- homeassistant/components/sensor/forecast.py | 48 +++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/sensor/forecast.py b/homeassistant/components/sensor/forecast.py index 8fe39c67114..0cbafe53d97 100644 --- a/homeassistant/components/sensor/forecast.py +++ b/homeassistant/components/sensor/forecast.py @@ -13,9 +13,14 @@ sensor: api_key: YOUR_APP_KEY monitored_conditions: - summary + - icon + - nearest_storm_distance + - nearest_storm_bearing - precip_type - precip_intensity + - precip_probability - temperature + - apparent_temperature - dew_point - wind_speed - wind_bearing @@ -24,7 +29,8 @@ sensor: - pressure - visibility - ozone - units: si, us, ca, uk, uk2 or auto(default) + # Optional: specify which unit system to use. + units: si, us, ca, uk2 or auto Variables: @@ -41,8 +47,10 @@ list of all available conditions to monitor. units *Optional -Specify the unit system. Default to 'auto' which is based on location. -Other options are us, si, ca, uk, and uk2. For more info see API link below. +Specify the unit system. Default to 'si' or 'us' based on the temperature +preference in Home Assistant. Other options are auto, us, si, ca, and uk2. +'auto' will let forecast.io decide the unit system based on location. +For more information see the API url below. Details for the API : https://developer.forecast.io/docs/v2 """ @@ -57,7 +65,7 @@ except ImportError: forecastio = None from homeassistant.util import Throttle -from homeassistant.const import (CONF_API_KEY) +from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS) from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) @@ -66,13 +74,21 @@ _LOGGER = logging.getLogger(__name__) # Name, si unit, us unit, ca unit, uk unit, uk2 unit SENSOR_TYPES = { 'summary': ['Summary', '', '', '', '', ''], + 'icon': ['Icon', '', '', '', '', ''], + 'nearest_storm_distance': ['Nearest Storm Distance', + 'km', 'm', 'km', 'km', 'm'], + 'nearest_storm_bearing': ['Nearest Storm Bearing', + '°', '°', '°', '°', '°'], 'precip_type': ['Precip', '', '', '', '', ''], - 'precip_intensity': ['Precip intensity', 'mm', 'in', 'mm', 'mm', 'mm'], + 'precip_intensity': ['Precip Intensity', 'mm', 'in', 'mm', 'mm', 'mm'], + 'precip_probability': ['Precip Probability', '%', '%', '%', '%', '%'], 'temperature': ['Temperature', '°C', '°F', '°C', '°C', '°C'], + 'apparent_temperature': ['Apparent Temperature', + '°C', '°F', '°C', '°C', '°C'], 'dew_point': ['Dew point', '°C', '°F', '°C', '°C', '°C'], 'wind_speed': ['Wind Speed', 'm/s', 'mph', 'km/h', 'mph', 'mph'], 'wind_bearing': ['Wind Bearing', '°', '°', '°', '°', '°'], - 'cloud_cover': ['Cloud coverage', '%', '%', '%', '%', '%'], + 'cloud_cover': ['Cloud Coverage', '%', '%', '%', '%', '%'], 'humidity': ['Humidity', '%', '%', '%', '%', '%'], 'pressure': ['Pressure', 'mBar', 'mBar', 'mBar', 'mBar', 'mBar'], 'visibility': ['Visibility', 'km', 'm', 'km', 'km', 'm'], @@ -106,9 +122,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): "Please check your settings for Forecast.io.") return False - units = config.get('units') - if units is None: - units = 'auto' + if 'units' in config: + units = config['units'] + elif hass.config.temperature_unit == TEMP_CELCIUS: + units = 'si' + else: + units = 'us' data = ForeCastData(config.get(CONF_API_KEY, None), hass.config.latitude, @@ -177,7 +196,14 @@ class ForeCastSensor(Entity): try: if self.type == 'summary': self._state = data.summary + elif self.type == 'icon': + self._state = data.icon + elif self.type == 'nearest_storm_distance': + self._state = data.nearestStormDistance + elif self.type == 'nearest_storm_bearing': + self._state = data.nearestStormBearing elif self.type == 'precip_intensity': + self._state = data.precipIntensity if data.precipIntensity == 0: self._state = 'None' self._unit_of_measurement = '' @@ -189,10 +215,14 @@ class ForeCastSensor(Entity): self._unit_of_measurement = '' else: self._state = data.precipType + elif self.type == 'precip_probability': + self._state = round(data.precipProbability * 100, 1) elif self.type == 'dew_point': self._state = round(data.dewPoint, 1) elif self.type == 'temperature': self._state = round(data.temperature, 1) + elif self.type == 'apparent_temperature': + self._state = round(data.apparentTemperature, 1) elif self.type == 'wind_speed': self._state = data.windSpeed elif self.type == 'wind_bearing': From b6e6512367f33b0b09fc45c04fae75d714757bc9 Mon Sep 17 00:00:00 2001 From: MakeMeASandwich Date: Tue, 20 Oct 2015 18:17:35 +0200 Subject: [PATCH 52/88] media_player/denon: refactor * connect only if necessary * do not throw errors if offline --- .../components/media_player/denon.py | 97 +++++++++++-------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/homeassistant/components/media_player/denon.py b/homeassistant/components/media_player/denon.py index 19286906f49..66b96ff7572 100644 --- a/homeassistant/components/media_player/denon.py +++ b/homeassistant/components/media_player/denon.py @@ -6,8 +6,7 @@ Developed for a Denon DRA-N5, see http://www.denon.co.uk/chg/product/compactsystems/networkmusicsystems/ceolpiccolo A few notes: - - As long as this module is active and connected, the receiver does - not seem to accept additional telnet connections. + - The receiver handles only one telnet connection and refuses others. - Be careful with the volume. 50% or even 100% are very loud. @@ -67,13 +66,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None): CONF_HOST) return False - add_devices([ - DenonDevice( - config.get('name', 'Music station'), - config.get('host')) - ]) - - return True + denon = DenonDevice( + config.get("name", "Music station"), + config.get("host") + ) + if denon.update(): + add_devices([denon]) + return True + else: + return False class DenonDevice(MediaPlayerDevice): @@ -84,28 +85,41 @@ class DenonDevice(MediaPlayerDevice): def __init__(self, name, host): self._name = name self._host = host - self._telnet = telnetlib.Telnet(self._host) + self._pwstate = "PWSTANDBY" + self._volume = 0 + self._muted = False + self._mediasource = "" - def query(self, message): - """ Send request and await response from server """ + @classmethod + def telnet_request(cls, telnet, command): + """ Executes `command` and returns the response. """ + telnet.write(command.encode("ASCII") + b"\r") + return telnet.read_until(b"\r", timeout=0.2).decode("ASCII").strip() + + def telnet_command(self, command): + """ Establishes a telnet connection and sends `command`. """ + telnet = telnetlib.Telnet(self._host) + telnet.write(command.encode("ASCII") + b"\r") + telnet.read_very_eager() # skip response + telnet.close() + + def update(self): try: - # unspecified command, should be ignored - self._telnet.write("?".encode('UTF-8') + b'\r') - except (EOFError, BrokenPipeError, ConnectionResetError): - self._telnet.open(self._host) + telnet = telnetlib.Telnet(self._host) + except ConnectionRefusedError: + return False - self._telnet.read_very_eager() # skip what is not requested + self._pwstate = self.telnet_request(telnet, "PW?") + # PW? sends also SISTATUS, which is not interesting + telnet.read_until(b"\r", timeout=0.2) - self._telnet.write(message.encode('ASCII') + b'\r') - # timeout 200ms, defined by protocol - resp = self._telnet.read_until(b'\r', timeout=0.2)\ - .decode('UTF-8').strip() + volume_str = self.telnet_request(telnet, "MV?")[len("MV"):] + self._volume = int(volume_str) / 60 + self._muted = (self.telnet_request(telnet, "MU?") == "MUON") + self._mediasource = self.telnet_request(telnet, "SI?")[len("SI"):] - if message == "PW?": - # workaround; PW? sends also SISTATUS - self._telnet.read_until(b'\r', timeout=0.2) - - return resp + telnet.close() + return True @property def name(self): @@ -115,10 +129,9 @@ class DenonDevice(MediaPlayerDevice): @property def state(self): """ Returns the state of the device. """ - pwstate = self.query('PW?') - if pwstate == "PWSTANDBY": + if self._pwstate == "PWSTANDBY": return STATE_OFF - if pwstate == "PWON": + if self._pwstate == "PWON": return STATE_ON return STATE_UNKNOWN @@ -126,17 +139,17 @@ class DenonDevice(MediaPlayerDevice): @property def volume_level(self): """ Volume level of the media player (0..1). """ - return int(self.query('MV?')[len('MV'):]) / 60 + return self._volume @property def is_volume_muted(self): """ Boolean if volume is currently muted. """ - return self.query('MU?') == "MUON" + return self._muted @property def media_title(self): """ Current media source. """ - return self.query('SI?')[len('SI'):] + return self._mediasource @property def supported_media_commands(self): @@ -145,24 +158,24 @@ class DenonDevice(MediaPlayerDevice): def turn_off(self): """ turn_off media player. """ - self.query('PWSTANDBY') + self.telnet_command("PWSTANDBY") def volume_up(self): """ volume_up media player. """ - self.query('MVUP') + self.telnet_command("MVUP") def volume_down(self): """ volume_down media player. """ - self.query('MVDOWN') + self.telnet_command("MVDOWN") def set_volume_level(self, volume): """ set volume level, range 0..1. """ # 60dB max - self.query('MV' + str(round(volume * 60)).zfill(2)) + self.telnet_command("MV" + str(round(volume * 60)).zfill(2)) def mute_volume(self, mute): """ mute (true) or unmute (false) media player. """ - self.query('MU' + ('ON' if mute else 'OFF')) + self.telnet_command("MU" + ("ON" if mute else "OFF")) def media_play_pause(self): """ media_play_pause media player. """ @@ -170,22 +183,22 @@ class DenonDevice(MediaPlayerDevice): def media_play(self): """ media_play media player. """ - self.query('NS9A') + self.telnet_command("NS9A") def media_pause(self): """ media_pause media player. """ - self.query('NS9B') + self.telnet_command("NS9B") def media_next_track(self): """ Send next track command. """ - self.query('NS9D') + self.telnet_command("NS9D") def media_previous_track(self): - self.query('NS9E') + self.telnet_command("NS9E") def media_seek(self, position): raise NotImplementedError() def turn_on(self): """ turn the media player on. """ - self.query('PWON') + self.telnet_command("PWON") From 55718aac66e747d4ffe2078fa4b883dc299a9f5c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:10:32 +0200 Subject: [PATCH 53/88] Remove configuration details --- .../components/media_player/squeezebox.py | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/homeassistant/components/media_player/squeezebox.py b/homeassistant/components/media_player/squeezebox.py index 03337648520..b80e121130a 100644 --- a/homeassistant/components/media_player/squeezebox.py +++ b/homeassistant/components/media_player/squeezebox.py @@ -1,39 +1,11 @@ """ homeassistant.components.media_player.squeezebox -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides an interface to the Logitech SqueezeBox API -Configuration: - -To use SqueezeBox add something something like the following to your -configuration.yaml file. - -media_player: - platform: squeezebox - host: 192.168.1.21 - port: 9090 - username: user - password: password - -Variables: - -host -*Required -The host name or address of the Logitech Media Server. - -port -*Optional -Telnet port to Logitech Media Server, default 9090. - -usermame -*Optional -Username, if password protection is enabled. - -password -*Optional -Password, if password protection is enabled. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.squeezebox """ - import logging import telnetlib import urllib.parse From 84a9a300d6dd174eabc18aec8b2de5d32912504b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:13:28 +0200 Subject: [PATCH 54/88] Fix link --- homeassistant/components/media_player/squeezebox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/squeezebox.py b/homeassistant/components/media_player/squeezebox.py index b80e121130a..b1f3f16567d 100644 --- a/homeassistant/components/media_player/squeezebox.py +++ b/homeassistant/components/media_player/squeezebox.py @@ -4,7 +4,7 @@ homeassistant.components.media_player.squeezebox Provides an interface to the Logitech SqueezeBox API For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/media_player.squeezebox +https://home-assistant.io/components/media_player.squeezebox.html """ import logging import telnetlib From 6115be7c42b7eac9bb1ebbc893588d1e8e2e886d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:13:45 +0200 Subject: [PATCH 55/88] Remove configuration details --- homeassistant/components/media_player/mpd.py | 31 ++------------------ 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/media_player/mpd.py b/homeassistant/components/media_player/mpd.py index 8cc22f9b982..6418cbd6e64 100644 --- a/homeassistant/components/media_player/mpd.py +++ b/homeassistant/components/media_player/mpd.py @@ -3,35 +3,8 @@ homeassistant.components.media_player.mpd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides functionality to interact with a Music Player Daemon. -Configuration: - -To use MPD you will need to add something like the following to your -configuration.yaml file. - -media_player: - platform: mpd - server: 127.0.0.1 - port: 6600 - location: bedroom - password: superSecretPassword123 - -Variables: - -server -*Required -IP address of the Music Player Daemon. Example: 192.168.1.32 - -port -*Optional -Port of the Music Player Daemon, defaults to 6600. Example: 6600 - -location -*Optional -Location of your Music Player Daemon. - -password -*Optional -Password for your Music Player Daemon. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.mpd.html """ import logging import socket From 170742b0a7e7d0e6816d000eb624aabe830331d1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:15:12 +0200 Subject: [PATCH 56/88] Remove configuration details --- homeassistant/components/media_player/kodi.py | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/homeassistant/components/media_player/kodi.py b/homeassistant/components/media_player/kodi.py index 2fe42e2e707..8e07ec2df8b 100644 --- a/homeassistant/components/media_player/kodi.py +++ b/homeassistant/components/media_player/kodi.py @@ -3,35 +3,8 @@ homeassistant.components.media_player.kodi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides an interface to the XBMC/Kodi JSON-RPC API -Configuration: - -To use the Kodi you will need to add something like the following to -your configuration.yaml file. - -media_player: - platform: kodi - name: Kodi - url: http://192.168.0.123/jsonrpc - user: kodi - password: my_secure_password - -Variables: - -name -*Optional -The name of the device. - -url -*Required -The URL of the XBMC/Kodi JSON-RPC API. Example: http://192.168.0.123/jsonrpc - -user -*Optional -The XBMC/Kodi HTTP username. - -password -*Optional -The XBMC/Kodi HTTP password. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.kodi.html """ import urllib import logging From 75f737144a4118d9475ee3121e219d3d1441977e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:24:07 +0200 Subject: [PATCH 57/88] Remove configuration details --- homeassistant/components/media_player/cast.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/media_player/cast.py b/homeassistant/components/media_player/cast.py index 6f622c9e0cc..175c2e21094 100644 --- a/homeassistant/components/media_player/cast.py +++ b/homeassistant/components/media_player/cast.py @@ -3,22 +3,8 @@ homeassistant.components.media_player.chromecast ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides functionality to interact with Cast devices on the network. -WARNING: This platform is currently not working due to a changed Cast API. - -Configuration: - -To use the chromecast integration you will need to add something like the -following to your configuration.yaml file. - -media_player: - platform: chromecast - host: 192.168.1.9 - -Variables: - -host -*Optional -Use only if you don't want to scan for devices. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.cast.html """ import logging From 44b08a06e75c1001cb92a004a48ddee4d87c3037 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:26:36 +0200 Subject: [PATCH 58/88] Remove configuration details --- .../components/media_player/itunes.py | 39 +++---------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/media_player/itunes.py b/homeassistant/components/media_player/itunes.py index 70def719146..40c771d1ea6 100644 --- a/homeassistant/components/media_player/itunes.py +++ b/homeassistant/components/media_player/itunes.py @@ -1,36 +1,10 @@ """ homeassistant.components.media_player.itunes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Provides an interface to iTunes-API (https://github.com/maddox/itunes-api) - -The iTunes media player will allow you to control your iTunes instance. You -can play/pause/next/previous/mute, adjust volume, etc. - -In addition to controlling iTunes, your available AirPlay endpoints will be -added as media players as well. You can then individually address them append -turn them on, turn them off, or adjust their volume. - -Configuration: - -To use iTunes you will need to add something like the following to -your configuration.yaml file. - -media_player: - platform: itunes - name: iTunes - host: http://192.168.1.16 - port: 8181 - -Variables: - -name -*Optional -The name of the device. - -url -*Required -URL of your running version of iTunes-API. Example: http://192.168.1.50:8181 +Provides an interface to iTunes API. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.itunes.html """ import logging @@ -157,11 +131,9 @@ class Itunes(object): path = '/airplay_devices/' + device_id + '/volume' return self._request('PUT', path, {'level': level}) -# pylint: disable=unused-argument -# pylint: disable=abstract-method + +# pylint: disable=unused-argument, abstract-method # pylint: disable=too-many-instance-attributes - - def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the itunes platform. """ @@ -179,7 +151,6 @@ class ItunesDevice(MediaPlayerDevice): """ Represents a iTunes-API instance. """ # pylint: disable=too-many-public-methods - def __init__(self, name, host, port, add_devices): self._name = name self._host = host From 0e145ec130488e747bfb38f2eaf0334aba6310ac Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 18:39:50 +0200 Subject: [PATCH 59/88] Remove configuration details --- .../components/media_player/sonos.py | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/media_player/sonos.py b/homeassistant/components/media_player/sonos.py index faf4f6aa983..13ee668b18a 100644 --- a/homeassistant/components/media_player/sonos.py +++ b/homeassistant/components/media_player/sonos.py @@ -1,17 +1,11 @@ """ homeassistant.components.media_player.sonos -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides an interface to Sonos players (via SoCo) -Configuration: - -To use SoCo, add something like this to your configuration: - -media_player: - platform: sonos +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.sonos.html """ - import logging import datetime @@ -56,8 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): return True -# pylint: disable=too-many-instance-attributes -# pylint: disable=too-many-public-methods +# pylint: disable=too-many-instance-attributes, too-many-public-methods # pylint: disable=abstract-method class SonosDevice(MediaPlayerDevice): """ Represents a Sonos device. """ @@ -74,7 +67,7 @@ class SonosDevice(MediaPlayerDevice): return True def update_sonos(self, now): - """ Updates state, called by track_utc_time_change """ + """ Updates state, called by track_utc_time_change. """ self.update_ha_state(True) @property @@ -162,31 +155,31 @@ class SonosDevice(MediaPlayerDevice): return SUPPORT_SONOS def turn_off(self): - """ turn_off media player. """ + """ Turn off media player. """ self._player.pause() def volume_up(self): - """ volume_up media player. """ + """ Volume up media player. """ self._player.volume += 1 def volume_down(self): - """ volume_down media player. """ + """ Volume down media player. """ self._player.volume -= 1 def set_volume_level(self, volume): - """ set volume level, range 0..1. """ + """ Set volume level, range 0..1. """ self._player.volume = str(int(volume * 100)) def mute_volume(self, mute): - """ mute (true) or unmute (false) media player. """ + """ Mute (true) or unmute (false) media player. """ self._player.mute = mute def media_play(self): - """ media_play media player. """ + """ Send paly command. """ self._player.play() def media_pause(self): - """ media_pause media player. """ + """ Send pause command. """ self._player.pause() def media_next_track(self): @@ -202,5 +195,5 @@ class SonosDevice(MediaPlayerDevice): self._player.seek(str(datetime.timedelta(seconds=int(position)))) def turn_on(self): - """ turn the media player on. """ + """ Turn the media player on. """ self._player.play() From a155587693ab4f070c2cfe5c7cbd3c216cd9fb9a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 19:01:19 +0200 Subject: [PATCH 60/88] Remove configuration details --- .../components/media_player/firetv.py | 65 ++++--------------- 1 file changed, 11 insertions(+), 54 deletions(-) diff --git a/homeassistant/components/media_player/firetv.py b/homeassistant/components/media_player/firetv.py index 9db17416bda..06f88e8efc3 100644 --- a/homeassistant/components/media_player/firetv.py +++ b/homeassistant/components/media_player/firetv.py @@ -1,47 +1,11 @@ """ homeassistant.components.media_player.firetv ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Provides functionality to interact with FireTV devices. -Provides control over an Amazon Fire TV (/stick) via -python-firetv, a Python 2.x module with a helper script -that exposes a HTTP server to fetch state and perform -actions. - -Steps to configure your Amazon Fire TV stick with Home Assistant: - -1. Turn on ADB Debugging on your Amazon Fire TV: - a. From the main (Launcher) screen, select Settings. - b. Select System > Developer Options. - c. Select ADB Debugging. -2. Find Amazon Fire TV device IP: - a. From the main (Launcher) screen, select Settings. - b. Select System > About > Network. -3. `pip install firetv[firetv-server]` into a Python 2.x environment -4. `firetv-server -d :5555`, background the process -5. Configure Home Assistant as follows: - -media_player: - platform: firetv - # optional: where firetv-server is running (default is 'localhost:5556') - host: localhost:5556 - # optional: device id (default is 'default') - device: livingroom-firetv - # optional: friendly name (default is 'Amazon Fire TV') - name: My Amazon Fire TV - -Note that python-firetv has support for multiple Amazon Fire TV devices. -If you have more than one configured, be sure to specify the device id used. -Run `firetv-server -h` and/or view the source for complete capabilities. - -Possible states are: - - off (TV screen is dark) - - standby (standard UI is active - not apps) - - idle (screen saver is active) - - play (video is playing) - - pause (video is paused) - - disconnected (can't communicate with device) +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.firetv.html """ - import logging import requests @@ -69,7 +33,7 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): - """ Sets up the firetv platform. """ + """ Sets up the FireTV platform. """ host = config.get('host', 'localhost:5556') device_id = config.get('device', 'default') try: @@ -94,12 +58,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class FireTV(object): """ firetv-server client. - Should a native Python 3 ADB module become available, - python-firetv can support Python 3, it can be added - as a dependency, and this class can be dispensed of. + Should a native Python 3 ADB module become available, python-firetv can + support Python 3, it can be added as a dependency, and this class can be + dispensed of. - For now, it acts as a client to the firetv-server - HTTP server (which must be running via Python 2). + For now, it acts as a client to the firetv-server HTTP server (which must + be running via Python 2). """ def __init__(self, host, device_id): @@ -108,10 +72,7 @@ class FireTV(object): @property def state(self): - """ Get the device state. - - An exception means UNKNOWN state. - """ + """ Get the device state. An exception means UNKNOWN state. """ try: response = requests.get( DEVICE_STATE_URL.format( @@ -126,11 +87,7 @@ class FireTV(object): return STATE_UNKNOWN def action(self, action_id): - """ Perform an action on the device. - - There is no action acknowledgment, so exceptions - result in a pass. - """ + """ Perform an action on the device. """ try: requests.get( DEVICE_ACTION_URL.format( From f9b2e0058ea3031d56f48fb54fce09547fbb0b0f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 19:01:38 +0200 Subject: [PATCH 61/88] Fix typo --- homeassistant/components/media_player/firetv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/firetv.py b/homeassistant/components/media_player/firetv.py index 06f88e8efc3..9d712c50c89 100644 --- a/homeassistant/components/media_player/firetv.py +++ b/homeassistant/components/media_player/firetv.py @@ -150,7 +150,7 @@ class FireTVDevice(MediaPlayerDevice): self._firetv.action('turn_off') def media_play(self): - """ Send play commmand. """ + """ Send play command. """ self._firetv.action('media_play') def media_pause(self): From e21921823efdd5bb1d243d765f5b120eb412c47a Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:29:22 +0200 Subject: [PATCH 62/88] Update docstring --- homeassistant/components/rfxtrx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index 0788986c91d..9c9cf0149e8 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -3,7 +3,7 @@ homeassistant.components.rfxtrx ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides support for RFXtrx components. -For more details about this platform, please refer to the documentation at +For more details about this component, please refer to the documentation at https://home-assistant.io/components/rfxtrx.html """ import logging From 3f6780d9bec965cf06b75be33f56477eb1611b22 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:31:37 +0200 Subject: [PATCH 63/88] Remove configuration details --- homeassistant/components/verisure.py | 40 ++-------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/homeassistant/components/verisure.py b/homeassistant/components/verisure.py index 50fd9d6c7a9..6d4158aca15 100644 --- a/homeassistant/components/verisure.py +++ b/homeassistant/components/verisure.py @@ -3,44 +3,8 @@ components.verisure ~~~~~~~~~~~~~~~~~~~ Provides support for verisure components. -Configuration: - -To use the Verisure component you will need to add something like the -following to your configuration.yaml file. - -verisure: - username: user@example.com - password: password - alarm: 1 - hygrometers: 0 - smartplugs: 1 - thermometers: 0 - -Variables: - -username -*Required -Username to Verisure mypages. - -password -*Required -Password to Verisure mypages. - -alarm -*Optional -Set to 1 to show alarm, 0 to disable. Default 1. - -hygrometers -*Optional -Set to 1 to show hygrometers, 0 to disable. Default 1. - -smartplugs -*Optional -Set to 1 to show smartplugs, 0 to disable. Default 1. - -thermometers -*Optional -Set to 1 to show thermometers, 0 to disable. Default 1. +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/verisure.html """ import logging from datetime import timedelta From 2e3f4624740b7d890d3b175564256c87b7f6c900 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:32:36 +0200 Subject: [PATCH 64/88] Update docstring --- homeassistant/components/wink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index 4027daacc0c..6c456ea1543 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -3,7 +3,7 @@ homeassistant.components.wink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Connects to a Wink hub and loads relevant components to control its devices. -For more details about this platform, please refer to the documentation at +For more details about this component, please refer to the documentation at https://home-assistant.io/components/wink.html """ import logging From a8e2f9cbb7fc8f8a493761975db3ceddf78845fa Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:34:02 +0200 Subject: [PATCH 65/88] Remove configuration details --- homeassistant/components/mqtt/__init__.py | 48 ++--------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 71ba0fe0c9c..69b37ffc94a 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -1,52 +1,10 @@ """ homeassistant.components.mqtt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -MQTT component, using paho-mqtt. This component needs a MQTT broker like -Mosquitto or Mosca. The Eclipse Foundation is running a public MQTT server -at iot.eclipse.org. If you prefer to use that one, keep in mind to adjust -the topic/client ID and that your messages are public. +MQTT component, using paho-mqtt. -Configuration: - -To use MQTT you will need to add something like the following to your -config/configuration.yaml. - -mqtt: - broker: 127.0.0.1 - -Or, if you want more options: - -mqtt: - broker: 127.0.0.1 - port: 1883 - client_id: home-assistant-1 - keepalive: 60 - username: your_username - password: your_secret_password - certificate: /home/paulus/dev/addtrustexternalcaroot.crt - -Variables: - -broker -*Required -This is the IP address of your MQTT broker, e.g. 192.168.1.32. - -port -*Optional -The network port to connect to. Default is 1883. - -client_id -*Optional -Client ID that Home Assistant will use. Has to be unique on the server. -Default is a random generated one. - -keepalive -*Optional -The keep alive in seconds for this client. Default is 60. - -certificate -*Optional -Certificate to use for encrypting the connection to the broker. +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/mqtt.html """ import logging import os From f828ee044d891d0a2478e9c3ba38be235578391f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:34:23 +0200 Subject: [PATCH 66/88] UPdate docstring --- homeassistant/components/arduino.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/arduino.py b/homeassistant/components/arduino.py index 02be44359f5..12ceafbd44b 100644 --- a/homeassistant/components/arduino.py +++ b/homeassistant/components/arduino.py @@ -4,7 +4,7 @@ components.arduino Arduino component that connects to a directly attached Arduino board which runs with the Firmata firmware. -For more details about this platform, please refer to the documentation at +For more details about this component, please refer to the documentation at https://home-assistant.io/components/arduino.html """ import logging From 87e55820e794af1ad68b6280b18376d1d8ae4ea1 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:39:04 +0200 Subject: [PATCH 67/88] Add link docs --- homeassistant/components/sensor/isy994.py | 3 +++ homeassistant/components/switch/isy994.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/isy994.py b/homeassistant/components/sensor/isy994.py index c30f618f715..a97d03fc6aa 100644 --- a/homeassistant/components/sensor/isy994.py +++ b/homeassistant/components/sensor/isy994.py @@ -2,6 +2,9 @@ homeassistant.components.sensor.isy994 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for ISY994 sensors. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/isy994.html """ import logging diff --git a/homeassistant/components/switch/isy994.py b/homeassistant/components/switch/isy994.py index 75032d2954d..5fb516d0690 100644 --- a/homeassistant/components/switch/isy994.py +++ b/homeassistant/components/switch/isy994.py @@ -1,8 +1,10 @@ """ homeassistant.components.switch.isy994 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Support for ISY994 switches. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/isy994.html """ import logging From 756cbe1b0829b679f4a1ee10e2da6165be4469d9 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:41:13 +0200 Subject: [PATCH 68/88] Remove configuration details --- homeassistant/components/sensor/worldclock.py | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/homeassistant/components/sensor/worldclock.py b/homeassistant/components/sensor/worldclock.py index 01767241a0a..3c15b48ad6a 100644 --- a/homeassistant/components/sensor/worldclock.py +++ b/homeassistant/components/sensor/worldclock.py @@ -4,26 +4,6 @@ homeassistant.components.sensor.worldclock The Worldclock sensor let you display the current time of a different time zone. -Configuration: - -To use the Worldclock sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: worldclock - time_zone: America/New_York - name: New York - -Variables: - -time_zone -*Required -Time zone you want to display. - -name -*Optional -Name of the sensor to use in the frontend. - For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.worldclock.html """ From 3ea167203f670d1decb47d69049106bb9b4fd070 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:48:30 +0200 Subject: [PATCH 69/88] Remove configuration details --- homeassistant/components/sensor/mysensors.py | 36 ++------------------ 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/sensor/mysensors.py b/homeassistant/components/sensor/mysensors.py index 84c62b26469..cb959522134 100644 --- a/homeassistant/components/sensor/mysensors.py +++ b/homeassistant/components/sensor/mysensors.py @@ -3,40 +3,8 @@ homeassistant.components.sensor.mysensors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support for MySensors sensors. -Configuration: - -To use the MySensors sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: mysensors - port: '/dev/ttyACM0' - -Variables: - -port -*Required -Port of your connection to your MySensors device. - -debug -*Optional -Enable or disable verbose debug logging. - -persistence -*Optional -Enable or disable local persistence of sensor information. -Note: If this is disabled, then each sensor will need to send presentation - messages after Home Assistant starts - -persistence_file -*Optional -Path to a file to save sensor information. -Note: The file extension determines the file type. Currently supported file - types are 'pickle' and 'json'. - -version -*Optional -Specifies the MySensors protocol version to use (ex. 1.4, 1.5). +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.mysensors.html """ import logging From 4f3b3a9e3469f18902ec1f1ed93020869b1bfcdb Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:53:58 +0200 Subject: [PATCH 70/88] Use the logger the same way as other platforms --- homeassistant/components/switch/wemo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index b27d0f58f7f..b598af04946 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -1,8 +1,10 @@ """ homeassistant.components.switch.wemo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Support for WeMo switches. + +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/switch.wemo.html """ import logging @@ -10,6 +12,7 @@ from homeassistant.components.switch import SwitchDevice from homeassistant.const import STATE_ON, STATE_OFF, STATE_STANDBY REQUIREMENTS = ['pywemo==0.3.1'] +_LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument @@ -26,7 +29,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): return - logging.getLogger(__name__).info("Scanning for WeMo devices") + _LOGGER.info("Scanning for WeMo devices.") switches = pywemo.discover_devices() # Filter out the switches and wrap in WemoSwitch object @@ -132,5 +135,4 @@ class WemoSwitch(SwitchDevice): elif self.wemo.model_name == 'Maker': self.maker_params = self.wemo.maker_params except AttributeError: - logging.getLogger(__name__).warning( - 'Could not update status for %s', self.name) + _LOGGER.warning('Could not update status for %s', self.name) From 9f4a3f4aeae8f3bcf0831ca220ee06fb875626b2 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:57:07 +0200 Subject: [PATCH 71/88] Use the logger the same way as other platforms do --- homeassistant/components/switch/tellstick.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/switch/tellstick.py b/homeassistant/components/switch/tellstick.py index 20bfa295820..363de83fdfb 100644 --- a/homeassistant/components/switch/tellstick.py +++ b/homeassistant/components/switch/tellstick.py @@ -13,9 +13,10 @@ from homeassistant.const import (EVENT_HOMEASSISTANT_STOP, from homeassistant.helpers.entity import ToggleEntity import tellcore.constants as tellcore_constants from tellcore.library import DirectCallbackDispatcher -SINGAL_REPETITIONS = 1 +SINGAL_REPETITIONS = 1 REQUIREMENTS = ['tellcore-py==1.1.2'] +_LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument @@ -24,8 +25,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): try: import tellcore.telldus as telldus except ImportError: - logging.getLogger(__name__).exception( - "Failed to import tellcore") + _LOGGER.exception("Failed to import tellcore") return core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher()) From 5dbdf82ec78af64ae712e6d0193add0ec7561976 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 22:58:00 +0200 Subject: [PATCH 72/88] Fix typo --- homeassistant/components/switch/tellstick.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/tellstick.py b/homeassistant/components/switch/tellstick.py index 363de83fdfb..4bff2c8592c 100644 --- a/homeassistant/components/switch/tellstick.py +++ b/homeassistant/components/switch/tellstick.py @@ -14,7 +14,7 @@ from homeassistant.helpers.entity import ToggleEntity import tellcore.constants as tellcore_constants from tellcore.library import DirectCallbackDispatcher -SINGAL_REPETITIONS = 1 +SIGNAL_REPETITIONS = 1 REQUIREMENTS = ['tellcore-py==1.1.2'] _LOGGER = logging.getLogger(__name__) @@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): core = telldus.TelldusCore(callback_dispatcher=DirectCallbackDispatcher()) - signal_repetitions = config.get('signal_repetitions', SINGAL_REPETITIONS) + signal_repetitions = config.get('signal_repetitions', SIGNAL_REPETITIONS) switches_and_lights = core.devices() From 2e7912157b4547de958b547932d244690f5232ef Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 23:00:20 +0200 Subject: [PATCH 73/88] Remove configuration details --- .../sensor/swiss_public_transport.py | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 5a07b585430..8885e1184b7 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -4,30 +4,8 @@ homeassistant.components.sensor.swiss_public_transport The Swiss public transport sensor will give you the next two departure times from a given location to another one. This sensor is limited to Switzerland. -Configuration: - -To use the Swiss public transport sensor you will need to add something like -the following to your configuration.yaml file. - -sensor: - platform: swiss_public_transport - from: STATION_ID - to: STATION_ID - -Variables: - -from -*Required -Start station/stop of your trip. To search for the ID of the station, use the -an URL like this: http://transport.opendata.ch/v1/locations?query=Wankdorf -to query for the station. If the score is 100 ("score":"100" in the response), -it is a perfect match. - -to -*Required -Destination station/stop of the trip. Same procedure as for the start station. - -Details for the API : http://transport.opendata.ch +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.swiss_public_transport.html """ import logging from datetime import timedelta From 3406b41b0c2cd45970a9084a2107e9c0da2578d8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 23:08:27 +0200 Subject: [PATCH 74/88] Fix return value --- homeassistant/components/sensor/swiss_public_transport.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 8885e1184b7..69c69e29afb 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -38,8 +38,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.exception( "Unable to determine stations. " "Check your settings and/or the availability of opendata.ch") - - return None + return False dev = [] data = PublicTransportData(journey) From 67d5581a1b99732e3b51602ac2fecbd48fa08458 Mon Sep 17 00:00:00 2001 From: Pascal Bach Date: Fri, 23 Oct 2015 23:40:14 +0200 Subject: [PATCH 75/88] Add simple REST switch The switch can get the state via GET and set the state via POST on a given REST resource. It is not able to control arbitrary urls but it allows controlling switches exposed via "real" REST. --- homeassistant/components/switch/rest.py | 127 ++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 homeassistant/components/switch/rest.py diff --git a/homeassistant/components/switch/rest.py b/homeassistant/components/switch/rest.py new file mode 100644 index 00000000000..0504f96bc4b --- /dev/null +++ b/homeassistant/components/switch/rest.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- +""" +homeassistant.components.switch.rest +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Allows to configure a REST switch. + +Configuration: + +switch: + platform: rest + name: "Bedroom Switch" + resource: "http://IP_ADDRESS/ENDPOINT" + body_on: "ON" + body_off: "OFF" + +Variables: + +resource +*Required* + +name +*Optional +The name of the switch. Default is 'REST Switch'. + +body_on +*Optional +The body that represents enabled state. Default is "ON". + +body_off +*Optional +The body that represents disabled state. Default is "OFF". + +""" + +import logging +import requests + +from homeassistant.components.switch import SwitchDevice + +_LOGGER = logging.getLogger(__name__) + +DEFAULT_NAME = "REST Switch" +DEFAULT_BODY_ON = "ON" +DEFAULT_BODY_OFF = "OFF" + + +# pylint: disable=unused-argument +def setup_platform(hass, config, add_devices_callback, discovery_info=None): + """ Add REST Switch """ + + resource = config.get('resource') + + if resource is None: + _LOGGER.error("Missing required variable: resource") + return False + + try: + requests.get(resource, timeout=10) + except requests.exceptions.MissingSchema: + _LOGGER.error("Missing resource or schema in configuration. " + "Add http:// to your URL.") + return False + except requests.exceptions.ConnectionError: + _LOGGER.error("No route to device. " + "Please check the IP address in the configuration file.") + return False + + add_devices_callback([RestSwitch( + hass, + config.get('name', DEFAULT_NAME), + config.get('resource'), + config.get('body_on', DEFAULT_BODY_ON), + config.get('body_off', DEFAULT_BODY_OFF))]) + + +# pylint: disable=too-many-arguments +class RestSwitch(SwitchDevice): + """ Represents a switch that can be togggled using REST """ + def __init__(self, hass, name, resource, body_on, body_off): + self._state = None + self._hass = hass + self._name = name + self._resource = resource + self._body_on = body_on + self._body_off = body_off + + @property + def name(self): + """ The name of the switch. """ + return self._name + + @property + def is_on(self): + """ True if device is on. """ + return self._state + + def turn_on(self, **kwargs): + """ Turn the device on. """ + request = requests.post(self._resource, + data=self._body_on, + timeout=10) + if request.status_code == 200: + self._state = True + else: + _LOGGER.error("Can't turn on %s. Is device offline?", + self._resource) + + def turn_off(self, **kwargs): + """ Turn the device off. """ + request = requests.post(self._resource, + data=self._body_off, + timeout=10) + if request.status_code == 200: + self._state = False + else: + _LOGGER.error("Can't turn off %s. Is device offline?", + self._resource) + + def update(self): + """ Gets the latest data from REST API and updates the state. """ + request = requests.get(self._resource, timeout=10) + if request.text == self._body_on: + self._state = True + elif request.text == self._body_off: + self._state = False + else: + self._state = None From 97f81ad7a667ea2aa1b292c1defbe34e689a29e5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 23 Oct 2015 23:48:57 +0200 Subject: [PATCH 76/88] Add more details --- .../sensor/swiss_public_transport.py | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 69c69e29afb..33dd69ff1e4 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -18,6 +18,12 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _RESOURCE = 'http://transport.opendata.ch/v1/' +ATTR_DEPARTURE_TIME1 = 'Next departure' +ATTR_DEPARTURE_TIME2 = 'Next on departure' +ATTR_START = 'Start' +ATTR_TARGET = 'Destination' +ATTR_REMAINING_TIME = 'Remaining time' + # Return cached results if last scan was less then this time ago MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) @@ -52,7 +58,9 @@ class SwissPublicTransportSensor(Entity): def __init__(self, data, journey): self.data = data - self._name = '{}-{}'.format(journey[2], journey[3]) + self._name = 'Next Departure' + self._from = journey[2] + self._to = journey[3] self.update() @property @@ -65,12 +73,26 @@ class SwissPublicTransportSensor(Entity): """ Returns the state of the device. """ return self._state + @property + def state_attributes(self): + """ Returns the state attributes. """ + if self._times is not None: + return { + ATTR_DEPARTURE_TIME1: self._times[0], + ATTR_DEPARTURE_TIME2: self._times[1], + ATTR_START: self._from, + ATTR_TARGET: self._to, + ATTR_REMAINING_TIME: '{}'.format( + ':'.join(str(self._times[2]).split(':')[:2])) + } + # pylint: disable=too-many-branches def update(self): """ Gets the latest data from opendata.ch and updates the states. """ - times = self.data.update() + self.data.update() + self._times = self.data.times try: - self._state = ', '.join(times) + self._state = self._times[0] except TypeError: pass @@ -82,6 +104,7 @@ class PublicTransportData(object): def __init__(self, journey): self.start = journey[0] self.destination = journey[1] + self.times = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): @@ -94,16 +117,21 @@ class PublicTransportData(object): 'to=' + self.destination + '&' + 'fields[]=connections/from/departureTimestamp/&' + 'fields[]=connections/', - timeout=10) + timeout=30) connections = response.json()['connections'][:2] try: - return [ + self.times = [ dt_util.datetime_to_time_str( dt_util.as_local(dt_util.utc_from_timestamp( item['from']['departureTimestamp'])) ) for item in connections ] + self.times.append( + dt_util.as_local( + dt_util.utc_from_timestamp( + connections[0]['from']['departureTimestamp'])) - + dt_util.as_local(dt_util.utcnow())) except KeyError: - return ['n/a'] + self.times = ['n/a'] From bffce11a9aaf12b1df8dd755d3aa6a6aa7d37fd6 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:20:18 +0200 Subject: [PATCH 77/88] Remove configuration details --- .../components/thermostat/radiotherm.py | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 831fd18f009..7659613aa20 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -1,28 +1,10 @@ """ homeassistant.components.thermostat.radiotherm -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Adds support for Radio Thermostat wifi-enabled home thermostats - -Config: -thermostat: - platform: radiotherm - hold_temp: boolean to control if hass temp adjustments hold(True) or are - temporary(False) - host: list of thermostat host/ips to control - -Example: -thermostat: - platform: radiotherm - hold_temp: True - host: - - 192.168.99.137 - - 192.168.99.202 - -Configure two thermostats via the configuration.yaml. Temperature settings -sent from hass will be sent to thermostat and then hold at that temp. Set -to False if you set a thermostat schedule on the tstat itself and just want -hass to send temporary temp changes. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Adds 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.html """ import logging import datetime From 7e3483ab03c0625f79c1eb48b40bb496d2e3e1a4 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:24:14 +0200 Subject: [PATCH 78/88] Remove configuration details --- homeassistant/components/thermostat/radiotherm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 7659613aa20..53974a45eb5 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -1,7 +1,7 @@ """ homeassistant.components.thermostat.radiotherm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Adds 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 https://home-assistant.io/components/thermostat.radiotherm.html From f2fda2914a33c1a6da5df9d222b768b907ce079b Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:29:02 +0200 Subject: [PATCH 79/88] Fix continuation --- homeassistant/components/sensor/swiss_public_transport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 33dd69ff1e4..ab4f9694739 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -84,7 +84,7 @@ class SwissPublicTransportSensor(Entity): ATTR_TARGET: self._to, ATTR_REMAINING_TIME: '{}'.format( ':'.join(str(self._times[2]).split(':')[:2])) - } + } # pylint: disable=too-many-branches def update(self): From 1e0e48fcd7e02e8889ccfaf3a4522a121a87c2d7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:29:47 +0200 Subject: [PATCH 80/88] Use logger the same as other platforms do --- homeassistant/components/thermostat/radiotherm.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 53974a45eb5..22dce97ad22 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -1,7 +1,7 @@ """ homeassistant.components.thermostat.radiotherm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Adds 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 https://home-assistant.io/components/thermostat.radiotherm.html @@ -15,16 +15,14 @@ from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL, from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT) REQUIREMENTS = ['radiotherm==1.2'] - HOLD_TEMP = 'hold_temp' +_LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the Radio Thermostat. """ import radiotherm - logger = logging.getLogger(__name__) - hosts = [] if CONF_HOST in config: hosts = config[CONF_HOST] @@ -32,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): hosts.append(radiotherm.discover.discover_address()) if hosts is None: - logger.error("no radiotherm thermostats detected") + _LOGGER.error("No radiotherm thermostats detected") return hold_temp = config.get(HOLD_TEMP, False) @@ -43,8 +41,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): tstat = radiotherm.get_thermostat(host) tstats.append(RadioThermostat(tstat, hold_temp)) except (URLError, OSError): - logger.exception( - "Unable to connect to Radio Thermostat: %s", host) + _LOGGER.exception("Unable to connect to Radio Thermostat: %s", + host) add_devices(tstats) From c19120e0123b76236d11f3523e2ebd64c00b9feb Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:34:49 +0200 Subject: [PATCH 81/88] Check import --- homeassistant/components/thermostat/radiotherm.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 22dce97ad22..3806b24533c 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -21,7 +21,13 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the Radio Thermostat. """ - import radiotherm + try: + import radiotherm + except ImportError: + _LOGGER.exception( + "Unable to import radiotherm. " + "Did you maybe not install the 'radiotherm' package?") + return False hosts = [] if CONF_HOST in config: From 060cbaf66b3722480e6bca54c2c32111179e7067 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 00:38:19 +0200 Subject: [PATCH 82/88] Add return value --- homeassistant/components/thermostat/radiotherm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index 3806b24533c..351ba387cb7 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -36,8 +36,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): hosts.append(radiotherm.discover.discover_address()) if hosts is None: - _LOGGER.error("No radiotherm thermostats detected") - return + _LOGGER.error("No radiotherm thermostats detected.") + return False hold_temp = config.get(HOLD_TEMP, False) tstats = [] From ade8681511d20906e328725b3cc53c8afac4dbdb Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 23 Oct 2015 23:44:04 -0700 Subject: [PATCH 83/88] Exclude rest switch from coverage --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 7e474d287c2..32458b4c606 100644 --- a/.coveragerc +++ b/.coveragerc @@ -91,6 +91,7 @@ omit = homeassistant/components/switch/command_switch.py homeassistant/components/switch/edimax.py homeassistant/components/switch/hikvisioncam.py + homeassistant/components/switch/rest.py homeassistant/components/switch/rpi_gpio.py homeassistant/components/switch/transmission.py homeassistant/components/switch/wemo.py From 0f81fc60ad7f57a69ed5a2c0385159355aad2cf8 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 09:10:31 +0200 Subject: [PATCH 84/88] Remove configuration details --- homeassistant/components/sensor/forecast.py | 52 +-------------------- 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/homeassistant/components/sensor/forecast.py b/homeassistant/components/sensor/forecast.py index 0cbafe53d97..fd08131cd4f 100644 --- a/homeassistant/components/sensor/forecast.py +++ b/homeassistant/components/sensor/forecast.py @@ -3,56 +3,8 @@ homeassistant.components.sensor.forecast ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Forecast.io weather service. -Configuration: - -To use the Forecast sensor you will need to add something like the -following to your configuration.yaml file. - -sensor: - platform: forecast - api_key: YOUR_APP_KEY - monitored_conditions: - - summary - - icon - - nearest_storm_distance - - nearest_storm_bearing - - precip_type - - precip_intensity - - precip_probability - - temperature - - apparent_temperature - - dew_point - - wind_speed - - wind_bearing - - cloud_cover - - humidity - - pressure - - visibility - - ozone - # Optional: specify which unit system to use. - units: si, us, ca, uk2 or auto - -Variables: - -api_key -*Required -To retrieve this value log into your account at http://forecast.io/. You can -make 1000 requests per day. This means that you could create every 1.4 minute -one. - -monitored_conditions -*Required -Conditions to monitor. See the configuration example above for a -list of all available conditions to monitor. - -units -*Optional -Specify the unit system. Default to 'si' or 'us' based on the temperature -preference in Home Assistant. Other options are auto, us, si, ca, and uk2. -'auto' will let forecast.io decide the unit system based on location. -For more information see the API url below. - -Details for the API : https://developer.forecast.io/docs/v2 +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/sensor.forecast.html """ import logging from datetime import timedelta From 649275044aae1cd58e5a273bd51a928898d802c7 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 24 Oct 2015 09:13:54 +0200 Subject: [PATCH 85/88] Remove configuration details --- .../components/media_player/denon.py | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/media_player/denon.py b/homeassistant/components/media_player/denon.py index 66b96ff7572..4c9065f5289 100644 --- a/homeassistant/components/media_player/denon.py +++ b/homeassistant/components/media_player/denon.py @@ -2,41 +2,9 @@ homeassistant.components.media_player.denon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Provides an interface to Denon Network Receivers. -Developed for a Denon DRA-N5, see -http://www.denon.co.uk/chg/product/compactsystems/networkmusicsystems/ceolpiccolo -A few notes: - - The receiver handles only one telnet connection and refuses others. - - - Be careful with the volume. 50% or even 100% are very loud. - - - To be able to wake up the receiver, activate the "remote" setting - in the receiver's settings. - - - Play and pause are supported, toggling is not possible. - - - Seeking cannot be implemented as the UI sends absolute positions. - Only seeking via simulated button presses is possible. - -Configuration: - -To use your Denon you will need to add something like the following to -your config/configuration.yaml: - -media_player: - platform: denon - name: Music station - host: 192.168.0.123 - -Variables: - -host -*Required -The ip of the player. Example: 192.168.0.123 - -name -*Optional -The name of the device. +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/media_player.denon.html """ import telnetlib import logging From 83e6c24f18d5457fa90543e9e8bde2e7e89bf46f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 24 Oct 2015 11:27:47 -0700 Subject: [PATCH 86/88] Re-enable Z-Wave for Docker --- Dockerfile | 11 +++++------ script/build_python_openzwave | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9554ec552d7..9344ec65245 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,11 +10,10 @@ RUN apt-get update && \ apt-get install -y --no-install-recommends nmap net-tools && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Open Z-Wave disabled because broken -#RUN apt-get update && \ -# apt-get install -y cython3 libudev-dev && \ -# apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ -# pip3 install cython && \ -# scripts/build_python_openzwave +RUN apt-get update && \ + apt-get install -y cython3 libudev-dev && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ + pip3 install "cython<0.23" && \ + script/build_python_openzwave CMD [ "python", "-m", "homeassistant", "--config", "/config" ] diff --git a/script/build_python_openzwave b/script/build_python_openzwave index 02c088fca44..029fd7873e6 100755 --- a/script/build_python_openzwave +++ b/script/build_python_openzwave @@ -1,7 +1,7 @@ # Sets up and builds python open zwave to be used with Home Assistant -# Dependencies that need to be installed: +# Dependencies that need to be installed: # apt-get install cython3 libudev-dev python-sphinx python3-setuptools -# pip3 install cython +# pip3 install "cython<0.23" cd "$(dirname "$0")/.." From e461ceae36238a24cd213ea5d86790cb56ec9b09 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 24 Oct 2015 12:18:48 -0700 Subject: [PATCH 87/88] discovery: update Netdisco requirement --- homeassistant/components/discovery.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/discovery.py b/homeassistant/components/discovery.py index 089db3fb324..0b3cc1025cc 100644 --- a/homeassistant/components/discovery.py +++ b/homeassistant/components/discovery.py @@ -19,7 +19,7 @@ from homeassistant.const import ( DOMAIN = "discovery" DEPENDENCIES = [] -REQUIREMENTS = ['netdisco==0.4.2'] +REQUIREMENTS = ['netdisco==0.5'] SCAN_INTERVAL = 300 # seconds diff --git a/requirements_all.txt b/requirements_all.txt index de1fa9e40ac..c63eea25853 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -87,7 +87,7 @@ https://github.com/theolind/pymysensors/archive/d4b809c2167650691058d1e29bfd2c4b pynetgear==0.3 # Netdisco (discovery) -netdisco==0.4.2 +netdisco==0.5 # Wemo (switch.wemo) pywemo==0.3.1 From 96181a555a73107b7b462dabb4ebe6f2ce3ce4a0 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 24 Oct 2015 12:40:36 -0700 Subject: [PATCH 88/88] Allow pipes in command sensors and services --- homeassistant/components/sensor/command_sensor.py | 2 +- homeassistant/components/shell_command.py | 2 +- tests/components/test_shell_command.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/command_sensor.py b/homeassistant/components/sensor/command_sensor.py index fc651fcc157..82ac36be500 100644 --- a/homeassistant/components/sensor/command_sensor.py +++ b/homeassistant/components/sensor/command_sensor.py @@ -98,7 +98,7 @@ class CommandSensorData(object): _LOGGER.info('Running command: %s', self.command) try: - return_value = subprocess.check_output(self.command.split()) + return_value = subprocess.check_output(self.command, shell=True) self.value = return_value.strip().decode('utf-8') except subprocess.CalledProcessError: _LOGGER.error('Command failed: %s', self.command) diff --git a/homeassistant/components/shell_command.py b/homeassistant/components/shell_command.py index c5c60e98e7d..493b605091a 100644 --- a/homeassistant/components/shell_command.py +++ b/homeassistant/components/shell_command.py @@ -34,7 +34,7 @@ def setup(hass, config): def service_handler(call): """ Execute a shell command service. """ try: - subprocess.call(conf[call.service].split(' '), + subprocess.call(conf[call.service], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) except subprocess.SubprocessError: diff --git a/tests/components/test_shell_command.py b/tests/components/test_shell_command.py index d9248d8f861..eefbdc5b230 100644 --- a/tests/components/test_shell_command.py +++ b/tests/components/test_shell_command.py @@ -30,7 +30,7 @@ class TestShellCommand(unittest.TestCase): path = os.path.join(tempdirname, 'called.txt') self.assertTrue(shell_command.setup(self.hass, { 'shell_command': { - 'test_service': "touch {}".format(path) + 'test_service': "date > {}".format(path) } }))