Merge remote-tracking branch 'upstream/dev' into igd
This commit is contained in:
commit
3db766e2ec
974 files changed
+6103
-3081
No files matched your search
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "Prvn\u00ed \u010dtvr\u0165",
|
||||
"full_moon": "\u00dapln\u011bk",
|
||||
"last_quarter": "Posledn\u00ed \u010dtvr\u0165",
|
||||
"new_moon": "Nov",
|
||||
"waning_crescent": "Couvaj\u00edc\u00ed srpek",
|
||||
"waning_gibbous": "Couvaj\u00edc\u00ed m\u011bs\u00edc",
|
||||
"waxing_crescent": "Dor\u016fstaj\u00edc\u00ed srpek",
|
||||
"waxing_gibbous": "Dor\u016fstaj\u00edc\u00ed m\u011bs\u00edc"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "Primer cuarto",
|
||||
"full_moon": "Luna llena",
|
||||
"new_moon": "Luna nueva"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "\u05e8\u05d1\u05e2\u05d5\u05df \u05e8\u05d0\u05e9\u05d5\u05df",
|
||||
"full_moon": "\u05d9\u05e8\u05d7 \u05de\u05dc\u05d0",
|
||||
"last_quarter": "\u05e8\u05d1\u05e2\u05d5\u05df \u05d0\u05d7\u05e8\u05d5\u05df",
|
||||
"new_moon": "\u05e8\u05d0\u05e9 \u05d7\u05d5\u05d3\u05e9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "Primo quarto",
|
||||
"full_moon": "Luna piena",
|
||||
"last_quarter": "Ultimo quarto",
|
||||
"new_moon": "Nuova luna"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "\u00c9ischt V\u00e9ierel",
|
||||
"full_moon": "Vollmound",
|
||||
"last_quarter": "L\u00e4scht V\u00e9ierel",
|
||||
"new_moon": "Neimound",
|
||||
"waning_crescent": "Ofhuelende Mound",
|
||||
"waning_gibbous": "Dr\u00ebtt V\u00e9ierel",
|
||||
"waxing_crescent": "Zouhuelende Mound",
|
||||
"waxing_gibbous": "Zweet V\u00e9ierel"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "pierwsza kwadra",
|
||||
"full_moon": "pe\u0142nia",
|
||||
"last_quarter": "ostatnia kwadra",
|
||||
"new_moon": "n\u00f3w",
|
||||
"waning_crescent": "sierp ubywaj\u0105cy",
|
||||
"waning_gibbous": "ubywaj\u0105cy garbaty",
|
||||
"waxing_crescent": "sierp przybywaj\u0105cy",
|
||||
"waxing_gibbous": "przybywaj\u0105cy garbaty"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "Quarto crescente",
|
||||
"full_moon": "Cheia",
|
||||
"last_quarter": "Quarto minguante",
|
||||
"new_moon": "Nova",
|
||||
"waning_crescent": "Minguante",
|
||||
"waning_gibbous": "Minguante gibosa",
|
||||
"waxing_crescent": "Crescente",
|
||||
"waxing_gibbous": "Crescente gibosa"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"state": {
|
||||
"first_quarter": "F\u00f6rsta kvartalet",
|
||||
"full_moon": "Fullm\u00e5ne",
|
||||
"last_quarter": "Sista kvartalet",
|
||||
"new_moon": "Nym\u00e5ne",
|
||||
"waning_crescent": "Avtagande halvm\u00e5ne",
|
||||
"waning_gibbous": "Avtagande halvm\u00e5ne",
|
||||
"waxing_crescent": "Tilltagande halvm\u00e5ne",
|
||||
"waxing_gibbous": "Tilltagande halvm\u00e5ne"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"state": {
|
||||
"autumn": "\u05e1\u05ea\u05d9\u05d5",
|
||||
"spring": "\u05d0\u05d1\u05d9\u05d1",
|
||||
"summer": "\u05e7\u05d9\u05e5",
|
||||
"winter": "\u05d7\u05d5\u05e8\u05e3"
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ SENSOR_TYPES = {
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up a sensor for an Abode device."""
|
||||
import abodepy.helpers.constants as CONST
|
||||
|
||||
@@ -38,7 +38,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
data.devices.extend(devices)
|
||||
|
||||
add_devices(devices)
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
class AbodeSensor(AbodeDevice):
|
||||
|
||||
@@ -32,7 +32,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up an ADS sensor device."""
|
||||
ads_hub = hass.data.get(ads.DATA_ADS)
|
||||
|
||||
@@ -45,7 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
entity = AdsSensor(
|
||||
ads_hub, ads_var, ads_type, name, unit_of_measurement, factor)
|
||||
|
||||
add_devices([entity])
|
||||
add_entities([entity])
|
||||
|
||||
|
||||
class AdsSensor(Entity):
|
||||
|
||||
@@ -117,7 +117,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
"""Configure the platform and add the sensors."""
|
||||
from pyairvisual import Client
|
||||
|
||||
@@ -161,7 +161,7 @@ async def async_setup_platform(
|
||||
AirVisualSensor(
|
||||
data, kind, name, icon, unit, locale, location_id))
|
||||
|
||||
async_add_devices(sensors, True)
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
|
||||
class AirVisualSensor(Entity):
|
||||
|
||||
@@ -15,13 +15,13 @@ _LOGGER = logging.getLogger(__name__)
|
||||
DEPENDENCIES = ['alarmdecoder']
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up for AlarmDecoder sensor devices."""
|
||||
_LOGGER.debug("AlarmDecoderSensor: setup_platform")
|
||||
|
||||
device = AlarmDecoderSensor(hass)
|
||||
|
||||
add_devices([device])
|
||||
add_entities([device])
|
||||
|
||||
|
||||
class AlarmDecoderSensor(Entity):
|
||||
|
||||
@@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['alpha_vantage==2.0.0']
|
||||
REQUIREMENTS = ['alpha_vantage==2.1.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -63,7 +63,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Alpha Vantage sensor."""
|
||||
from alpha_vantage.timeseries import TimeSeries
|
||||
from alpha_vantage.foreignexchange import ForeignExchange
|
||||
@@ -107,7 +107,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.debug(str(error))
|
||||
dev.append(AlphaVantageForeignExchange(forex, conversion))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
_LOGGER.debug("Setup completed")
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ SCAN_INTERVAL = timedelta(seconds=10)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up a sensor for an Amcrest IP Camera."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -34,7 +35,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
amcrest_sensors.append(
|
||||
AmcrestSensor(amcrest.name, amcrest.device, sensor_type))
|
||||
|
||||
async_add_devices(amcrest_sensors, True)
|
||||
async_add_entities(amcrest_sensors, True)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ DEPENDENCIES = ['android_ip_webcam']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the IP Webcam Sensor."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -30,7 +31,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
for sensor in sensors:
|
||||
all_sensors.append(IPWebcamSensor(name, host, ipcam, sensor))
|
||||
|
||||
async_add_devices(all_sensors, True)
|
||||
async_add_entities(all_sensors, True)
|
||||
|
||||
|
||||
class IPWebcamSensor(AndroidIPCamEntity):
|
||||
|
||||
@@ -49,7 +49,8 @@ class StreamHandler(logging.Handler):
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the API stream platform."""
|
||||
entity = APICount()
|
||||
handler = StreamHandler(entity)
|
||||
@@ -65,7 +66,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, remove_logger)
|
||||
|
||||
async_add_devices([entity])
|
||||
async_add_entities([entity])
|
||||
|
||||
|
||||
class APICount(Entity):
|
||||
|
||||
@@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Arduino platform."""
|
||||
if arduino.BOARD is None:
|
||||
_LOGGER.error("A connection has not been made to the Arduino board")
|
||||
@@ -44,7 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors = []
|
||||
for pinnum, pin in pins.items():
|
||||
sensors.append(ArduinoSensor(pin.get(CONF_NAME), pinnum, CONF_TYPE))
|
||||
add_devices(sensors)
|
||||
add_entities(sensors)
|
||||
|
||||
|
||||
class ArduinoSensor(Entity):
|
||||
|
||||
@@ -44,7 +44,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the aREST sensor."""
|
||||
resource = config.get(CONF_RESOURCE)
|
||||
var_conf = config.get(CONF_MONITORED_VARIABLES)
|
||||
@@ -102,7 +102,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
pin=pinnum, unit_of_measurement=pin.get(
|
||||
CONF_UNIT_OF_MEASUREMENT), renderer=renderer))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class ArestSensor(Entity):
|
||||
|
||||
@@ -43,7 +43,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up an Arlo IP sensor."""
|
||||
arlo = hass.data.get(DATA_ARLO)
|
||||
if not arlo:
|
||||
@@ -70,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
SENSOR_TYPES[sensor_type][0], base_station.name)
|
||||
sensors.append(ArloSensor(name, base_station, sensor_type))
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class ArloSensor(Entity):
|
||||
|
||||
@@ -59,7 +59,8 @@ def _slug(name):
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the ARWN platform."""
|
||||
@callback
|
||||
def async_sensor_event_received(topic, payload, qos):
|
||||
@@ -97,7 +98,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
store[sensor.name] = sensor
|
||||
_LOGGER.debug("Registering new sensor %(name)s => %(event)s",
|
||||
dict(name=sensor.name, event=event))
|
||||
async_add_devices((sensor,), True)
|
||||
async_add_entities((sensor,), True)
|
||||
else:
|
||||
store[sensor.name].set_event(event)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Bbox sensor."""
|
||||
# Create a data fetcher to support all of the configured sensors. Then make
|
||||
# the first call to init the data.
|
||||
@@ -65,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for variable in config[CONF_MONITORED_VARIABLES]:
|
||||
sensors.append(BboxSensor(bbox_data, variable, name))
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class BboxSensor(Entity):
|
||||
|
||||
@@ -67,7 +67,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
# pylint: disable=import-error
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the BH1750 sensor."""
|
||||
import smbus
|
||||
from i2csense.bh1750 import BH1750
|
||||
@@ -95,7 +96,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
_LOGGER.info("Setup of BH1750 light sensor at %s in mode %s is complete",
|
||||
i2c_address, operation_mode)
|
||||
|
||||
async_add_devices(dev, True)
|
||||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class BH1750Sensor(Entity):
|
||||
|
||||
@@ -58,7 +58,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Bitcoin sensors."""
|
||||
from blockchain import exchangerates
|
||||
|
||||
@@ -73,7 +73,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for variable in config[CONF_DISPLAY_OPTIONS]:
|
||||
dev.append(BitcoinSensor(data, variable, currency))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class BitcoinSensor(Entity):
|
||||
|
||||
@@ -21,7 +21,7 @@ SENSOR_TYPES = {
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up a Blink sensor."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
devs.append(BlinkSensor(name, 'notifications', index, data))
|
||||
index += 1
|
||||
|
||||
add_devices(devs, True)
|
||||
add_entities(devs, True)
|
||||
|
||||
|
||||
class BlinkSensor(Entity):
|
||||
|
||||
@@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Blockchain.info sensors."""
|
||||
from pyblockchain import validate_address
|
||||
|
||||
@@ -45,7 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Bitcoin address is not valid: %s", address)
|
||||
return False
|
||||
|
||||
add_devices([BlockchainSensor(name, addresses)], True)
|
||||
add_entities([BlockchainSensor(name, addresses)], True)
|
||||
|
||||
|
||||
class BlockchainSensor(Entity):
|
||||
|
||||
@@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the available BloomSky weather sensors."""
|
||||
bloomsky = hass.components.bloomsky
|
||||
# Default needed in case of discovery
|
||||
@@ -49,7 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
for device in bloomsky.BLOOMSKY.devices.values():
|
||||
for variable in sensors:
|
||||
add_devices(
|
||||
add_entities(
|
||||
[BloomSkySensor(bloomsky.BLOOMSKY, device, variable)], True)
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
# pylint: disable=import-error
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the BME280 sensor."""
|
||||
import smbus
|
||||
from i2csense.bme280 import BME280
|
||||
@@ -117,7 +118,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
async_add_devices(dev, True)
|
||||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class BME280Handler:
|
||||
|
||||
@@ -98,7 +98,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the BME680 sensor."""
|
||||
SENSOR_TYPES[SENSOR_TEMP][1] = hass.config.units.temperature_unit
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -112,7 +113,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
dev.append(BME680Sensor(
|
||||
sensor_handler, variable, SENSOR_TYPES[variable][1], name))
|
||||
|
||||
async_add_devices(dev)
|
||||
async_add_entities(dev)
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ ATTR_TO_HA = {
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the BMW sensors."""
|
||||
accounts = hass.data[BMW_DOMAIN]
|
||||
_LOGGER.debug('Found BMW accounts: %s',
|
||||
@@ -41,7 +41,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
devices.append(device)
|
||||
device = BMWConnectedDriveSensor(account, vehicle, 'mileage')
|
||||
devices.append(device)
|
||||
add_devices(devices, True)
|
||||
add_entities(devices, True)
|
||||
|
||||
|
||||
class BMWConnectedDriveSensor(Entity):
|
||||
|
||||
@@ -99,7 +99,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the BOM sensor."""
|
||||
station = config.get(CONF_STATION)
|
||||
zone_id, wmo_id = config.get(CONF_ZONE_ID), config.get(CONF_WMO_ID)
|
||||
@@ -127,8 +127,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Received error from BOM Current: %s", err)
|
||||
return
|
||||
|
||||
add_devices([BOMCurrentSensor(bom_data, variable, config.get(CONF_NAME))
|
||||
for variable in config[CONF_MONITORED_CONDITIONS]])
|
||||
add_entities([BOMCurrentSensor(bom_data, variable, config.get(CONF_NAME))
|
||||
for variable in config[CONF_MONITORED_CONDITIONS]])
|
||||
|
||||
|
||||
class BOMCurrentSensor(Entity):
|
||||
|
||||
@@ -47,7 +47,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Broadlink device sensors."""
|
||||
host = config.get(CONF_HOST)
|
||||
mac = config.get(CONF_MAC).encode().replace(b':', b'')
|
||||
@@ -59,7 +59,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
dev = []
|
||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||
dev.append(BroadlinkSensor(name, broadlink_data, variable))
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class BroadlinkSensor(Entity):
|
||||
|
||||
@@ -141,7 +141,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Create the buienradar sensor."""
|
||||
from homeassistant.components.weather.buienradar import DEFAULT_TIMEFRAME
|
||||
|
||||
@@ -163,7 +164,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
for sensor_type in config[CONF_MONITORED_CONDITIONS]:
|
||||
dev.append(BrSensor(sensor_type, config.get(CONF_NAME, 'br'),
|
||||
coordinates))
|
||||
async_add_devices(dev)
|
||||
async_add_entities(dev)
|
||||
|
||||
data = BrData(hass, coordinates, timeframe, dev)
|
||||
# schedule the first update in 1 minute from now:
|
||||
|
||||
@@ -30,7 +30,7 @@ STATE_AIR_QUALITY_ABNORMAL = "abnormal"
|
||||
STATE_AIR_QUALITY_VERY_ABNORMAL = "very_abnormal"
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Canary sensors."""
|
||||
data = hass.data[DATA_CANARY]
|
||||
devices = []
|
||||
@@ -44,7 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
devices.append(CanarySensor(data, sensor_type,
|
||||
location, device))
|
||||
|
||||
add_devices(devices, True)
|
||||
add_entities(devices, True)
|
||||
|
||||
|
||||
class CanarySensor(Entity):
|
||||
|
||||
@@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up certificate expiry sensor."""
|
||||
def run_setup(event):
|
||||
"""Wait until Home Assistant is fully initialized before creating.
|
||||
@@ -44,8 +44,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
server_port = config.get(CONF_PORT)
|
||||
sensor_name = config.get(CONF_NAME)
|
||||
|
||||
add_devices([SSLCertificate(sensor_name, server_name, server_port)],
|
||||
True)
|
||||
add_entities([SSLCertificate(sensor_name, server_name, server_port)],
|
||||
True)
|
||||
|
||||
# To allow checking of the HA certificate we must first be running.
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, run_setup)
|
||||
|
||||
@@ -126,7 +126,7 @@ def async_citybikes_request(hass, uri, schema):
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices,
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the CityBikes platform."""
|
||||
if PLATFORM not in hass.data:
|
||||
@@ -167,7 +167,7 @@ def async_setup_platform(hass, config, async_add_devices,
|
||||
(station_id, station_uid)):
|
||||
devices.append(CityBikesStation(hass, network, station_id, name))
|
||||
|
||||
async_add_devices(devices, True)
|
||||
async_add_entities(devices, True)
|
||||
|
||||
|
||||
class CityBikesNetwork:
|
||||
|
||||
@@ -21,7 +21,7 @@ DEPENDENCIES = ['coinbase']
|
||||
ETH_ICON = 'mdi:currency-eth'
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Coinbase sensors."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
hass.data[DATA_COINBASE], discovery_info['exchange_currency'],
|
||||
discovery_info['native_currency'])
|
||||
|
||||
add_devices([sensor], True)
|
||||
add_entities([sensor], True)
|
||||
|
||||
|
||||
class AccountSensor(Entity):
|
||||
|
||||
@@ -56,7 +56,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the CoinMarketCap sensor."""
|
||||
currency_id = config.get(CONF_CURRENCY_ID)
|
||||
display_currency = config.get(CONF_DISPLAY_CURRENCY).upper()
|
||||
@@ -71,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
currency_id = DEFAULT_CURRENCY_ID
|
||||
display_currency = DEFAULT_DISPLAY_CURRENCY
|
||||
|
||||
add_devices([CoinMarketCapSensor(
|
||||
add_entities([CoinMarketCapSensor(
|
||||
CoinMarketCapData(
|
||||
currency_id, display_currency), display_currency_decimals)], True)
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the ComEd Hourly Pricing sensor."""
|
||||
websession = async_get_clientsession(hass)
|
||||
dev = []
|
||||
@@ -60,7 +61,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
hass.loop, websession, variable[CONF_SENSOR_TYPE],
|
||||
variable[CONF_OFFSET], variable.get(CONF_NAME)))
|
||||
|
||||
async_add_devices(dev, True)
|
||||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class ComedHourlyPricingSensor(Entity):
|
||||
|
||||
@@ -23,7 +23,7 @@ DEPENDENCIES = ['comfoconnect']
|
||||
SENSOR_TYPES = {}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the ComfoConnect fan platform."""
|
||||
from pycomfoconnect import (
|
||||
SENSOR_TEMPERATURE_EXTRACT, SENSOR_HUMIDITY_EXTRACT,
|
||||
@@ -90,7 +90,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
)
|
||||
)
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class ComfoConnectSensor(Entity):
|
||||
|
||||
@@ -43,7 +43,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Command Sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
command = config.get(CONF_COMMAND)
|
||||
@@ -55,7 +55,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
json_attributes = config.get(CONF_JSON_ATTRIBUTES)
|
||||
data = CommandSensorData(hass, command, command_timeout)
|
||||
|
||||
add_devices([CommandSensor(
|
||||
add_entities([CommandSensor(
|
||||
hass, data, name, unit, value_template, json_attributes)], True)
|
||||
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the CPU speed sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
|
||||
add_devices([CpuSpeedSensor(name)], True)
|
||||
add_entities([CpuSpeedSensor(name)], True)
|
||||
|
||||
|
||||
class CpuSpeedSensor(Entity):
|
||||
|
||||
@@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Crime Reports platform."""
|
||||
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
|
||||
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
|
||||
@@ -50,7 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
include = config.get(CONF_INCLUDE)
|
||||
exclude = config.get(CONF_EXCLUDE)
|
||||
|
||||
add_devices([CrimeReportsSensor(
|
||||
add_entities([CrimeReportsSensor(
|
||||
hass, name, latitude, longitude, radius, include, exclude)], True)
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the CUPS sensor."""
|
||||
host = config.get(CONF_HOST)
|
||||
port = config.get(CONF_PORT)
|
||||
@@ -71,7 +71,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Printer is not present: %s", printer)
|
||||
continue
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class CupsSensor(Entity):
|
||||
|
||||
@@ -36,7 +36,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Currencylayer sensor."""
|
||||
base = config.get(CONF_BASE)
|
||||
api_key = config.get(CONF_API_KEY)
|
||||
@@ -54,7 +54,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors.append(CurrencylayerSensor(rest, base, variable))
|
||||
if 'error' in response.json():
|
||||
return False
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class CurrencylayerSensor(Entity):
|
||||
|
||||
@@ -31,7 +31,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Daikin sensors."""
|
||||
if discovery_info is not None:
|
||||
host = discovery_info.get('ip')
|
||||
@@ -51,7 +51,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for monitored_state in monitored_conditions:
|
||||
sensors.append(DaikinClimateSensor(api, monitored_state, units, name))
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class DaikinClimateSensor(Entity):
|
||||
|
||||
@@ -33,10 +33,12 @@ DEFAULT_LANGUAGE = 'en'
|
||||
|
||||
DEFAULT_NAME = 'Dark Sky'
|
||||
|
||||
DEPRECATED_SENSOR_TYPES = {'apparent_temperature_max',
|
||||
'apparent_temperature_min',
|
||||
'temperature_max',
|
||||
'temperature_min'}
|
||||
DEPRECATED_SENSOR_TYPES = {
|
||||
'apparent_temperature_max',
|
||||
'apparent_temperature_min',
|
||||
'temperature_max',
|
||||
'temperature_min',
|
||||
}
|
||||
|
||||
# Sensor types are defined like so:
|
||||
# Name, si unit, us unit, ca unit, uk unit, uk2 unit
|
||||
@@ -125,6 +127,8 @@ SENSOR_TYPES = {
|
||||
UNIT_UV_INDEX, UNIT_UV_INDEX, UNIT_UV_INDEX,
|
||||
UNIT_UV_INDEX, UNIT_UV_INDEX, 'mdi:weather-sunny',
|
||||
['currently', 'hourly', 'daily']],
|
||||
'moon_phase': ['Moon Phase', None, None, None, None, None,
|
||||
'mdi:weather-night', ['daily']],
|
||||
}
|
||||
|
||||
CONDITION_PICTURES = {
|
||||
@@ -170,7 +174,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Dark Sky sensor."""
|
||||
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
|
||||
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
|
||||
@@ -203,7 +207,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors = []
|
||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||
if variable in DEPRECATED_SENSOR_TYPES:
|
||||
_LOGGER.warning("Monitored condition %s is deprecated.",
|
||||
_LOGGER.warning("Monitored condition %s is deprecated",
|
||||
variable)
|
||||
sensors.append(DarkSkySensor(forecast_data, variable, name))
|
||||
if forecast is not None and 'daily' in SENSOR_TYPES[variable][7]:
|
||||
@@ -211,7 +215,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors.append(DarkSkySensor(
|
||||
forecast_data, variable, name, forecast_day))
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class DarkSkySensor(Entity):
|
||||
@@ -316,7 +320,8 @@ class DarkSkySensor(Entity):
|
||||
'apparent_temperature_max',
|
||||
'apparent_temperature_high',
|
||||
'precip_intensity_max',
|
||||
'precip_accumulation']):
|
||||
'precip_accumulation',
|
||||
'moon_phase']):
|
||||
self.forecast_data.update_daily()
|
||||
daily = self.forecast_data.data_daily
|
||||
if self.type == 'daily_summary':
|
||||
@@ -407,7 +412,7 @@ class DarkSkyData:
|
||||
self._api_key, self.latitude, self.longitude, units=self.units,
|
||||
lang=self.language)
|
||||
except (ConnectError, HTTPError, Timeout, ValueError) as error:
|
||||
_LOGGER.error("Unable to connect to Dark Sky. %s", error)
|
||||
_LOGGER.error("Unable to connect to Dark Sky: %s", error)
|
||||
self.data = None
|
||||
self.unit_system = self.data and self.data.json['flags']['units']
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ https://home-assistant.io/components/sensor.deconz/
|
||||
"""
|
||||
from homeassistant.components.deconz.const import (
|
||||
ATTR_DARK, ATTR_ON, CONF_ALLOW_CLIP_SENSOR, DOMAIN as DATA_DECONZ,
|
||||
DATA_DECONZ_ID, DATA_DECONZ_UNSUB)
|
||||
DATA_DECONZ_ID, DATA_DECONZ_UNSUB, DECONZ_DOMAIN)
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL, ATTR_VOLTAGE, DEVICE_CLASS_BATTERY)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import slugify
|
||||
@@ -21,13 +22,13 @@ ATTR_DAYLIGHT = 'daylight'
|
||||
ATTR_EVENT_ID = 'event_id'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Old way of setting up deCONZ sensors."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the deCONZ sensors."""
|
||||
@callback
|
||||
def async_add_sensor(sensors):
|
||||
@@ -43,7 +44,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
entities.append(DeconzBattery(sensor))
|
||||
else:
|
||||
entities.append(DeconzSensor(sensor))
|
||||
async_add_devices(entities, True)
|
||||
async_add_entities(entities, True)
|
||||
|
||||
hass.data[DATA_DECONZ_UNSUB].append(
|
||||
async_dispatcher_connect(hass, 'deconz_new_sensor', async_add_sensor))
|
||||
@@ -134,6 +135,22 @@ class DeconzSensor(Entity):
|
||||
attr[ATTR_DAYLIGHT] = self._sensor.daylight
|
||||
return attr
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return a device description for device registry."""
|
||||
if (self._sensor.uniqueid is None or
|
||||
self._sensor.uniqueid.count(':') != 7):
|
||||
return None
|
||||
serial = self._sensor.uniqueid.split('-', 1)[0]
|
||||
return {
|
||||
'connections': {(CONNECTION_ZIGBEE, serial)},
|
||||
'identifiers': {(DECONZ_DOMAIN, serial)},
|
||||
'manufacturer': self._sensor.manufacturer,
|
||||
'model': self._sensor.modelid,
|
||||
'name': self._sensor.name,
|
||||
'sw_version': self._sensor.swversion,
|
||||
}
|
||||
|
||||
|
||||
class DeconzBattery(Entity):
|
||||
"""Battery class for when a device is only represented as an event."""
|
||||
@@ -192,3 +209,19 @@ class DeconzBattery(Entity):
|
||||
ATTR_EVENT_ID: slugify(self._device.name),
|
||||
}
|
||||
return attr
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return a device description for device registry."""
|
||||
if (self._device.uniqueid is None or
|
||||
self._device.uniqueid.count(':') != 7):
|
||||
return None
|
||||
serial = self._device.uniqueid.split('-', 1)[0]
|
||||
return {
|
||||
'connections': {(CONNECTION_ZIGBEE, serial)},
|
||||
'identifiers': {(DECONZ_DOMAIN, serial)},
|
||||
'manufacturer': self._device.manufacturer,
|
||||
'model': self._device.modelid,
|
||||
'name': self._device.name,
|
||||
'sw_version': self._device.swversion,
|
||||
}
|
||||
@@ -42,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Deluge sensors."""
|
||||
from deluge_client import DelugeRPCClient
|
||||
|
||||
@@ -62,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for variable in config[CONF_MONITORED_VARIABLES]:
|
||||
dev.append(DelugeSensor(variable, deluge_api, name))
|
||||
|
||||
add_devices(dev)
|
||||
add_entities(dev)
|
||||
|
||||
|
||||
class DelugeSensor(Entity):
|
||||
|
||||
@@ -10,9 +10,9 @@ from homeassistant.const import (
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Demo sensors."""
|
||||
add_devices([
|
||||
add_entities([
|
||||
DemoSensor('Outside Temperature', 15.6, DEVICE_CLASS_TEMPERATURE,
|
||||
TEMP_CELSIUS, 12),
|
||||
DemoSensor('Outside Humidity', 54, DEVICE_CLASS_HUMIDITY, '%', None),
|
||||
|
||||
@@ -34,13 +34,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Deutsche Bahn Sensor."""
|
||||
start = config.get(CONF_START)
|
||||
destination = config.get(CONF_DESTINATION)
|
||||
only_direct = config.get(CONF_ONLY_DIRECT)
|
||||
|
||||
add_devices([DeutscheBahnSensor(start, destination, only_direct)], True)
|
||||
add_entities([DeutscheBahnSensor(start, destination, only_direct)], True)
|
||||
|
||||
|
||||
class DeutscheBahnSensor(Entity):
|
||||
|
||||
@@ -51,7 +51,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the DHT sensor."""
|
||||
# pylint: disable=import-error
|
||||
import Adafruit_DHT
|
||||
@@ -83,7 +83,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class DHTSensor(Entity):
|
||||
|
||||
@@ -37,7 +37,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the Discogs sensor."""
|
||||
import discogs_client
|
||||
|
||||
@@ -51,7 +52,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
_LOGGER.error("API token is not valid")
|
||||
return
|
||||
|
||||
async_add_devices([DiscogsSensor(identity, name)], True)
|
||||
async_add_entities([DiscogsSensor(identity, name)], True)
|
||||
|
||||
|
||||
class DiscogsSensor(Entity):
|
||||
|
||||
@@ -19,11 +19,13 @@ REQUIREMENTS = ['aiodns==1.1.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_NAME = 'name'
|
||||
CONF_HOSTNAME = 'hostname'
|
||||
CONF_RESOLVER = 'resolver'
|
||||
CONF_RESOLVER_IPV6 = 'resolver_ipv6'
|
||||
CONF_IPV6 = 'ipv6'
|
||||
|
||||
DEFAULT_NAME = 'myip'
|
||||
DEFAULT_HOSTNAME = 'myip.opendns.com'
|
||||
DEFAULT_RESOLVER = '208.67.222.222'
|
||||
DEFAULT_RESOLVER_IPV6 = '2620:0:ccc::2'
|
||||
@@ -32,6 +34,7 @@ DEFAULT_IPV6 = False
|
||||
SCAN_INTERVAL = timedelta(seconds=120)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Optional(CONF_HOSTNAME, default=DEFAULT_HOSTNAME): cv.string,
|
||||
vol.Optional(CONF_RESOLVER, default=DEFAULT_RESOLVER): cv.string,
|
||||
vol.Optional(CONF_RESOLVER_IPV6, default=DEFAULT_RESOLVER_IPV6): cv.string,
|
||||
@@ -43,6 +46,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the DNS IP sensor."""
|
||||
hostname = config.get(CONF_HOSTNAME)
|
||||
name = config.get(CONF_NAME)
|
||||
if not name:
|
||||
if hostname == DEFAULT_HOSTNAME:
|
||||
name = DEFAULT_NAME
|
||||
else:
|
||||
name = hostname
|
||||
ipv6 = config.get(CONF_IPV6)
|
||||
if ipv6:
|
||||
resolver = config.get(CONF_RESOLVER_IPV6)
|
||||
@@ -50,17 +59,18 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
resolver = config.get(CONF_RESOLVER)
|
||||
|
||||
async_add_devices([WanIpSensor(
|
||||
hass, hostname, resolver, ipv6)], True)
|
||||
hass, name, hostname, resolver, ipv6)], True)
|
||||
|
||||
|
||||
class WanIpSensor(Entity):
|
||||
"""Implementation of a DNS IP sensor."""
|
||||
|
||||
def __init__(self, hass, hostname, resolver, ipv6):
|
||||
def __init__(self, hass, name, hostname, resolver, ipv6):
|
||||
"""Initialize the sensor."""
|
||||
import aiodns
|
||||
self.hass = hass
|
||||
self._name = hostname
|
||||
self._name = name
|
||||
self.hostname = hostname
|
||||
self.resolver = aiodns.DNSResolver(loop=self.hass.loop)
|
||||
self.resolver.nameservers = [resolver]
|
||||
self.querytype = 'AAAA' if ipv6 else 'A'
|
||||
@@ -79,7 +89,8 @@ class WanIpSensor(Entity):
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
"""Get the current DNS IP address for hostname."""
|
||||
response = yield from self.resolver.query(self._name, self.querytype)
|
||||
response = yield from self.resolver.query(self.hostname,
|
||||
self.querytype)
|
||||
if response:
|
||||
self._state = response[0].host
|
||||
else:
|
||||
|
||||
@@ -54,9 +54,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Dovado platform for sensors."""
|
||||
return Dovado().setup(hass, config, add_devices)
|
||||
return Dovado().setup(hass, config, add_entities)
|
||||
|
||||
|
||||
class Dovado:
|
||||
@@ -67,7 +67,7 @@ class Dovado:
|
||||
self.state = {}
|
||||
self._dovado = None
|
||||
|
||||
def setup(self, hass, config, add_devices):
|
||||
def setup(self, hass, config, add_entities):
|
||||
"""Set up the connection."""
|
||||
import dovado
|
||||
self._dovado = dovado.Dovado(
|
||||
@@ -90,7 +90,7 @@ class Dovado:
|
||||
|
||||
for sensor in SENSORS:
|
||||
if sensor in config.get(CONF_SENSORS, [sensor]):
|
||||
add_devices([DovadoSensor(self, sensor)])
|
||||
add_entities([DovadoSensor(self, sensor)])
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the DSMR sensor."""
|
||||
# Suppress logging
|
||||
logging.getLogger('dsmr_parser').setLevel(logging.ERROR)
|
||||
@@ -160,7 +161,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
DerivativeDSMREntity('Hourly Gas Consumption', gas_obis),
|
||||
]
|
||||
|
||||
async_add_devices(devices)
|
||||
async_add_entities(devices)
|
||||
|
||||
def update_entities_telegram(telegram):
|
||||
"""Update entities with latest telegram and trigger state update."""
|
||||
|
||||
@@ -31,13 +31,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the DTE energy bridge sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
ip_address = config.get(CONF_IP_ADDRESS)
|
||||
version = config.get(CONF_VERSION, 1)
|
||||
|
||||
add_devices([DteEnergyBridgeSensor(ip_address, name, version)], True)
|
||||
add_entities([DteEnergyBridgeSensor(ip_address, name, version)], True)
|
||||
|
||||
|
||||
class DteEnergyBridgeSensor(Entity):
|
||||
|
||||
@@ -56,14 +56,14 @@ def due_in_minutes(timestamp):
|
||||
return str(int(diff.total_seconds() / 60))
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Dublin public transport sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
stop = config.get(CONF_STOP_ID)
|
||||
route = config.get(CONF_ROUTE)
|
||||
|
||||
data = PublicTransportData(stop, route)
|
||||
add_devices([DublinPublicTransportSensor(data, stop, route, name)], True)
|
||||
add_entities([DublinPublicTransportSensor(data, stop, route, name)], True)
|
||||
|
||||
|
||||
class DublinPublicTransportSensor(Entity):
|
||||
|
||||
@@ -27,7 +27,7 @@ LAST_BILL_AVERAGE_USAGE = "last_bills_average_usage"
|
||||
LAST_BILL_DAYS_BILLED = "last_bills_days_billed"
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up all Duke Energy meters."""
|
||||
from pydukeenergy.api import DukeEnergy, DukeEnergyException
|
||||
|
||||
@@ -39,7 +39,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Failed to set up Duke Energy")
|
||||
return
|
||||
|
||||
add_devices([DukeEnergyMeter(meter) for meter in duke.get_meters()])
|
||||
add_entities([DukeEnergyMeter(meter) for meter in duke.get_meters()])
|
||||
|
||||
|
||||
class DukeEnergyMeter(Entity):
|
||||
|
||||
@@ -53,7 +53,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the DWD-Weather-Warnings sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
region_name = config.get(CONF_REGION_NAME)
|
||||
@@ -63,7 +63,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors = [DwdWeatherWarningsSensor(api, name, condition)
|
||||
for condition in config[CONF_MONITORED_CONDITIONS]]
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class DwdWeatherWarningsSensor(Entity):
|
||||
|
||||
@@ -34,7 +34,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Dweet sensor."""
|
||||
import dweepy
|
||||
|
||||
@@ -57,7 +57,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
dweet = DweetData(device)
|
||||
|
||||
add_devices([DweetSensor(hass, dweet, name, value_template, unit)], True)
|
||||
add_entities([DweetSensor(hass, dweet, name, value_template, unit)], True)
|
||||
|
||||
|
||||
class DweetSensor(Entity):
|
||||
|
||||
@@ -23,7 +23,7 @@ SENSOR_UNITS = {
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Dyson Sensors."""
|
||||
_LOGGER.debug("Creating new Dyson fans")
|
||||
devices = []
|
||||
@@ -37,7 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
devices.append(DysonHumiditySensor(hass, device))
|
||||
devices.append(DysonTemperatureSensor(hass, device, unit))
|
||||
devices.append(DysonAirQualitySensor(hass, device))
|
||||
add_devices(devices)
|
||||
add_entities(devices)
|
||||
|
||||
|
||||
class DysonSensor(Entity):
|
||||
|
||||
@@ -64,7 +64,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the EBox sensor."""
|
||||
username = config.get(CONF_USERNAME)
|
||||
@@ -86,7 +86,7 @@ async def async_setup_platform(hass, config, async_add_devices,
|
||||
for variable in config[CONF_MONITORED_VARIABLES]:
|
||||
sensors.append(EBoxSensor(ebox_data, variable, name))
|
||||
|
||||
async_add_devices(sensors, True)
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
|
||||
class EBoxSensor(Entity):
|
||||
|
||||
@@ -19,7 +19,7 @@ SENSOR_TYPES = {
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Ecobee sensors."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
@@ -33,7 +33,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
dev.append(EcobeeSensor(sensor['name'], item['type'], index))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class EcobeeSensor(Entity):
|
||||
|
||||
@@ -39,7 +39,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Validate configuration, create devices and start monitoring thread."""
|
||||
bt_device_id = config.get("bt_device_id")
|
||||
|
||||
@@ -70,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.info("Starting scanner for Eddystone beacons")
|
||||
mon.start()
|
||||
|
||||
add_devices(devices)
|
||||
add_entities(devices)
|
||||
mon.start()
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, monitor_stop)
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, monitor_start)
|
||||
|
||||
@@ -56,7 +56,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Efergy sensor."""
|
||||
app_token = config.get(CONF_APPTOKEN)
|
||||
utc_offset = str(config.get(CONF_UTC_OFFSET))
|
||||
@@ -76,7 +76,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
variable[CONF_SENSOR_TYPE], app_token, utc_offset,
|
||||
variable[CONF_PERIOD], variable[CONF_CURRENCY]))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class EfergySensor(Entity):
|
||||
|
||||
@@ -35,7 +35,7 @@ ATTR_SESSION_START = 'Session Start'
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the eight sleep sensors."""
|
||||
if discovery_info is None:
|
||||
@@ -60,7 +60,7 @@ async def async_setup_platform(hass, config, async_add_devices,
|
||||
else:
|
||||
all_sensors.append(EightUserSensor(name, eight, sensor, units))
|
||||
|
||||
async_add_devices(all_sensors, True)
|
||||
async_add_entities(all_sensors, True)
|
||||
|
||||
|
||||
class EightHeatSensor(EightSleepHeatEntity):
|
||||
|
||||
@@ -35,7 +35,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the ELIQ Online sensor."""
|
||||
import eliqonline
|
||||
|
||||
@@ -52,7 +52,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Could not access the ELIQ Online API: %s", error)
|
||||
return False
|
||||
|
||||
add_devices([EliqSensor(api, channel_id, name)], True)
|
||||
add_entities([EliqSensor(api, channel_id, name)], True)
|
||||
|
||||
|
||||
class EliqSensor(Entity):
|
||||
|
||||
@@ -61,7 +61,7 @@ def get_id(sensorid, feedtag, feedname, feedid, feeduserid):
|
||||
sensorid, feedtag, feedname, feedid, feeduserid)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Emoncms sensor."""
|
||||
apikey = config.get(CONF_API_KEY)
|
||||
url = config.get(CONF_URL)
|
||||
@@ -102,7 +102,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors.append(EmonCmsSensor(hass, data, name, value_template,
|
||||
unit_of_measurement, str(sensorid),
|
||||
elem))
|
||||
add_devices(sensors)
|
||||
add_entities(sensors)
|
||||
|
||||
|
||||
class EmonCmsSensor(Entity):
|
||||
|
||||
@@ -25,12 +25,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up an EnOcean sensor device."""
|
||||
dev_id = config.get(CONF_ID)
|
||||
devname = config.get(CONF_NAME)
|
||||
|
||||
add_devices([EnOceanSensor(dev_id, devname)])
|
||||
add_entities([EnOceanSensor(dev_id, devname)])
|
||||
|
||||
|
||||
class EnOceanSensor(enocean.EnOceanDevice, Entity):
|
||||
|
||||
@@ -37,15 +37,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.All(cv.ensure_list, [vol.In(list(SENSORS))])})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Enphase Envoy sensor."""
|
||||
ip_address = config[CONF_IP_ADDRESS]
|
||||
monitored_conditions = config[CONF_MONITORED_CONDITIONS]
|
||||
|
||||
# Iterate through the list of sensors
|
||||
for condition in monitored_conditions:
|
||||
add_devices([Envoy(ip_address, condition, SENSORS[condition][0],
|
||||
SENSORS[condition][1])], True)
|
||||
add_entities([Envoy(ip_address, condition, SENSORS[condition][0],
|
||||
SENSORS[condition][1])], True)
|
||||
|
||||
|
||||
class Envoy(Entity):
|
||||
|
||||
@@ -52,7 +52,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Sense HAT sensor platform."""
|
||||
try:
|
||||
import envirophat
|
||||
@@ -66,7 +66,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for variable in config[CONF_DISPLAY_OPTIONS]:
|
||||
dev.append(EnvirophatSensor(data, variable))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class EnvirophatSensor(Entity):
|
||||
|
||||
@@ -20,7 +20,8 @@ DEPENDENCIES = ['envisalink']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Perform the setup for Envisalink sensor devices."""
|
||||
configured_partitions = discovery_info['partitions']
|
||||
|
||||
@@ -35,7 +36,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
hass.data[DATA_EVL])
|
||||
devices.append(device)
|
||||
|
||||
async_add_devices(devices)
|
||||
async_add_entities(devices)
|
||||
|
||||
|
||||
class EnvisalinkSensor(EnvisalinkDevice, Entity):
|
||||
|
||||
@@ -30,7 +30,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Etherscan.io sensors."""
|
||||
address = config.get(CONF_ADDRESS)
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -44,7 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
if not name:
|
||||
name = "ETH Balance"
|
||||
|
||||
add_devices([EtherscanSensor(name, address, token, token_address)], True)
|
||||
add_entities([EtherscanSensor(name, address, token, token_address)], True)
|
||||
|
||||
|
||||
class EtherscanSensor(Entity):
|
||||
|
||||
@@ -40,7 +40,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the fail2ban sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
jails = config.get(CONF_JAILS)
|
||||
@@ -52,7 +53,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
for jail in jails:
|
||||
device_list.append(BanSensor(name, jail, log_parser))
|
||||
|
||||
async_add_devices(device_list, True)
|
||||
async_add_entities(device_list, True)
|
||||
|
||||
|
||||
class BanSensor(Entity):
|
||||
|
||||
@@ -41,11 +41,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Fast.com sensor."""
|
||||
data = SpeedtestData(hass, config)
|
||||
sensor = SpeedtestSensor(data)
|
||||
add_devices([sensor])
|
||||
add_entities([sensor])
|
||||
|
||||
def update(call=None):
|
||||
"""Update service for manual updates."""
|
||||
|
||||
@@ -41,7 +41,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Fedex platform."""
|
||||
import fedexdeliverymanager
|
||||
|
||||
@@ -57,7 +57,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.exception("Could not connect to Fedex Delivery Manager")
|
||||
return False
|
||||
|
||||
add_devices([FedexSensor(session, name, update_interval)], True)
|
||||
add_entities([FedexSensor(session, name, update_interval)], True)
|
||||
|
||||
|
||||
class FedexSensor(Entity):
|
||||
|
||||
@@ -71,7 +71,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the Fido sensor."""
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
@@ -89,7 +90,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
for variable in config[CONF_MONITORED_VARIABLES]:
|
||||
sensors.append(FidoSensor(fido_data, variable, name, number))
|
||||
|
||||
async_add_devices(sensors, True)
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
|
||||
class FidoSensor(Entity):
|
||||
|
||||
@@ -33,7 +33,8 @@ 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_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the file sensor."""
|
||||
file_path = config.get(CONF_FILE_PATH)
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -44,7 +45,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
value_template.hass = hass
|
||||
|
||||
if hass.config.is_allowed_path(file_path):
|
||||
async_add_devices(
|
||||
async_add_entities(
|
||||
[FileSensor(name, file_path, unit, value_template)], True)
|
||||
else:
|
||||
_LOGGER.error("'%s' is not a whitelisted directory", file_path)
|
||||
|
||||
@@ -26,7 +26,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the file size sensor."""
|
||||
sensors = []
|
||||
for path in config.get(CONF_FILE_PATHS):
|
||||
@@ -38,7 +38,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
sensors.append(Filesize(path))
|
||||
|
||||
if sensors:
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class Filesize(Entity):
|
||||
|
||||
@@ -114,7 +114,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the template sensors."""
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -124,7 +124,7 @@ async def async_setup_platform(hass, config, async_add_devices,
|
||||
entity=entity_id, **_filter)
|
||||
for _filter in config[CONF_FILTERS]]
|
||||
|
||||
async_add_devices([SensorFilter(name, entity_id, filters)])
|
||||
async_add_entities([SensorFilter(name, entity_id, filters)])
|
||||
|
||||
|
||||
class SensorFilter(Entity):
|
||||
|
||||
@@ -50,7 +50,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the sensors.
|
||||
|
||||
Login to the bank and get a list of existing accounts. Create a
|
||||
@@ -98,7 +98,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.debug('Creating holdings %s for bank %s',
|
||||
account.accountnumber, fints_name)
|
||||
|
||||
add_devices(accounts, True)
|
||||
add_entities(accounts, True)
|
||||
|
||||
|
||||
class FinTsClient:
|
||||
|
||||
@@ -151,7 +151,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def request_app_setup(hass, config, add_devices, config_path,
|
||||
def request_app_setup(hass, config, add_entities, config_path,
|
||||
discovery_info=None):
|
||||
"""Assist user with configuring the Fitbit dev application."""
|
||||
configurator = hass.components.configurator
|
||||
@@ -167,9 +167,9 @@ def request_app_setup(hass, config, add_devices, config_path,
|
||||
configurator.notify_errors(_CONFIGURING['fitbit'],
|
||||
error_msg)
|
||||
else:
|
||||
setup_platform(hass, config, add_devices, discovery_info)
|
||||
setup_platform(hass, config, add_entities, discovery_info)
|
||||
else:
|
||||
setup_platform(hass, config, add_devices, discovery_info)
|
||||
setup_platform(hass, config, add_entities, discovery_info)
|
||||
|
||||
start_url = "{}{}".format(hass.config.api.base_url,
|
||||
FITBIT_AUTH_CALLBACK_PATH)
|
||||
@@ -215,19 +215,19 @@ def request_oauth_completion(hass):
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Fitbit sensor."""
|
||||
config_path = hass.config.path(FITBIT_CONFIG_FILE)
|
||||
if os.path.isfile(config_path):
|
||||
config_file = load_json(config_path)
|
||||
if config_file == DEFAULT_CONFIG:
|
||||
request_app_setup(
|
||||
hass, config, add_devices, config_path, discovery_info=None)
|
||||
hass, config, add_entities, config_path, discovery_info=None)
|
||||
return False
|
||||
else:
|
||||
save_json(config_path, DEFAULT_CONFIG)
|
||||
request_app_setup(
|
||||
hass, config, add_devices, config_path, discovery_info=None)
|
||||
hass, config, add_entities, config_path, discovery_info=None)
|
||||
return False
|
||||
|
||||
if "fitbit" in _CONFIGURING:
|
||||
@@ -276,7 +276,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
dev.append(FitbitSensor(
|
||||
authd_client, config_path, resource,
|
||||
hass.config.units.is_metric, clock_format))
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
else:
|
||||
oauth = fitbit.api.FitbitOauth2Client(
|
||||
@@ -293,7 +293,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
hass.http.register_redirect(FITBIT_AUTH_START, fitbit_auth_start_url)
|
||||
hass.http.register_view(FitbitAuthCallbackView(
|
||||
config, add_devices, oauth))
|
||||
config, add_entities, oauth))
|
||||
|
||||
request_oauth_completion(hass)
|
||||
|
||||
@@ -305,10 +305,10 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
||||
url = FITBIT_AUTH_CALLBACK_PATH
|
||||
name = 'api:fitbit:callback'
|
||||
|
||||
def __init__(self, config, add_devices, oauth):
|
||||
def __init__(self, config, add_entities, oauth):
|
||||
"""Initialize the OAuth callback view."""
|
||||
self.config = config
|
||||
self.add_devices = add_devices
|
||||
self.add_entities = add_entities
|
||||
self.oauth = oauth
|
||||
|
||||
@callback
|
||||
@@ -368,7 +368,8 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
||||
}
|
||||
save_json(hass.config.path(FITBIT_CONFIG_FILE), config_contents)
|
||||
|
||||
hass.async_add_job(setup_platform, hass, self.config, self.add_devices)
|
||||
hass.async_add_job(setup_platform, hass, self.config,
|
||||
self.add_entities)
|
||||
|
||||
return html_response
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Fixer.io sensor."""
|
||||
from fixerio import Fixerio, exceptions
|
||||
|
||||
@@ -53,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
return
|
||||
|
||||
data = ExchangeData(target, api_key)
|
||||
add_devices([ExchangeRateSensor(data, name, target)], True)
|
||||
add_entities([ExchangeRateSensor(data, name, target)], True)
|
||||
|
||||
|
||||
class ExchangeRateSensor(Entity):
|
||||
|
||||
@@ -42,7 +42,7 @@ def get_size(files_list):
|
||||
return sum(size_list)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the folder sensor."""
|
||||
path = config.get(CONF_FOLDER_PATHS)
|
||||
|
||||
@@ -50,7 +50,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("folder %s is not valid or allowed", path)
|
||||
else:
|
||||
folder = Folder(path, config.get(CONF_FILTER))
|
||||
add_devices([folder], True)
|
||||
add_entities([folder], True)
|
||||
|
||||
|
||||
class Folder(Entity):
|
||||
|
||||
@@ -52,7 +52,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the devices associated with the account."""
|
||||
from foobot_async import FoobotClient
|
||||
@@ -82,7 +82,7 @@ async def async_setup_platform(hass, config, async_add_devices,
|
||||
except FoobotClient.ClientError:
|
||||
_LOGGER.error('Failed to fetch data from foobot servers.')
|
||||
return
|
||||
async_add_devices(dev, True)
|
||||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class FoobotSensor(Entity):
|
||||
|
||||
@@ -56,7 +56,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Fritz!Box call monitor sensor platform."""
|
||||
name = config.get(CONF_NAME)
|
||||
host = config.get(CONF_HOST)
|
||||
@@ -77,7 +77,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
sensor = FritzBoxCallSensor(name=name, phonebook=phonebook)
|
||||
|
||||
add_devices([sensor])
|
||||
add_entities([sensor])
|
||||
|
||||
monitor = FritzBoxCallMonitor(host=host, port=port, sensor=sensor)
|
||||
monitor.connect()
|
||||
|
||||
@@ -48,7 +48,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the FRITZ!Box monitor sensors."""
|
||||
# pylint: disable=import-error
|
||||
import fritzconnection as fc
|
||||
@@ -67,7 +67,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
return 1
|
||||
_LOGGER.info("Successfully connected to FRITZ!Box")
|
||||
|
||||
add_devices([FritzboxMonitorSensor(name, fstatus)], True)
|
||||
add_entities([FritzboxMonitorSensor(name, fstatus)], True)
|
||||
|
||||
|
||||
class FritzboxMonitorSensor(Entity):
|
||||
|
||||
@@ -43,7 +43,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Gearbest sensor."""
|
||||
from gearbest_parser import CurrencyConverter
|
||||
currency = config.get(CONF_CURRENCY)
|
||||
@@ -68,7 +68,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
currency_update,
|
||||
MIN_TIME_BETWEEN_CURRENCY_UPDATES)
|
||||
|
||||
add_devices(sensors, True)
|
||||
add_entities(sensors, True)
|
||||
|
||||
|
||||
class GearbestSensor(Entity):
|
||||
|
||||
@@ -13,15 +13,15 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (CONF_DOMAIN, CONF_NAME)
|
||||
from homeassistant.const import CONF_NAME
|
||||
|
||||
REQUIREMENTS = ['beautifulsoup4==4.6.3']
|
||||
REQUIREMENTS = ['geizhals==0.0.7']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_DESCRIPTION = 'description'
|
||||
CONF_PRODUCT_ID = 'product_id'
|
||||
CONF_REGEX = 'regex'
|
||||
CONF_LOCALE = 'locale'
|
||||
|
||||
ICON = 'mdi:coin'
|
||||
|
||||
@@ -31,37 +31,41 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_NAME): cv.string,
|
||||
vol.Required(CONF_PRODUCT_ID): cv.positive_int,
|
||||
vol.Optional(CONF_DESCRIPTION, default='Price'): cv.string,
|
||||
vol.Optional(CONF_DOMAIN, default='geizhals.de'): vol.In(
|
||||
['geizhals.at',
|
||||
'geizhals.eu',
|
||||
'geizhals.de',
|
||||
'skinflint.co.uk',
|
||||
'cenowarka.pl']),
|
||||
vol.Optional(CONF_REGEX, default=r'\D\s(\d*)[\,|\.](\d*)'): cv.string,
|
||||
vol.Optional(CONF_LOCALE, default='DE'): vol.In(
|
||||
['AT',
|
||||
'EU',
|
||||
'DE',
|
||||
'UK',
|
||||
'PL']),
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Geizwatch sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
description = config.get(CONF_DESCRIPTION)
|
||||
product_id = config.get(CONF_PRODUCT_ID)
|
||||
domain = config.get(CONF_DOMAIN)
|
||||
regex = config.get(CONF_REGEX)
|
||||
domain = config.get(CONF_LOCALE)
|
||||
|
||||
add_devices([Geizwatch(name, description, product_id, domain, regex)],
|
||||
True)
|
||||
add_entities([Geizwatch(name, description, product_id, domain)],
|
||||
True)
|
||||
|
||||
|
||||
class Geizwatch(Entity):
|
||||
"""Implementation of Geizwatch."""
|
||||
|
||||
def __init__(self, name, description, product_id, domain, regex):
|
||||
def __init__(self, name, description, product_id, domain):
|
||||
"""Initialize the sensor."""
|
||||
from geizhals import Device, Geizhals
|
||||
|
||||
# internal
|
||||
self._name = name
|
||||
self._geizhals = Geizhals(product_id, domain)
|
||||
self._device = Device()
|
||||
|
||||
# external
|
||||
self.description = description
|
||||
self.data = GeizParser(product_id, domain, regex)
|
||||
self._state = None
|
||||
self.product_id = product_id
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -76,73 +80,24 @@ class Geizwatch(Entity):
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the best price of the selected product."""
|
||||
return self._state
|
||||
return self._device.prices[0]
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
while len(self.data.prices) < 4:
|
||||
self.data.prices.append("None")
|
||||
attrs = {'device_name': self.data.device_name,
|
||||
while len(self._device.prices) < 4:
|
||||
self._device.prices.append('None')
|
||||
attrs = {'device_name': self._device.name,
|
||||
'description': self.description,
|
||||
'unit_of_measurement': self.data.unit_of_measurement,
|
||||
'product_id': self.data.product_id,
|
||||
'price1': self.data.prices[0],
|
||||
'price2': self.data.prices[1],
|
||||
'price3': self.data.prices[2],
|
||||
'price4': self.data.prices[3]}
|
||||
'unit_of_measurement': self._device.price_currency,
|
||||
'product_id': self.product_id,
|
||||
'price1': self._device.prices[0],
|
||||
'price2': self._device.prices[1],
|
||||
'price3': self._device.prices[2],
|
||||
'price4': self._device.prices[3]}
|
||||
return attrs
|
||||
|
||||
def update(self):
|
||||
"""Get the latest price from geizhals and updates the state."""
|
||||
self.data.update()
|
||||
self._state = self.data.prices[0]
|
||||
|
||||
|
||||
class GeizParser:
|
||||
"""Pull data from the geizhals website."""
|
||||
|
||||
def __init__(self, product_id, domain, regex):
|
||||
"""Initialize the sensor."""
|
||||
# parse input arguments
|
||||
self.product_id = product_id
|
||||
self.domain = domain
|
||||
self.regex = regex
|
||||
|
||||
# set some empty default values
|
||||
self.device_name = ''
|
||||
self.prices = [None, None, None, None]
|
||||
self.unit_of_measurement = ''
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
"""Update the device prices."""
|
||||
import bs4
|
||||
import requests
|
||||
import re
|
||||
|
||||
sess = requests.session()
|
||||
request = sess.get('https://{}/{}'.format(self.domain,
|
||||
self.product_id),
|
||||
allow_redirects=True,
|
||||
timeout=1)
|
||||
soup = bs4.BeautifulSoup(request.text, 'html.parser')
|
||||
|
||||
# parse name
|
||||
raw = soup.find_all('span', attrs={'itemprop': 'name'})
|
||||
self.device_name = raw[1].string
|
||||
|
||||
# parse prices
|
||||
prices = []
|
||||
for tmp in soup.find_all('span', attrs={'class': 'gh_price'}):
|
||||
matches = re.search(self.regex, tmp.string)
|
||||
raw = '{}.{}'.format(matches.group(1),
|
||||
matches.group(2))
|
||||
prices += [float(raw)]
|
||||
prices.sort()
|
||||
self.prices = prices[1:]
|
||||
|
||||
# parse unit
|
||||
price_match = soup.find('span', attrs={'class': 'gh_price'})
|
||||
matches = re.search(r'€|£|PLN', price_match.string)
|
||||
self.unit_of_measurement = matches.group()
|
||||
"""Get the latest price from geizhals and updates the state."""
|
||||
self._device = self._geizhals.parse()
|
||||
@@ -54,7 +54,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the GeoRSS component."""
|
||||
home_latitude = hass.config.latitude
|
||||
home_longitude = hass.config.longitude
|
||||
@@ -81,7 +81,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
device = GeoRssServiceSensor(category, data, name,
|
||||
unit_of_measurement)
|
||||
devices.append(device)
|
||||
add_devices(devices, True)
|
||||
add_entities(devices, True)
|
||||
|
||||
|
||||
class GeoRssServiceSensor(Entity):
|
||||
|
||||
@@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Gitter sensor."""
|
||||
from gitterpy.client import GitterClient
|
||||
from gitterpy.errors import GitterTokenError
|
||||
@@ -49,7 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Token is not valid")
|
||||
return
|
||||
|
||||
add_devices([GitterSensor(gitter, room, name, username)], True)
|
||||
add_entities([GitterSensor(gitter, room, name, username)], True)
|
||||
|
||||
|
||||
class GitterSensor(Entity):
|
||||
|
||||
@@ -63,7 +63,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the Glances sensors."""
|
||||
from glances_api import Glances
|
||||
|
||||
@@ -86,7 +86,7 @@ async def async_setup_platform(
|
||||
for resource in var_conf:
|
||||
dev.append(GlancesSensor(glances, name, resource))
|
||||
|
||||
async_add_devices(dev, True)
|
||||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class GlancesSensor(Entity):
|
||||
|
||||
@@ -79,7 +79,7 @@ def convert_time_to_utc(timestr):
|
||||
return dt_util.as_timestamp(combined)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities_callback, discovery_info=None):
|
||||
"""Set up the Google travel time platform."""
|
||||
def run_setup(event):
|
||||
"""Delay the setup until Home Assistant is fully initialized.
|
||||
@@ -112,7 +112,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
hass, name, api_key, origin, destination, options)
|
||||
|
||||
if sensor.valid_api_connection:
|
||||
add_devices_callback([sensor])
|
||||
add_entities_callback([sensor])
|
||||
|
||||
# Wait until start event is sent to load this component.
|
||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, run_setup)
|
||||
|
||||
@@ -76,7 +76,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Google Wifi sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
host = config.get(CONF_HOST)
|
||||
@@ -87,7 +87,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for condition in conditions:
|
||||
dev.append(GoogleWifiSensor(api, name, condition))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class GoogleWifiSensor(Entity):
|
||||
|
||||
@@ -36,7 +36,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the GPSD component."""
|
||||
name = config.get(CONF_NAME)
|
||||
host = config.get(CONF_HOST)
|
||||
@@ -62,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
_LOGGER.error("Not able to connect to GPSD")
|
||||
return False
|
||||
|
||||
add_devices([GpsdSensor(hass, name, host, port)])
|
||||
add_entities([GpsdSensor(hass, name, host, port)])
|
||||
|
||||
|
||||
class GpsdSensor(Entity):
|
||||
|
||||
@@ -151,7 +151,7 @@ def get_next_departure(sched, start_station_id, end_station_id, offset):
|
||||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the GTFS sensor."""
|
||||
gtfs_dir = hass.config.path(DEFAULT_PATH)
|
||||
data = config.get(CONF_DATA)
|
||||
@@ -179,7 +179,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
if not gtfs.feeds:
|
||||
pygtfs.append_feed(gtfs, os.path.join(gtfs_dir, data))
|
||||
|
||||
add_devices([GTFSDepartureSensor(gtfs, name, origin, destination, offset)])
|
||||
add_entities([
|
||||
GTFSDepartureSensor(gtfs, name, origin, destination, offset)])
|
||||
|
||||
|
||||
class GTFSDepartureSensor(Entity):
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
"""
|
||||
The Habitica sensor.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.habitica/
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.components import habitica
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the habitica platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
name = discovery_info[habitica.CONF_NAME]
|
||||
sensors = discovery_info[habitica.CONF_SENSORS]
|
||||
sensor_data = HabitipyData(hass.data[habitica.DOMAIN][name])
|
||||
await sensor_data.update()
|
||||
async_add_devices([
|
||||
HabitipySensor(name, sensor, sensor_data)
|
||||
for sensor in sensors
|
||||
], True)
|
||||
|
||||
|
||||
class HabitipyData:
|
||||
"""Habitica API user data cache."""
|
||||
|
||||
def __init__(self, api):
|
||||
"""
|
||||
Habitica API user data cache.
|
||||
|
||||
api - HAHabitipyAsync object
|
||||
"""
|
||||
self.api = api
|
||||
self.data = None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
async def update(self):
|
||||
"""Get a new fix from Habitica servers."""
|
||||
self.data = await self.api.user.get()
|
||||
|
||||
|
||||
class HabitipySensor(Entity):
|
||||
"""A generic Habitica sensor."""
|
||||
|
||||
def __init__(self, name, sensor_name, updater):
|
||||
"""
|
||||
Init a generic Habitica sensor.
|
||||
|
||||
name - Habitica platform name
|
||||
sensor_name - one of the names from ALL_SENSOR_TYPES
|
||||
"""
|
||||
self._name = name
|
||||
self._sensor_name = sensor_name
|
||||
self._sensor_type = habitica.SENSORS_TYPES[sensor_name]
|
||||
self._state = None
|
||||
self._updater = updater
|
||||
|
||||
async def async_update(self):
|
||||
"""Update Condition and Forecast."""
|
||||
await self._updater.update()
|
||||
data = self._updater.data
|
||||
for element in self._sensor_type.path:
|
||||
data = data[element]
|
||||
self._state = data
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return self._sensor_type.icon
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return "{0}_{1}_{2}".format(
|
||||
habitica.DOMAIN, self._name, self._sensor_name)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit the value is expressed in."""
|
||||
return self._sensor_type.unit
|
||||
@@ -35,7 +35,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the HaveIBeenPwned sensor."""
|
||||
emails = config.get(CONF_EMAIL)
|
||||
data = HaveIBeenPwnedData(emails)
|
||||
@@ -44,7 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for email in emails:
|
||||
devices.append(HaveIBeenPwnedSensor(data, hass, email))
|
||||
|
||||
add_devices(devices)
|
||||
add_entities(devices)
|
||||
|
||||
# To make sure we get initial data for the sensors ignoring the normal
|
||||
# throttle of 15 minutes but using an update throttle of 5 seconds
|
||||
|
||||
@@ -37,7 +37,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the HDDTemp sensor."""
|
||||
name = config.get(CONF_NAME)
|
||||
host = config.get(CONF_HOST)
|
||||
@@ -54,7 +54,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for disk in disks:
|
||||
dev.append(HddTempSensor(name, disk, hddtemp))
|
||||
|
||||
add_devices(dev, True)
|
||||
add_entities(dev, True)
|
||||
|
||||
|
||||
class HddTempSensor(Entity):
|
||||
|
||||
Loaded 100 of 974 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user