Merge 'dev' into mysensors-component-switch

This commit is contained in:
MartinHjelmare committed 2015-12-05 23:55:36 +01:00
commit 1d141566bd
237 files changed
+7086 -2944

No files matched your search

+6 -3
View File
@@ -2,14 +2,16 @@
homeassistant.components.sensor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Component to interface with various sensors that can be monitored.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/sensor/
"""
import logging
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.components import wink, zwave, isy994, verisure
from homeassistant.components import wink, zwave, isy994, verisure, ecobee
DOMAIN = 'sensor'
DEPENDENCIES = []
SCAN_INTERVAL = 30
ENTITY_ID_FORMAT = DOMAIN + '.{}'
@@ -19,7 +21,8 @@ DISCOVERY_PLATFORMS = {
wink.DISCOVER_SENSORS: 'wink',
zwave.DISCOVER_SENSORS: 'zwave',
isy994.DISCOVER_SENSORS: 'isy994',
verisure.DISCOVER_SENSORS: 'verisure'
verisure.DISCOVER_SENSORS: 'verisure',
ecobee.DISCOVER_SENSORS: 'ecobee'
}
+1 -1
View File
@@ -5,7 +5,7 @@ Support for getting information from Arduino pins. Only analog pins are
supported.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.arduino.html
https://home-assistant.io/components/sensor.arduino/
"""
import logging
+6 -5
View File
@@ -4,15 +4,16 @@ homeassistant.components.sensor.arest
The arest sensor will consume an exposed aREST API of a device.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.arest.html
https://home-assistant.io/components/sensor.arest/
"""
import logging
import requests
from datetime import timedelta
import logging
import requests
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.bitcoin
Bitcoin information service that uses blockchain.info and its online wallet.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.bitcoin.html
https://home-assistant.io/components/sensor.bitcoin/
"""
import logging
from datetime import timedelta
@@ -4,7 +4,7 @@ homeassistant.components.sensor.command_sensor
Allows to configure custom shell commands to turn a value for a sensor.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.command_sensor.html
https://home-assistant.io/components/sensor.command_sensor/
"""
import logging
import subprocess
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.cpuspeed
Shows the current CPU speed.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.cpuspeed.html
https://home-assistant.io/components/sensor.cpuspeed/
"""
import logging
-1
View File
@@ -13,7 +13,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices([
DemoSensor('Outside Temperature', 15.6, TEMP_CELCIUS, 12),
DemoSensor('Outside Humidity', 54, '%', None),
DemoSensor('Alarm back', 'Armed', None, None),
])
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.dht
Adafruit DHT temperature and humidity sensor.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.dht.html
https://home-assistant.io/components/sensor.dht/
"""
import logging
from datetime import timedelta
+109
View File
@@ -0,0 +1,109 @@
"""
homeassistant.components.sensor.ecobee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ecobee Thermostat Component
This component adds support for Ecobee3 Wireless Thermostats.
You will need to setup developer access to your thermostat,
and create and API key on the ecobee website.
The first time you run this component you will see a configuration
component card in Home Assistant. This card will contain a PIN code
that you will need to use to authorize access to your thermostat. You
can do this at https://www.ecobee.com/consumerportal/index.html
Click My Apps, Add application, Enter Pin and click Authorize.
After authorizing the application click the button in the configuration
card. Now your thermostat and sensors should shown in home-assistant.
You can use the optional hold_temp parameter to set whether or not holds
are set indefintely or until the next scheduled event.
ecobee:
api_key: asdfasdfasdfasdfasdfaasdfasdfasdfasdf
hold_temp: True
"""
import logging
from homeassistant.helpers.entity import Entity
from homeassistant.components import ecobee
from homeassistant.const import TEMP_FAHRENHEIT
DEPENDENCIES = ['ecobee']
SENSOR_TYPES = {
'temperature': ['Temperature', TEMP_FAHRENHEIT],
'humidity': ['Humidity', '%'],
'occupancy': ['Occupancy', '']
}
_LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the sensors. """
if discovery_info is None:
return
data = ecobee.NETWORK
dev = list()
for index in range(len(data.ecobee.thermostats)):
for sensor in data.ecobee.get_remote_sensors(index):
for item in sensor['capability']:
if item['type'] not in ('temperature',
'humidity', 'occupancy'):
continue
dev.append(EcobeeSensor(sensor['name'], item['type'], index))
add_devices(dev)
class EcobeeSensor(Entity):
""" An ecobee sensor. """
def __init__(self, sensor_name, sensor_type, sensor_index):
self._name = sensor_name + ' ' + SENSOR_TYPES[sensor_type][0]
self.sensor_name = sensor_name
self.type = sensor_type
self.index = sensor_index
self._state = None
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self.update()
@property
def name(self):
return self._name.rstrip()
@property
def state(self):
""" Returns the state of the device. """
return self._state
@property
def unit_of_measurement(self):
return self._unit_of_measurement
def update(self):
data = ecobee.NETWORK
data.update()
for sensor in data.ecobee.get_remote_sensors(self.index):
for item in sensor['capability']:
if (
item['type'] == self.type and
self.type == 'temperature' and
self.sensor_name == sensor['name']):
self._state = float(item['value']) / 10
elif (
item['type'] == self.type and
self.type == 'humidity' and
self.sensor_name == sensor['name']):
self._state = item['value']
elif (
item['type'] == self.type and
self.type == 'occupancy' and
self.sensor_name == sensor['name']):
self._state = item['value']
+2 -2
View File
@@ -5,7 +5,7 @@ Monitors home energy use as measured by an efergy engage hub using its
(unofficial, undocumented) API.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.efergy.html
https://home-assistant.io/components/sensor.efergy/
"""
import logging
from requests import get, RequestException
@@ -97,5 +97,5 @@ class EfergySensor(Entity):
self._state = response.json()['sum']
else:
self._state = 'Unknown'
except RequestException:
except (RequestException, ValueError):
_LOGGER.warning('Could not update status for %s', self.name)
+5 -13
View File
@@ -4,22 +4,16 @@ homeassistant.components.sensor.forecast
Forecast.io weather service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.forecast.html
https://home-assistant.io/components/sensor.forecast/
"""
import logging
from datetime import timedelta
REQUIREMENTS = ['python-forecastio==1.3.3']
try:
import forecastio
except ImportError:
forecastio = None
from homeassistant.util import Throttle
from homeassistant.const import (CONF_API_KEY, TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['python-forecastio==1.3.3']
_LOGGER = logging.getLogger(__name__)
# Sensor types are defined like so:
@@ -53,11 +47,7 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=120)
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Get the Forecast.io sensor. """
global forecastio # pylint: disable=invalid-name
if forecastio is None:
import forecastio as forecastio_
forecastio = forecastio_
import forecastio
if None in (hass.config.latitude, hass.config.longitude):
_LOGGER.error("Latitude or longitude not set in Home Assistant config")
@@ -141,6 +131,7 @@ class ForeCastSensor(Entity):
# pylint: disable=too-many-branches
def update(self):
""" Gets the latest data from Forecast.io and updates the states. """
import forecastio
self.forecast_client.update()
data = self.forecast_client.data
@@ -209,6 +200,7 @@ class ForeCastData(object):
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from Forecast.io. """
import forecastio
forecast = forecastio.load_forecast(self._api_key,
self.latitude,
+53 -42
View File
@@ -4,19 +4,23 @@ homeassistant.components.sensor.glances
Gathers system information of hosts which running glances.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.glances.html
https://home-assistant.io/components/sensor.glances/
"""
import logging
import requests
from datetime import timedelta
import logging
import requests
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
from homeassistant.const import STATE_UNKNOWN
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'Glances Sensor'
_RESOURCE = '/api/2/all'
CONF_HOST = 'host'
CONF_PORT = '61208'
CONF_RESOURCES = 'resources'
SENSOR_TYPES = {
'disk_use_percent': ['Disk Use', '%'],
'disk_use': ['Disk Use', 'GiB'],
@@ -43,13 +47,15 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Setup the Glances sensor. """
if not config.get('host'):
_LOGGER.error('"host:" is missing your configuration')
return False
host = config.get('host')
port = config.get('port', 61208)
host = config.get(CONF_HOST)
port = config.get('port', CONF_PORT)
url = 'http://{}:{}{}'.format(host, port, _RESOURCE)
var_conf = config.get(CONF_RESOURCES)
if None in (host, var_conf):
_LOGGER.error('Not all required config keys present: %s',
', '.join((CONF_HOST, CONF_RESOURCES)))
return False
try:
response = requests.get(url, timeout=10)
@@ -57,18 +63,19 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_LOGGER.error('Response status is "%s"', response.status_code)
return False
except requests.exceptions.MissingSchema:
_LOGGER.error('Missing resource or schema in configuration. '
'Please heck our details in the configuration file.')
_LOGGER.error("Missing resource or schema in configuration. "
"Please check the details in the configuration file.")
return False
except requests.exceptions.ConnectionError:
_LOGGER.error('No route to resource/endpoint. '
'Please check the details in the configuration file.')
_LOGGER.error("No route to resource/endpoint: '%s'. "
"Please check the details in the configuration file.",
url)
return False
rest = GlancesData(url)
dev = []
for resource in config['resources']:
for resource in var_conf:
if resource not in SENSOR_TYPES:
_LOGGER.error('Sensor type: "%s" does not exist', resource)
else:
@@ -78,13 +85,13 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class GlancesSensor(Entity):
""" Implements a REST sensor. """
""" Implements a Glances sensor. """
def __init__(self, rest, sensor_type):
self.rest = rest
self._name = SENSOR_TYPES[sensor_type][0]
self.type = sensor_type
self._state = None
self._state = STATE_UNKNOWN
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self.update()
@@ -98,46 +105,49 @@ class GlancesSensor(Entity):
""" Unit the value is expressed in. """
return self._unit_of_measurement
# pylint: disable=too-many-branches, too-many-return-statements
@property
def state(self):
""" Returns the state of the device. """
return self._state
# pylint: disable=too-many-branches
def update(self):
""" Gets the latest data from REST API and updates the state. """
self.rest.update()
""" Returns the state of the resources. """
value = self.rest.data
if value is not None:
if self.type == 'disk_use_percent':
self._state = value['fs'][0]['percent']
return value['fs'][0]['percent']
elif self.type == 'disk_use':
self._state = round(value['fs'][0]['used'] / 1024**3, 1)
return round(value['fs'][0]['used'] / 1024**3, 1)
elif self.type == 'disk_free':
self._state = round(value['fs'][0]['free'] / 1024**3, 1)
try:
return round(value['fs'][0]['free'] / 1024**3, 1)
except KeyError:
return round((value['fs'][0]['size'] -
value['fs'][0]['used']) / 1024**3, 1)
elif self.type == 'memory_use_percent':
self._state = value['mem']['percent']
return value['mem']['percent']
elif self.type == 'memory_use':
self._state = round(value['mem']['used'] / 1024**2, 1)
return round(value['mem']['used'] / 1024**2, 1)
elif self.type == 'memory_free':
self._state = round(value['mem']['free'] / 1024**2, 1)
return round(value['mem']['free'] / 1024**2, 1)
elif self.type == 'swap_use_percent':
self._state = value['memswap']['percent']
return value['memswap']['percent']
elif self.type == 'swap_use':
self._state = round(value['memswap']['used'] / 1024**3, 1)
return round(value['memswap']['used'] / 1024**3, 1)
elif self.type == 'swap_free':
self._state = round(value['memswap']['free'] / 1024**3, 1)
return round(value['memswap']['free'] / 1024**3, 1)
elif self.type == 'processor_load':
self._state = value['load']['min15']
return value['load']['min15']
elif self.type == 'process_running':
self._state = value['processcount']['running']
return value['processcount']['running']
elif self.type == 'process_total':
self._state = value['processcount']['total']
return value['processcount']['total']
elif self.type == 'process_thread':
self._state = value['processcount']['thread']
return value['processcount']['thread']
elif self.type == 'process_sleeping':
self._state = value['processcount']['sleeping']
return value['processcount']['sleeping']
def update(self):
""" Gets the latest data from REST API. """
self.rest.update()
# pylint: disable=too-few-public-methods
@@ -145,15 +155,16 @@ class GlancesData(object):
""" Class for handling the data retrieval. """
def __init__(self, resource):
self.resource = resource
self._resource = resource
self.data = dict()
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
""" Gets the latest data from REST service. """
""" Gets the latest data from the Glances REST API. """
try:
response = requests.get(self.resource, timeout=10)
response = requests.get(self._resource, timeout=10)
self.data = response.json()
except requests.exceptions.ConnectionError:
_LOGGER.error("No route to host/endpoint.")
_LOGGER.error("No route to host/endpoint '%s'. Is device offline?",
self._resource)
self.data = None
+1 -1
View File
@@ -4,7 +4,7 @@ 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
https://home-assistant.io/components/isy994/
"""
import logging
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.modbus
Support for Modbus sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.modbus.html
https://home-assistant.io/components/sensor.modbus/
"""
import logging
+7 -4
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.mqtt
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
https://home-assistant.io/components/sensor.mqtt/
"""
import logging
from homeassistant.helpers.entity import Entity
@@ -31,23 +31,26 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
config.get('name', DEFAULT_NAME),
config.get('state_topic'),
config.get('qos', DEFAULT_QOS),
config.get('unit_of_measurement'))])
config.get('unit_of_measurement'),
config.get('state_format'))])
# pylint: disable=too-many-arguments, too-many-instance-attributes
class MqttSensor(Entity):
""" Represents a sensor that can be updated using MQTT. """
def __init__(self, hass, name, state_topic, qos, unit_of_measurement):
def __init__(self, hass, name, state_topic, qos, unit_of_measurement,
state_format):
self._state = "-"
self._hass = hass
self._name = name
self._state_topic = state_topic
self._qos = qos
self._unit_of_measurement = unit_of_measurement
self._parse = mqtt.FmtParser(state_format)
def message_received(topic, payload, qos):
""" A new MQTT message has been received. """
self._state = payload
self._state = self._parse(payload)
self.update_ha_state()
mqtt.subscribe(hass, self._state_topic, message_received, self._qos)
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.mysensors
Support for MySensors sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.mysensors.html
https://home-assistant.io/components/sensor.mysensors/
"""
import logging
@@ -4,7 +4,7 @@ homeassistant.components.sensor.openweathermap
OpenWeatherMap (OWM) service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.openweathermap.html
https://home-assistant.io/components/sensor.openweathermap/
"""
import logging
from datetime import timedelta
+5 -4
View File
@@ -4,12 +4,13 @@ homeassistant.components.sensor.rest
The rest sensor will consume JSON responses sent by an exposed REST API.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rest.html
https://home-assistant.io/components/sensor.rest/
"""
import logging
import requests
from json import loads
from datetime import timedelta
from json import loads
import logging
import requests
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
+6 -2
View File
@@ -4,14 +4,13 @@ homeassistant.components.sensor.rfxtrx
Shows sensor values from RFXtrx sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rfxtrx.html
https://home-assistant.io/components/sensor.rfxtrx/
"""
import logging
from collections import OrderedDict
from homeassistant.const import (TEMP_CELCIUS)
from homeassistant.helpers.entity import Entity
from RFXtrx import SensorEvent
import homeassistant.components.rfxtrx as rfxtrx
from homeassistant.util import slugify
@@ -28,6 +27,7 @@ _LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Setup the RFXtrx platform. """
from RFXtrx import SensorEvent
def sensor_update(event):
""" Callback for sensor updates from the RFXtrx gateway. """
@@ -43,6 +43,10 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
rfxtrx.RFX_DEVICES[entity_id] = new_sensor
add_devices_callback([new_sensor])
else:
_LOGGER.debug(
"EntityID: %s sensor_update",
entity_id,
)
rfxtrx.RFX_DEVICES[entity_id].event = event
if sensor_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
+4 -9
View File
@@ -4,15 +4,12 @@ homeassistant.components.sensor.rpi_gpio
Allows to configure a binary state sensor using RPi GPIO.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.rpi_gpio.html
https://home-assistant.io/components/sensor.rpi_gpio/
"""
# pylint: disable=import-error
import logging
from homeassistant.helpers.entity import Entity
try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
from homeassistant.const import (DEVICE_DEFAULT_NAME,
EVENT_HOMEASSISTANT_START,
EVENT_HOMEASSISTANT_STOP)
@@ -29,10 +26,7 @@ _LOGGER = logging.getLogger(__name__)
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Raspberry PI GPIO ports. """
if GPIO is None:
_LOGGER.error('RPi.GPIO not available. rpi_gpio ports ignored.')
return
# pylint: disable=no-member
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
sensors = []
@@ -65,6 +59,7 @@ class RPiGPIOSensor(Entity):
def __init__(self, port_name, port_num, pull_mode,
value_high, value_low, bouncetime):
# pylint: disable=no-member
import RPi.GPIO as GPIO
self._name = port_name or DEVICE_DEFAULT_NAME
self._port = port_num
self._pull = GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP
+3 -4
View File
@@ -4,14 +4,13 @@ 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/sensor.sabnzbd.html
https://home-assistant.io/components/sensor.sabnzbd/
"""
from homeassistant.util import Throttle
from datetime import timedelta
import logging
from homeassistant.helpers.entity import Entity
import logging
from homeassistant.util import Throttle
REQUIREMENTS = ['https://github.com/jamespcole/home-assistant-nzb-clients/'
'archive/616cad59154092599278661af17e2a9f2cf5e2a9.zip'
@@ -5,7 +5,7 @@ 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.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.swiss_public_transport.html
https://home-assistant.io/components/sensor.swiss_public_transport/
"""
import logging
from datetime import timedelta
@@ -4,7 +4,7 @@ homeassistant.components.sensor.systemmonitor
Shows system monitor values such as: disk, memory, and processor use.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.systemmonitor.html
https://home-assistant.io/components/sensor.systemmonitor/
"""
import logging
+4 -4
View File
@@ -4,14 +4,11 @@ homeassistant.components.sensor.tellstick
Shows sensor values from Tellstick sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.tellstick.html
https://home-assistant.io/components/sensor.tellstick/
"""
import logging
from collections import namedtuple
import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants
from homeassistant.const import TEMP_CELCIUS
from homeassistant.helpers.entity import Entity
import homeassistant.util as util
@@ -24,6 +21,9 @@ REQUIREMENTS = ['tellcore-py==1.1.2']
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up Tellstick sensors. """
import tellcore.telldus as telldus
import tellcore.constants as tellcore_constants
sensor_value_descriptions = {
tellcore_constants.TELLSTICK_TEMPERATURE:
DatatypeDescription(
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.temper
Support for getting temperature from TEMPer devices.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.temper.html
https://home-assistant.io/components/sensor.temper/
"""
import logging
from homeassistant.helpers.entity import Entity
+1 -1
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.time_date
Date and Time service.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.time_date.html
https://home-assistant.io/components/sensor.time_date/
"""
import logging
+10 -10
View File
@@ -4,20 +4,15 @@ homeassistant.components.sensor.transmission
Monitors Transmission BitTorrent client API.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.transmission.html
https://home-assistant.io/components/sensor.transmission/
"""
from homeassistant.util import Throttle
from datetime import timedelta
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
from homeassistant.helpers.entity import Entity
# pylint: disable=no-name-in-module, import-error
import transmissionrpc
from transmissionrpc.error import TransmissionError
import logging
from homeassistant.const import CONF_HOST, CONF_USERNAME, CONF_PASSWORD
from homeassistant.util import Throttle
from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['transmissionrpc==0.11']
SENSOR_TYPES = {
'current_status': ['Status', ''],
@@ -33,6 +28,9 @@ _THROTTLED_REFRESH = None
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Transmission sensors. """
import transmissionrpc
from transmissionrpc.error import TransmissionError
host = config.get(CONF_HOST)
username = config.get(CONF_USERNAME, None)
password = config.get(CONF_PASSWORD, None)
@@ -97,6 +95,8 @@ class TransmissionSensor(Entity):
def refresh_transmission_data(self):
""" Calls the throttled Transmission refresh method. """
from transmissionrpc.error import TransmissionError
if _THROTTLED_REFRESH is not None:
try:
_THROTTLED_REFRESH()
+5 -5
View File
@@ -4,7 +4,7 @@ homeassistant.components.sensor.vera
Support for Vera sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.vera.html
https://home-assistant.io/components/sensor.vera/
"""
import logging
from requests.exceptions import RequestException
@@ -15,9 +15,9 @@ from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME,
TEMP_CELCIUS, TEMP_FAHRENHEIT)
REQUIREMENTS = ['https://github.com/balloob/home-assistant-vera-api/archive/'
'a8f823066ead6c7da6fb5e7abaf16fef62e63364.zip'
'#python-vera==0.1']
REQUIREMENTS = ['https://github.com/pavoni/home-assistant-vera-api/archive/'
'efdba4e63d58a30bc9b36d9e01e69858af9130b8.zip'
'#python-vera==0.1.1']
_LOGGER = logging.getLogger(__name__)
@@ -95,7 +95,7 @@ class VeraSensor(Entity):
@property
def state_attributes(self):
attr = super().state_attributes
attr = {}
if self.vera_device.has_battery:
attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%'
+2 -2
View File
@@ -3,8 +3,8 @@ 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
For more details about this platform, please refer to the documentation at
documentation at https://home-assistant.io/components/verisure/
"""
import logging
+4 -4
View File
@@ -3,8 +3,8 @@ 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/sensor.wink.html
For more details about this platform, please refer to the documentation at
at https://home-assistant.io/components/sensor.wink/
"""
import logging
@@ -12,8 +12,8 @@ from homeassistant.helpers.entity import Entity
from homeassistant.const import CONF_ACCESS_TOKEN, STATE_OPEN, STATE_CLOSED
REQUIREMENTS = ['https://github.com/balloob/python-wink/archive/'
'c2b700e8ca866159566ecf5e644d9c297f69f257.zip'
'#python-wink==0.1']
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
'#python-wink==0.2']
def setup_platform(hass, config, add_devices, discovery_info=None):
@@ -5,7 +5,7 @@ The Worldclock sensor let you display the current time of a different time
zone.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.worldclock.html
https://home-assistant.io/components/sensor.worldclock/
"""
import logging
+22 -5
View File
@@ -3,14 +3,14 @@ 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
For more details about this platform, please refer to the documentation
at https://home-assistant.io/components/zwave/
"""
# Because we do not compile openzwave on CI
# pylint: disable=import-error
from homeassistant.helpers.event import track_point_in_time
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
import datetime
from homeassistant.helpers.event import track_point_in_time
import homeassistant.util.dt as dt_util
import homeassistant.components.zwave as zwave
from homeassistant.helpers.entity import Entity
@@ -31,6 +31,16 @@ DEVICE_MAPPINGS = {
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up Z-Wave sensors. """
# Return on empty `discovery_info`. Given you configure HA with:
#
# sensor:
# platform: zwave
#
# `setup_platform` will be called without `discovery_info`.
if discovery_info is None:
return
node = zwave.NETWORK.nodes[discovery_info[zwave.ATTR_NODE_ID]]
value = node.values[discovery_info[zwave.ATTR_VALUE_ID]]
@@ -60,11 +70,18 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
elif value.command_class == zwave.COMMAND_CLASS_SENSOR_MULTILEVEL:
add_devices([ZWaveMultilevelSensor(value)])
elif (value.command_class == zwave.COMMAND_CLASS_METER and
value.type == zwave.TYPE_DECIMAL):
add_devices([ZWaveMultilevelSensor(value)])
class ZWaveSensor(Entity):
""" Represents a Z-Wave sensor. """
def __init__(self, sensor_value):
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
self._value = sensor_value
self._node = sensor_value.node