1 parent
0100f87ff2
commit
47e31dc9ee
143 files changed
+1584
-1761
No files matched your search
@@ -47,8 +47,8 @@ class AbodeSensor(AbodeDevice):
|
||||
super().__init__(data, device)
|
||||
self._sensor_type = sensor_type
|
||||
self._icon = 'mdi:{}'.format(SENSOR_TYPES[self._sensor_type][1])
|
||||
self._name = '{0} {1}'.format(self._device.name,
|
||||
SENSOR_TYPES[self._sensor_type][0])
|
||||
self._name = '{0} {1}'.format(
|
||||
self._device.name, SENSOR_TYPES[self._sensor_type][0])
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
||||
@@ -3,33 +3,32 @@ Support for ADS sensors.
|
||||
|
||||
For more details about this platform, please refer to the documentation.
|
||||
https://home-assistant.io/components/sensor.ads/
|
||||
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import ads
|
||||
from homeassistant.components.ads import (
|
||||
CONF_ADS_FACTOR, CONF_ADS_TYPE, CONF_ADS_VAR)
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME, CONF_UNIT_OF_MEASUREMENT
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components import ads
|
||||
from homeassistant.components.ads import CONF_ADS_VAR, CONF_ADS_TYPE, \
|
||||
CONF_ADS_FACTOR
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_NAME = 'ADS sensor'
|
||||
DEFAULT_NAME = "ADS sensor"
|
||||
DEPENDENCIES = ['ads']
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ADS_VAR): cv.string,
|
||||
vol.Optional(CONF_ADS_FACTOR): cv.positive_int,
|
||||
vol.Optional(CONF_ADS_TYPE, default=ads.ADSTYPE_INT):
|
||||
vol.In([ads.ADSTYPE_INT, ads.ADSTYPE_UINT, ads.ADSTYPE_BYTE]),
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_UNIT_OF_MEASUREMENT, default=''): cv.string,
|
||||
vol.Optional(CONF_ADS_TYPE, default=ads.ADSTYPE_INT): vol.In(
|
||||
[ads.ADSTYPE_INT, ads.ADSTYPE_UINT, ads.ADSTYPE_BYTE]
|
||||
),
|
||||
vol.Optional(CONF_ADS_FACTOR): cv.positive_int,
|
||||
})
|
||||
|
||||
|
||||
@@ -43,8 +42,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
unit_of_measurement = config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||
factor = config.get(CONF_ADS_FACTOR)
|
||||
|
||||
entity = AdsSensor(ads_hub, ads_var, ads_type, name,
|
||||
unit_of_measurement, factor)
|
||||
entity = AdsSensor(
|
||||
ads_hub, ads_var, ads_type, name, unit_of_measurement, factor)
|
||||
|
||||
add_devices([entity])
|
||||
|
||||
@@ -68,9 +67,9 @@ class AdsSensor(Entity):
|
||||
"""Register device notification."""
|
||||
def update(name, value):
|
||||
"""Handle device notifications."""
|
||||
_LOGGER.debug('Variable %s changed its value to %d', name, value)
|
||||
_LOGGER.debug("Variable %s changed its value to %d", name, value)
|
||||
|
||||
# if factor is set use it otherwise not
|
||||
# If factor is set use it otherwise not
|
||||
if self.factor is None:
|
||||
self._value = value
|
||||
else:
|
||||
@@ -99,5 +98,5 @@ class AdsSensor(Entity):
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Return False because entity pushes its state to HA."""
|
||||
"""Return False because entity pushes its state."""
|
||||
return False
|
||||
@@ -86,12 +86,12 @@ class DeconzSensor(Entity):
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Unit of measurement of this sensor."""
|
||||
"""Return the unit of measurement of this sensor."""
|
||||
return self._sensor.sensor_unit
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if sensor is available."""
|
||||
"""Return true if sensor is available."""
|
||||
return self._sensor.reachable
|
||||
|
||||
@property
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
"""Support for Dyson Pure Cool Link Sensors.
|
||||
"""
|
||||
Support for Dyson Pure Cool Link Sensors.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.dyson/
|
||||
"""
|
||||
import logging
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.const import TEMP_CELSIUS, STATE_OFF
|
||||
from homeassistant.components.dyson import DYSON_DEVICES
|
||||
|
||||
from homeassistant.const import STATE_OFF, TEMP_CELSIUS
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
DEPENDENCIES = ['dyson']
|
||||
|
||||
SENSOR_UNITS = {
|
||||
"filter_life": "hours",
|
||||
"humidity": "%",
|
||||
"dust": "level",
|
||||
"air_quality": "level"
|
||||
'air_quality': 'level',
|
||||
'dust': 'level',
|
||||
'filter_life': 'hours',
|
||||
'humidity': '%',
|
||||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -25,7 +25,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the Dyson Sensors."""
|
||||
_LOGGER.info("Creating new Dyson fans")
|
||||
_LOGGER.debug("Creating new Dyson fans")
|
||||
devices = []
|
||||
unit = hass.config.units.temperature_unit
|
||||
# Get Dyson Devices from parent component
|
||||
@@ -52,12 +52,12 @@ class DysonSensor(Entity):
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Callback when entity is added to hass."""
|
||||
"""Call when entity is added to hass."""
|
||||
self.hass.async_add_job(
|
||||
self._device.add_message_listener, self.on_message)
|
||||
|
||||
def on_message(self, message):
|
||||
"""Called when new messages received from the fan."""
|
||||
"""Handle new messages which are received from the fan."""
|
||||
# Prevent refreshing if not needed
|
||||
if self._old_value is None or self._old_value != self.state:
|
||||
_LOGGER.debug("Message received for %s device: %s", self.name,
|
||||
|
||||
@@ -4,19 +4,19 @@ IMAP sensor support.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.imap/
|
||||
"""
|
||||
import logging
|
||||
import asyncio
|
||||
import async_timeout
|
||||
import logging
|
||||
|
||||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_NAME, CONF_PORT, CONF_USERNAME, CONF_PASSWORD,
|
||||
CONF_NAME, CONF_PASSWORD, CONF_PORT, CONF_USERNAME,
|
||||
EVENT_HOMEASSISTANT_STOP)
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Setup the IMAP platform."""
|
||||
"""Set up the IMAP platform."""
|
||||
sensor = ImapSensor(config.get(CONF_NAME),
|
||||
config.get(CONF_USERNAME),
|
||||
config.get(CONF_PASSWORD),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""KIRA interface to receive UDP packets from an IR-IP bridge."""
|
||||
# pylint: disable=import-error
|
||||
"""
|
||||
KIRA interface to receive UDP packets from an IR-IP bridge.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.kira/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
CONF_NAME,
|
||||
STATE_UNKNOWN)
|
||||
|
||||
from homeassistant.const import CONF_DEVICE, CONF_NAME, STATE_UNKNOWN
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
DOMAIN = 'kira'
|
||||
@@ -15,17 +15,18 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ICON = 'mdi:remote'
|
||||
|
||||
CONF_SENSOR = "sensor"
|
||||
CONF_SENSOR = 'sensor'
|
||||
|
||||
|
||||
# pylint: disable=unused-argument, too-many-function-args
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
"""Setup Kira sensor."""
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up a Kira sensor."""
|
||||
if discovery_info is not None:
|
||||
name = discovery_info.get(CONF_NAME)
|
||||
device = discovery_info.get(CONF_DEVICE)
|
||||
kira = hass.data[DOMAIN][CONF_SENSOR][name]
|
||||
add_devices_callback([KiraReceiver(device, kira)])
|
||||
|
||||
add_devices([KiraReceiver(device, kira)])
|
||||
|
||||
|
||||
class KiraReceiver(Entity):
|
||||
@@ -34,14 +35,14 @@ class KiraReceiver(Entity):
|
||||
def __init__(self, name, kira):
|
||||
"""Initialize the sensor."""
|
||||
self._name = name
|
||||
self._state = STATE_UNKNOWN
|
||||
self._state = None
|
||||
self._device = STATE_UNKNOWN
|
||||
|
||||
kira.registerCallback(self._update_callback)
|
||||
|
||||
def _update_callback(self, code):
|
||||
code_name, device = code
|
||||
_LOGGER.info("Kira Code: %s", code_name)
|
||||
_LOGGER.debug("Kira Code: %s", code_name)
|
||||
self._state = code_name
|
||||
self._device = device
|
||||
self.schedule_update_ha_state()
|
||||
@@ -64,9 +65,7 @@ class KiraReceiver(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the device."""
|
||||
attr = {}
|
||||
attr[CONF_DEVICE] = self._device
|
||||
return attr
|
||||
return {CONF_DEVICE: self._device}
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
|
||||
@@ -5,14 +5,15 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.knx/
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.knx import DATA_KNX, ATTR_DISCOVER_DEVICES
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.knx import ATTR_DISCOVER_DEVICES, DATA_KNX
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
CONF_ADDRESS = 'address'
|
||||
CONF_TYPE = 'type'
|
||||
@@ -28,20 +29,16 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up sensor(s) for KNX platform."""
|
||||
if DATA_KNX not in hass.data \
|
||||
or not hass.data[DATA_KNX].initialized:
|
||||
return False
|
||||
if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized:
|
||||
return
|
||||
|
||||
if discovery_info is not None:
|
||||
async_add_devices_discovery(hass, discovery_info, async_add_devices)
|
||||
else:
|
||||
async_add_devices_config(hass, config, async_add_devices)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@callback
|
||||
def async_add_devices_discovery(hass, discovery_info, async_add_devices):
|
||||
@@ -70,7 +67,7 @@ class KNXSensor(Entity):
|
||||
"""Representation of a KNX sensor."""
|
||||
|
||||
def __init__(self, hass, device):
|
||||
"""Initialization of KNXSensor."""
|
||||
"""Initialize of a KNX sensor."""
|
||||
self.device = device
|
||||
self.hass = hass
|
||||
self.async_register_callbacks()
|
||||
@@ -80,7 +77,7 @@ class KNXSensor(Entity):
|
||||
"""Register callbacks to update hass after device was changed."""
|
||||
@asyncio.coroutine
|
||||
def after_update_callback(device):
|
||||
"""Callback after device was updated."""
|
||||
"""Call after device was updated."""
|
||||
# pylint: disable=unused-argument
|
||||
yield from self.async_update_ha_state()
|
||||
self.device.register_device_updated_cb(after_update_callback)
|
||||
|
||||
@@ -4,17 +4,17 @@ Support for LaCrosse sensor components.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.lacrosse/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.sensor import (ENTITY_ID_FORMAT, PLATFORM_SCHEMA)
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
EVENT_HOMEASSISTANT_STOP, CONF_DEVICE, CONF_NAME, CONF_ID,
|
||||
CONF_SENSORS, CONF_TYPE, TEMP_CELSIUS)
|
||||
CONF_DEVICE, CONF_ID, CONF_NAME, CONF_SENSORS, CONF_TYPE,
|
||||
EVENT_HOMEASSISTANT_STOP, TEMP_CELSIUS)
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity, async_generate_entity_id
|
||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -147,7 +147,7 @@ class LaCrosseSensor(Entity):
|
||||
return attributes
|
||||
|
||||
def _callback_lacrosse(self, lacrosse_sensor, user_data):
|
||||
"""Callback function that is called from pylacrosse with new values."""
|
||||
"""Handle a function that is called from pylacrosse with new values."""
|
||||
if self._expire_after is not None and self._expire_after > 0:
|
||||
# Reset old trigger
|
||||
if self._expiration_trigger:
|
||||
|
||||
@@ -4,22 +4,24 @@ Sensor for checking the status of London air.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.london_air/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_LOCATIONS = 'locations'
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=30)
|
||||
|
||||
AUTHORITIES = [
|
||||
'Barking and Dagenham',
|
||||
'Bexley',
|
||||
@@ -48,6 +50,7 @@ AUTHORITIES = [
|
||||
'Tower Hamlets',
|
||||
'Wandsworth',
|
||||
'Westminster']
|
||||
|
||||
URL = ('http://api.erg.kcl.ac.uk/AirQuality/Hourly/'
|
||||
'MonitoringIndex/GroupName=London/Json')
|
||||
|
||||
@@ -58,7 +61,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the Tube sensor."""
|
||||
"""Set up the London Air sensor."""
|
||||
data = APIData()
|
||||
data.update()
|
||||
sensors = []
|
||||
@@ -199,7 +202,7 @@ def parse_site(entry_sites_data):
|
||||
|
||||
|
||||
def parse_api_response(response):
|
||||
"""API can return dict or list of data so need to check."""
|
||||
"""Parse return dict or list of data from API."""
|
||||
data = dict.fromkeys(AUTHORITIES)
|
||||
for authority in AUTHORITIES:
|
||||
for entry in response['HourlyAirQualityIndex']['LocalAuthority']:
|
||||
|
||||
@@ -4,33 +4,35 @@ Sensor for Mopar vehicles.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.mopar/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN, PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD, CONF_PIN,
|
||||
ATTR_ATTRIBUTION, ATTR_COMMAND,
|
||||
LENGTH_KILOMETERS)
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION, ATTR_COMMAND, CONF_PASSWORD, CONF_PIN, CONF_USERNAME,
|
||||
LENGTH_KILOMETERS)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
REQUIREMENTS = ['motorparts==1.0.2']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(days=7)
|
||||
ATTR_VEHICLE_INDEX = 'vehicle_index'
|
||||
SERVICE_REMOTE_COMMAND = 'mopar_remote_command'
|
||||
|
||||
COOKIE_FILE = 'mopar_cookies.pickle'
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(days=7)
|
||||
|
||||
SERVICE_REMOTE_COMMAND = 'mopar_remote_command'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Required(CONF_PIN): cv.positive_int
|
||||
vol.Required(CONF_PIN): cv.positive_int,
|
||||
})
|
||||
|
||||
REMOTE_COMMAND_SCHEMA = vol.Schema({
|
||||
@@ -41,17 +43,16 @@ REMOTE_COMMAND_SCHEMA = vol.Schema({
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Mopar platform."""
|
||||
"""Set up the Mopar platform."""
|
||||
import motorparts
|
||||
cookie = hass.config.path(COOKIE_FILE)
|
||||
try:
|
||||
session = motorparts.get_session(config.get(CONF_USERNAME),
|
||||
config.get(CONF_PASSWORD),
|
||||
config.get(CONF_PIN),
|
||||
cookie_path=cookie)
|
||||
session = motorparts.get_session(
|
||||
config.get(CONF_USERNAME), config.get(CONF_PASSWORD),
|
||||
config.get(CONF_PIN), cookie_path=cookie)
|
||||
except motorparts.MoparError:
|
||||
_LOGGER.error("failed to login")
|
||||
return False
|
||||
_LOGGER.error("Failed to login")
|
||||
return
|
||||
|
||||
def _handle_service(service):
|
||||
"""Handle service call."""
|
||||
@@ -67,12 +68,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
data = MoparData(session)
|
||||
add_devices([MoparSensor(data, index)
|
||||
for index, _ in enumerate(data.vehicles)],
|
||||
True)
|
||||
return True
|
||||
for index, _ in enumerate(data.vehicles)], True)
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class MoparData(object):
|
||||
"""Container for Mopar vehicle data.
|
||||
|
||||
@@ -91,11 +89,11 @@ class MoparData(object):
|
||||
def update(self, **kwargs):
|
||||
"""Update data."""
|
||||
import motorparts
|
||||
_LOGGER.info("updating vehicle data")
|
||||
_LOGGER.info("Updating vehicle data")
|
||||
try:
|
||||
self.vehicles = motorparts.get_summary(self._session)['vehicles']
|
||||
except motorparts.MoparError:
|
||||
_LOGGER.exception("failed to get summary")
|
||||
_LOGGER.exception("Failed to get summary")
|
||||
return
|
||||
for index, _ in enumerate(self.vehicles):
|
||||
try:
|
||||
@@ -103,7 +101,7 @@ class MoparData(object):
|
||||
self.tow_guides[index] = motorparts.get_tow_guide(
|
||||
self._session, index)
|
||||
except motorparts.MoparError:
|
||||
_LOGGER.warning("failed to update for vehicle index %s", index)
|
||||
_LOGGER.warning("Failed to update for vehicle index %s", index)
|
||||
|
||||
|
||||
class MoparSensor(Entity):
|
||||
@@ -132,9 +130,9 @@ class MoparSensor(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return '{} {} {}'.format(self._vehicle['year'],
|
||||
self._vehicle['make'],
|
||||
self._vehicle['model'])
|
||||
return '{} {} {}'.format(
|
||||
self._vehicle['year'], self._vehicle['make'],
|
||||
self._vehicle['model'])
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@@ -4,17 +4,16 @@ Support for Nederlandse Spoorwegen public transport.
|
||||
For more details on this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.nederlandse_spoorwegen/
|
||||
"""
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_EMAIL, CONF_NAME,
|
||||
CONF_PASSWORD, ATTR_ATTRIBUTION)
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION, CONF_EMAIL, CONF_NAME, CONF_PASSWORD)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
@@ -50,7 +49,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the departure sensor."""
|
||||
"""Set up the departure sensor."""
|
||||
import ns_api
|
||||
nsapi = ns_api.NSAPI(
|
||||
config.get(CONF_EMAIL), config.get(CONF_PASSWORD))
|
||||
@@ -77,7 +76,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
def valid_stations(stations, given_stations):
|
||||
"""Verify the existance of the given station codes."""
|
||||
"""Verify the existence of the given station codes."""
|
||||
for station in given_stations:
|
||||
if station is None:
|
||||
continue
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
"""Support for Open Hardware Monitor Sensor Platform."""
|
||||
"""
|
||||
Support for Open Hardware Monitor Sensor Platform.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.openhardwaremonitor/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.util.dt import utcnow
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -37,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Open Hardware Monitor platform."""
|
||||
"""Set up the Open Hardware Monitor platform."""
|
||||
data = OpenHardwareMonitorData(config, hass)
|
||||
add_devices(data.devices, True)
|
||||
|
||||
@@ -124,9 +129,8 @@ class OpenHardwareMonitorData(object):
|
||||
|
||||
def refresh(self):
|
||||
"""Download and parse JSON from OHM."""
|
||||
data_url = "http://%s:%d/data.json" % (
|
||||
self._config.get(CONF_HOST),
|
||||
self._config.get(CONF_PORT))
|
||||
data_url = "http://{}:{}/data.json".format(
|
||||
self._config.get(CONF_HOST), self._config.get(CONF_PORT))
|
||||
|
||||
try:
|
||||
response = requests.get(data_url, timeout=30)
|
||||
@@ -135,7 +139,7 @@ class OpenHardwareMonitorData(object):
|
||||
_LOGGER.error("ConnectionError: Is OpenHardwareMonitor running?")
|
||||
|
||||
def initialize(self, now):
|
||||
"""Initial parsing of the sensors and adding of devices."""
|
||||
"""Parse of the sensors and adding of devices."""
|
||||
self.refresh()
|
||||
|
||||
if self.data is None:
|
||||
@@ -173,11 +177,7 @@ class OpenHardwareMonitorData(object):
|
||||
fullname = ' '.join(child_names)
|
||||
|
||||
dev = OpenHardwareMonitorDevice(
|
||||
self,
|
||||
fullname,
|
||||
path,
|
||||
unit_of_measurement
|
||||
)
|
||||
self, fullname, path, unit_of_measurement)
|
||||
|
||||
result.append(dev)
|
||||
return result
|
||||
@@ -9,14 +9,14 @@ import logging
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.components.rfxtrx as rfxtrx
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.rfxtrx import (
|
||||
ATTR_DATA_TYPE, ATTR_FIRE_EVENT, ATTR_NAME, CONF_AUTOMATIC_ADD,
|
||||
CONF_DATA_TYPE, CONF_DEVICES, CONF_FIRE_EVENT, DATA_TYPES)
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.components.rfxtrx import (
|
||||
ATTR_NAME, ATTR_FIRE_EVENT, ATTR_DATA_TYPE, CONF_AUTOMATIC_ADD,
|
||||
CONF_FIRE_EVENT, CONF_DEVICES, DATA_TYPES, CONF_DATA_TYPE)
|
||||
|
||||
DEPENDENCIES = ['rfxtrx']
|
||||
|
||||
@@ -35,13 +35,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the RFXtrx platform."""
|
||||
from RFXtrx import SensorEvent
|
||||
sensors = []
|
||||
for packet_id, entity_info in config[CONF_DEVICES].items():
|
||||
event = rfxtrx.get_rfx_object(packet_id)
|
||||
device_id = "sensor_" + slugify(event.device.id_string.lower())
|
||||
device_id = "sensor_{}".format(slugify(event.device.id_string.lower()))
|
||||
if device_id in rfxtrx.RFX_DEVICES:
|
||||
continue
|
||||
_LOGGER.info("Add %s rfxtrx.sensor", entity_info[ATTR_NAME])
|
||||
@@ -60,7 +60,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
sensors.append(new_sensor)
|
||||
sub_sensors[_data_type] = new_sensor
|
||||
rfxtrx.RFX_DEVICES[device_id] = sub_sensors
|
||||
add_devices_callback(sensors)
|
||||
add_devices(sensors)
|
||||
|
||||
def sensor_update(event):
|
||||
"""Handle sensor updates from the RFXtrx gateway."""
|
||||
@@ -78,8 +78,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
if sensors[key].should_fire_event:
|
||||
sensor.hass.bus.fire(
|
||||
"signal_received", {
|
||||
ATTR_ENTITY_ID:
|
||||
sensors[key].entity_id,
|
||||
ATTR_ENTITY_ID: sensors[key].entity_id,
|
||||
}
|
||||
)
|
||||
return
|
||||
@@ -100,7 +99,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
sub_sensors = {}
|
||||
sub_sensors[new_sensor.data_type] = new_sensor
|
||||
rfxtrx.RFX_DEVICES[device_id] = sub_sensors
|
||||
add_devices_callback([new_sensor])
|
||||
add_devices([new_sensor])
|
||||
|
||||
if sensor_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
|
||||
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(sensor_update)
|
||||
@@ -135,7 +134,7 @@ class RfxtrxSensor(Entity):
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
"""Return the device state attributes."""
|
||||
if not self.event:
|
||||
return None
|
||||
return self.event.values
|
||||
|
||||
@@ -4,12 +4,13 @@ Sensors for the Tesla sensors.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.tesla/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
||||
from homeassistant.components.tesla import DOMAIN as TESLA_DOMAIN, TeslaDevice
|
||||
from homeassistant.components.tesla import DOMAIN as TESLA_DOMAIN
|
||||
from homeassistant.components.tesla import TeslaDevice
|
||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -37,7 +38,7 @@ class TeslaSensor(TeslaDevice, Entity):
|
||||
"""Representation of Tesla sensors."""
|
||||
|
||||
def __init__(self, tesla_device, controller, sensor_type=None):
|
||||
"""Initialisation of the sensor."""
|
||||
"""Initialize of the sensor."""
|
||||
self.current_value = None
|
||||
self._unit = None
|
||||
self.last_changed_time = None
|
||||
|
||||
@@ -21,13 +21,12 @@ STATUS_DELIVERED = 'delivered'
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the USPS platform."""
|
||||
"""Set up the USPS platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
usps = hass.data[DATA_USPS]
|
||||
add_devices([USPSPackageSensor(usps),
|
||||
USPSMailSensor(usps)], True)
|
||||
add_devices([USPSPackageSensor(usps), USPSMailSensor(usps)], True)
|
||||
|
||||
|
||||
class USPSPackageSensor(Entity):
|
||||
@@ -73,7 +72,7 @@ class USPSPackageSensor(Entity):
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend."""
|
||||
"""Return the icon to use in the frontend."""
|
||||
return 'mdi:package-variant-closed'
|
||||
|
||||
@property
|
||||
|
||||
@@ -4,17 +4,16 @@ Support for information about the Italian train system using ViaggiaTreno API.
|
||||
For more details about this platform please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.viaggiatreno
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import asyncio
|
||||
import async_timeout
|
||||
import aiohttp
|
||||
|
||||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -58,9 +57,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config,
|
||||
async_add_devices, discovery_info=None):
|
||||
"""Setup the ViaggiaTreno platform."""
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the ViaggiaTreno platform."""
|
||||
train_id = config.get(CONF_TRAIN_ID)
|
||||
station_id = config.get(CONF_STATION_ID)
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -100,8 +98,7 @@ class ViaggiaTrenoSensor(Entity):
|
||||
self._name = name
|
||||
|
||||
self.uri = VIAGGIATRENO_ENDPOINT.format(
|
||||
station_id=station_id,
|
||||
train_id=train_id)
|
||||
station_id=station_id, train_id=train_id)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
@@ -5,29 +5,26 @@ For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.vultr/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (
|
||||
CONF_MONITORED_CONDITIONS, CONF_NAME)
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.components.vultr import (
|
||||
CONF_SUBSCRIPTION, ATTR_CURRENT_BANDWIDTH_USED, ATTR_PENDING_CHARGES,
|
||||
ATTR_CURRENT_BANDWIDTH_USED, ATTR_PENDING_CHARGES, CONF_SUBSCRIPTION,
|
||||
DATA_VULTR)
|
||||
|
||||
# Name defaults to {subscription label} {sensor name}
|
||||
DEFAULT_NAME = 'Vultr {} {}'
|
||||
DEPENDENCIES = ['vultr']
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# Monitored conditions: name, units, icon
|
||||
DEFAULT_NAME = 'Vultr {} {}'
|
||||
DEPENDENCIES = ['vultr']
|
||||
|
||||
MONITORED_CONDITIONS = {
|
||||
ATTR_CURRENT_BANDWIDTH_USED: ['Current Bandwidth Used', 'GB',
|
||||
'mdi:chart-histogram'],
|
||||
ATTR_PENDING_CHARGES: ['Pending Charges', 'US$',
|
||||
'mdi:currency-usd']
|
||||
ATTR_PENDING_CHARGES: ['Pending Charges', 'US$', 'mdi:currency-usd'],
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
@@ -48,15 +45,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
if subscription not in vultr.data:
|
||||
_LOGGER.error("Subscription %s not found", subscription)
|
||||
return False
|
||||
return
|
||||
|
||||
sensors = []
|
||||
|
||||
for condition in monitored_conditions:
|
||||
sensors.append(VultrSensor(vultr,
|
||||
subscription,
|
||||
condition,
|
||||
name))
|
||||
sensors.append(VultrSensor(vultr, subscription, condition, name))
|
||||
|
||||
add_devices(sensors, True)
|
||||
|
||||
@@ -84,21 +78,21 @@ class VultrSensor(Entity):
|
||||
"""Return the name of the sensor."""
|
||||
try:
|
||||
return self._name.format(self._condition_name)
|
||||
except IndexError: # name contains more {} than fulfilled
|
||||
except IndexError:
|
||||
try:
|
||||
return self._name.format(self.data['label'],
|
||||
self._condition_name)
|
||||
except (KeyError, TypeError): # label key missing or data is None
|
||||
return self._name.format(
|
||||
self.data['label'], self._condition_name)
|
||||
except (KeyError, TypeError):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon used in the frontend if any."""
|
||||
"""Return the icon used in the frontend if any."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""The unit of measurement to present the value in."""
|
||||
"""Return the unit of measurement to present the value in."""
|
||||
return self._units
|
||||
|
||||
@property
|
||||
|
||||
@@ -4,13 +4,13 @@ Get WHOIS information for a given host.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.whois/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
@@ -22,10 +22,10 @@ CONF_DOMAIN = 'domain'
|
||||
|
||||
DEFAULT_NAME = 'Whois'
|
||||
|
||||
ATTR_EXPIRES = 'expires'
|
||||
ATTR_NAME_SERVERS = 'name_servers'
|
||||
ATTR_REGISTRAR = 'registrar'
|
||||
ATTR_UPDATED = 'updated'
|
||||
ATTR_EXPIRES = 'expires'
|
||||
|
||||
SCAN_INTERVAL = timedelta(hours=24)
|
||||
|
||||
@@ -79,12 +79,12 @@ class WhoisSensor(Entity):
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""The icon to represent this sensor."""
|
||||
"""Return the icon to represent this sensor."""
|
||||
return 'mdi:calendar-clock'
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""The unit of measurement to present the value in."""
|
||||
"""Return the unit of measurement to present the value in."""
|
||||
return 'days'
|
||||
|
||||
@property
|
||||
|
||||
@@ -7,12 +7,13 @@ at https://home-assistant.io/components/sensor.wink/
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.components.wink import DOMAIN, WinkDevice
|
||||
from homeassistant.const import TEMP_CELSIUS
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.wink import WinkDevice, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['wink']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSOR_TYPES = ['temperature', 'humidity', 'balance', 'proximity']
|
||||
|
||||
@@ -61,7 +62,7 @@ class WinkSensorDevice(WinkDevice, Entity):
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Callback when entity is added to hass."""
|
||||
"""Call when entity is added to hass."""
|
||||
self.hass.data[DOMAIN]['entities']['sensor'].append(self)
|
||||
|
||||
@property
|
||||
|
||||
Reference in new issue
Block a user