fix req_all
This commit is contained in:
commit
02a8ce71d0
146 files changed
+3761
-1539
No files matched your search
@@ -12,7 +12,6 @@ from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.components import wink, zwave, isy994, verisure, ecobee
|
||||
|
||||
DOMAIN = 'sensor'
|
||||
DEPENDENCIES = []
|
||||
SCAN_INTERVAL = 30
|
||||
|
||||
ENTITY_ID_FORMAT = DOMAIN + '.{}'
|
||||
|
||||
@@ -6,13 +6,14 @@ 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/
|
||||
"""
|
||||
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__)
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ ecobee:
|
||||
hold_temp: True
|
||||
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components import ecobee
|
||||
from homeassistant.const import TEMP_FAHRENHEIT
|
||||
import logging
|
||||
|
||||
DEPENDENCIES = ['ecobee']
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -9,17 +9,11 @@ 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,
|
||||
|
||||
@@ -6,9 +6,10 @@ 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/
|
||||
"""
|
||||
import logging
|
||||
import requests
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import requests
|
||||
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@@ -116,7 +117,11 @@ class GlancesSensor(Entity):
|
||||
elif self.type == 'disk_use':
|
||||
return round(value['fs'][0]['used'] / 1024**3, 1)
|
||||
elif self.type == 'disk_free':
|
||||
return 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':
|
||||
return value['mem']['percent']
|
||||
elif self.type == 'memory_use':
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -6,10 +6,11 @@ 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/
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -11,7 +11,6 @@ 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. """
|
||||
|
||||
@@ -6,13 +6,10 @@ 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/
|
||||
"""
|
||||
# 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
|
||||
|
||||
@@ -6,12 +6,11 @@ Monitors SABnzbd NZB client API.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
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'
|
||||
|
||||
@@ -9,9 +9,6 @@ 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(
|
||||
|
||||
@@ -6,18 +6,13 @@ Monitors Transmission BitTorrent client API.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
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()
|
||||
|
||||
@@ -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 + '%'
|
||||
|
||||
|
||||
@@ -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/'
|
||||
'9eb39eaba0717922815e673ad1114c685839d890.zip'
|
||||
'#python-wink==0.1.1']
|
||||
'42fdcfa721b1bc583688e3592d8427f4c13ba6d9.zip'
|
||||
'#python-wink==0.2']
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
@@ -6,11 +6,11 @@ Interfaces with Z-Wave sensors.
|
||||
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
|
||||
@@ -79,6 +79,9 @@ 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
|
||||
|
||||
|
||||
Reference in new issue
Block a user