Merge remote-tracking branch 'upstream/dev' into igd
This commit is contained in:
commit
e73f31d829
485 files changed
+6059
-3434
No files matched your search
@@ -43,7 +43,7 @@ async def async_setup(hass, config):
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Setup a config entry."""
|
||||
"""Set up a config entry."""
|
||||
return await hass.data[DOMAIN].async_setup_entry(entry)
|
||||
|
||||
|
||||
|
||||
@@ -58,7 +58,10 @@ class BMWConnectedDriveSensor(Entity):
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Data update is triggered from BMWConnectedDriveEntity."""
|
||||
"""Return False.
|
||||
|
||||
Data update is triggered from BMWConnectedDriveEntity.
|
||||
"""
|
||||
return False
|
||||
|
||||
@property
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Counter for the days till a HTTPS (TLS) certificate will expire.
|
||||
Counter for the days until an HTTPS (TLS) certificate will expire.
|
||||
|
||||
For more details about this sensor please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.cert_expiry/
|
||||
|
||||
@@ -28,7 +28,7 @@ LAST_BILL_DAYS_BILLED = "last_bills_days_billed"
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup all Duke Energy meters."""
|
||||
"""Set up all Duke Energy meters."""
|
||||
from pydukeenergy.api import DukeEnergy, DukeEnergyException
|
||||
|
||||
try:
|
||||
@@ -36,7 +36,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
config[CONF_PASSWORD],
|
||||
update_interval=120)
|
||||
except DukeEnergyException:
|
||||
_LOGGER.error("Failed to setup Duke Energy")
|
||||
_LOGGER.error("Failed to set up Duke Energy")
|
||||
return
|
||||
|
||||
add_devices([DukeEnergyMeter(meter) for meter in duke.get_meters()])
|
||||
|
||||
@@ -108,7 +108,7 @@ class FinTsClient:
|
||||
"""
|
||||
|
||||
def __init__(self, credentials: BankCredentials, name: str):
|
||||
"""Constructor for class FinTsClient."""
|
||||
"""Initialize a FinTsClient."""
|
||||
self._credentials = credentials
|
||||
self.name = name
|
||||
|
||||
@@ -151,14 +151,14 @@ class FinTsClient:
|
||||
|
||||
|
||||
class FinTsAccount(Entity):
|
||||
"""Sensor for a FinTS balanc account.
|
||||
"""Sensor for a FinTS balance account.
|
||||
|
||||
A balance account contains an amount of money (=balance). The amount may
|
||||
also be negative.
|
||||
"""
|
||||
|
||||
def __init__(self, client: FinTsClient, account, name: str) -> None:
|
||||
"""Constructor for class FinTsAccount."""
|
||||
"""Initialize a FinTs balance account."""
|
||||
self._client = client # type: FinTsClient
|
||||
self._account = account
|
||||
self._name = name # type: str
|
||||
@@ -167,7 +167,10 @@ class FinTsAccount(Entity):
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Data needs to be polled from the bank servers."""
|
||||
"""Return True.
|
||||
|
||||
Data needs to be polled from the bank servers.
|
||||
"""
|
||||
return True
|
||||
|
||||
def update(self) -> None:
|
||||
@@ -218,7 +221,7 @@ class FinTsHoldingsAccount(Entity):
|
||||
"""
|
||||
|
||||
def __init__(self, client: FinTsClient, account, name: str) -> None:
|
||||
"""Constructor for class FinTsHoldingsAccount."""
|
||||
"""Initialize a FinTs holdings account."""
|
||||
self._client = client # type: FinTsClient
|
||||
self._name = name # type: str
|
||||
self._account = account
|
||||
@@ -227,7 +230,10 @@ class FinTsHoldingsAccount(Entity):
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Data needs to be polled from the bank servers."""
|
||||
"""Return True.
|
||||
|
||||
Data needs to be polled from the bank servers.
|
||||
"""
|
||||
return True
|
||||
|
||||
def update(self) -> None:
|
||||
|
||||
@@ -5,8 +5,9 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.homematic/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematic import ATTR_DISCOVER_DEVICES, HMDevice
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -70,7 +71,7 @@ HM_ICON_HA_CAST = {
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the HomeMatic platform."""
|
||||
"""Set up the HomeMatic sensor platform."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
@@ -83,7 +84,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class HMSensor(HMDevice):
|
||||
"""Represents various HomeMatic sensors in Home Assistant."""
|
||||
"""Representation of a HomeMatic sensor."""
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -111,4 +112,4 @@ class HMSensor(HMDevice):
|
||||
if self._state:
|
||||
self._data.update({self._state: STATE_UNKNOWN})
|
||||
else:
|
||||
_LOGGER.critical("Can't initialize sensor %s", self._name)
|
||||
_LOGGER.critical("Unable to initialize sensor: %s", self._name)
|
||||
@@ -1,18 +1,17 @@
|
||||
"""
|
||||
Support for HomematicIP sensors.
|
||||
Support for HomematicIP Cloud sensors.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.homematicip_cloud/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN,
|
||||
HMIPC_HAPID)
|
||||
HMIPC_HAPID, HomematicipGenericDevice)
|
||||
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE)
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
|
||||
TEMP_CELSIUS)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -25,14 +24,14 @@ ATTR_TEMPERATURE_OFFSET = 'temperature_offset'
|
||||
ATTR_HUMIDITY = 'humidity'
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the HomematicIP sensors devices."""
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud sensors devices."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
"""Set up the HomematicIP sensors from a config entry."""
|
||||
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
||||
from homematicip.device import (
|
||||
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
|
||||
TemperatureHumiditySensorDisplay, MotionDetectorIndoor)
|
||||
@@ -54,7 +53,7 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
|
||||
|
||||
|
||||
class HomematicipAccesspointStatus(HomematicipGenericDevice):
|
||||
"""Representation of an HomeMaticIP access point."""
|
||||
"""Representation of an HomeMaticIP Cloud access point."""
|
||||
|
||||
def __init__(self, home):
|
||||
"""Initialize access point device."""
|
||||
@@ -82,7 +81,7 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice):
|
||||
|
||||
|
||||
class HomematicipHeatingThermostat(HomematicipGenericDevice):
|
||||
"""MomematicIP heating thermostat representation."""
|
||||
"""Represenation of a HomematicIP heating thermostat device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize heating thermostat device."""
|
||||
@@ -115,7 +114,7 @@ class HomematicipHeatingThermostat(HomematicipGenericDevice):
|
||||
|
||||
|
||||
class HomematicipHumiditySensor(HomematicipGenericDevice):
|
||||
"""MomematicIP humidity device."""
|
||||
"""Represenation of a HomematicIP Cloud humidity device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the thermometer device."""
|
||||
@@ -138,7 +137,7 @@ class HomematicipHumiditySensor(HomematicipGenericDevice):
|
||||
|
||||
|
||||
class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
||||
"""MomematicIP the thermometer device."""
|
||||
"""Representation of a HomematicIP Cloud thermometer device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the thermometer device."""
|
||||
@@ -161,7 +160,7 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
|
||||
|
||||
|
||||
class HomematicipIlluminanceSensor(HomematicipGenericDevice):
|
||||
"""MomematicIP the thermometer device."""
|
||||
"""Represenation of a HomematicIP Illuminance device."""
|
||||
|
||||
def __init__(self, home, device):
|
||||
"""Initialize the device."""
|
||||
|
||||
@@ -31,7 +31,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the ihc sensor platform."""
|
||||
"""Set up the IHC sensor platform."""
|
||||
ihc_controller = hass.data[IHC_DATA][IHC_CONTROLLER]
|
||||
info = hass.data[IHC_DATA][IHC_INFO]
|
||||
devices = []
|
||||
@@ -77,6 +77,6 @@ class IHCSensor(IHCDevice, Entity):
|
||||
return self._unit_of_measurement
|
||||
|
||||
def on_ihc_change(self, ihc_id, value):
|
||||
"""Callback when ihc resource changes."""
|
||||
"""Handle IHC resource change."""
|
||||
self._state = value
|
||||
self.schedule_update_ha_state()
|
||||
+8
-8
@@ -2,35 +2,35 @@
|
||||
Support for INSTEON dimmers via PowerLinc Modem.
|
||||
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.insteon_plm/
|
||||
https://home-assistant.io/components/sensor.insteon/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.components.insteon_plm import InsteonPLMEntity
|
||||
from homeassistant.components.insteon import InsteonEntity
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
DEPENDENCIES = ['insteon_plm']
|
||||
DEPENDENCIES = ['insteon']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
"""Set up the INSTEON PLM device class for the hass platform."""
|
||||
plm = hass.data['insteon_plm'].get('plm')
|
||||
"""Set up the INSTEON device class for the hass platform."""
|
||||
insteon_modem = hass.data['insteon'].get('modem')
|
||||
|
||||
address = discovery_info['address']
|
||||
device = plm.devices[address]
|
||||
device = insteon_modem.devices[address]
|
||||
state_key = discovery_info['state_key']
|
||||
|
||||
_LOGGER.debug('Adding device %s entity %s to Sensor platform',
|
||||
device.address.hex, device.states[state_key].name)
|
||||
|
||||
new_entity = InsteonPLMSensorDevice(device, state_key)
|
||||
new_entity = InsteonSensorDevice(device, state_key)
|
||||
|
||||
async_add_devices([new_entity])
|
||||
|
||||
|
||||
class InsteonPLMSensorDevice(InsteonPLMEntity, Entity):
|
||||
class InsteonSensorDevice(InsteonEntity, Entity):
|
||||
"""A Class for an Insteon device."""
|
||||
@@ -49,14 +49,14 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return '{} {}'.format(self.device.name(), self._name)
|
||||
return '{} {}'.format(self._device.name(), self._name)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the sensor."""
|
||||
icon = None
|
||||
if self.type == 'status':
|
||||
status = self.device.getStatus()
|
||||
status = self._device.getStatus()
|
||||
if status == 'standby':
|
||||
icon = 'mdi:power-plug-off'
|
||||
elif status == 'plugged':
|
||||
@@ -87,19 +87,19 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
"""Return the state."""
|
||||
state = None
|
||||
if self.type == 'status':
|
||||
state = self.device.getStatus()
|
||||
state = self._device.getStatus()
|
||||
elif self.type == 'temperature':
|
||||
state = self.device.getTemperature()
|
||||
state = self._device.getTemperature()
|
||||
elif self.type == 'voltage':
|
||||
state = self.device.getVoltage()
|
||||
state = self._device.getVoltage()
|
||||
elif self.type == 'amps':
|
||||
state = self.device.getAmps()
|
||||
state = self._device.getAmps()
|
||||
elif self.type == 'watts':
|
||||
state = self.device.getWatts()
|
||||
state = self._device.getWatts()
|
||||
elif self.type == 'charge_time':
|
||||
state = self.device.getChargeTime()
|
||||
state = self._device.getChargeTime()
|
||||
elif self.type == 'energy_added':
|
||||
state = self.device.getEnergyAdded()
|
||||
state = self._device.getEnergyAdded()
|
||||
else:
|
||||
state = 'Unknown'
|
||||
return state
|
||||
@@ -109,7 +109,7 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
if self.type == 'status':
|
||||
man_dev_id = self.device.id()
|
||||
man_dev_id = self._device.id()
|
||||
if man_dev_id:
|
||||
attributes["manufacturer_device_id"] = man_dev_id
|
||||
return attributes
|
||||
@@ -64,7 +64,7 @@ class KNXSensor(Entity):
|
||||
|
||||
def __init__(self, hass, device):
|
||||
"""Initialize of a KNX sensor."""
|
||||
self.device = device
|
||||
self._device = device
|
||||
self.hass = hass
|
||||
self.async_register_callbacks()
|
||||
|
||||
@@ -74,12 +74,12 @@ class KNXSensor(Entity):
|
||||
async def after_update_callback(device):
|
||||
"""Call after device was updated."""
|
||||
await self.async_update_ha_state()
|
||||
self.device.register_device_updated_cb(after_update_callback)
|
||||
self._device.register_device_updated_cb(after_update_callback)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the KNX device."""
|
||||
return self.device.name
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
@@ -94,12 +94,12 @@ class KNXSensor(Entity):
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self.device.resolve_state()
|
||||
return self._device.resolve_state()
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return self.device.unit_of_measurement()
|
||||
return self._device.unit_of_measurement()
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the melissa sensor platform."""
|
||||
"""Set up the melissa sensor platform."""
|
||||
sensors = []
|
||||
api = hass.data[DATA_MELISSA]
|
||||
devices = api.fetch_devices().values()
|
||||
|
||||
@@ -140,15 +140,15 @@ class NestBasicSensor(NestSensorDevice):
|
||||
self._unit = SENSOR_UNITS.get(self.variable)
|
||||
|
||||
if self.variable in VARIABLE_NAME_MAPPING:
|
||||
self._state = getattr(self.device,
|
||||
self._state = getattr(self._device,
|
||||
VARIABLE_NAME_MAPPING[self.variable])
|
||||
elif self.variable in PROTECT_SENSOR_TYPES \
|
||||
and self.variable != 'color_status':
|
||||
# keep backward compatibility
|
||||
state = getattr(self.device, self.variable)
|
||||
state = getattr(self._device, self.variable)
|
||||
self._state = state.capitalize() if state is not None else None
|
||||
else:
|
||||
self._state = getattr(self.device, self.variable)
|
||||
self._state = getattr(self._device, self.variable)
|
||||
|
||||
|
||||
class NestTempSensor(NestSensorDevice):
|
||||
@@ -166,12 +166,12 @@ class NestTempSensor(NestSensorDevice):
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
if self.device.temperature_scale == 'C':
|
||||
if self._device.temperature_scale == 'C':
|
||||
self._unit = TEMP_CELSIUS
|
||||
else:
|
||||
self._unit = TEMP_FAHRENHEIT
|
||||
|
||||
temp = getattr(self.device, self.variable)
|
||||
temp = getattr(self._device, self.variable)
|
||||
if temp is None:
|
||||
self._state = None
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
"""
|
||||
Support for the NOAA Tides and Currents API.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.noaa_tides/
|
||||
"""
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION, CONF_NAME, CONF_TIME_ZONE, CONF_UNIT_SYSTEM)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['py_noaa==0.3.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_STATION_ID = 'station_id'
|
||||
|
||||
DEFAULT_ATTRIBUTION = "Data provided by NOAA"
|
||||
DEFAULT_NAME = 'NOAA Tides'
|
||||
DEFAULT_TIMEZONE = 'lst_ldt'
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=60)
|
||||
|
||||
TIMEZONES = ['gmt', 'lst', 'lst_ldt']
|
||||
UNIT_SYSTEMS = ['english', 'metric']
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_STATION_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_TIME_ZONE, default=DEFAULT_TIMEZONE): vol.In(TIMEZONES),
|
||||
vol.Optional(CONF_UNIT_SYSTEM): vol.In(UNIT_SYSTEMS),
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Set up the NOAA Tides and Currents sensor."""
|
||||
station_id = config[CONF_STATION_ID]
|
||||
name = config.get(CONF_NAME)
|
||||
timezone = config.get(CONF_TIME_ZONE)
|
||||
|
||||
if CONF_UNIT_SYSTEM in config:
|
||||
unit_system = config[CONF_UNIT_SYSTEM]
|
||||
elif hass.config.units.is_metric:
|
||||
unit_system = UNIT_SYSTEMS[1]
|
||||
else:
|
||||
unit_system = UNIT_SYSTEMS[0]
|
||||
|
||||
noaa_sensor = NOAATidesAndCurrentsSensor(
|
||||
name, station_id, timezone, unit_system)
|
||||
|
||||
noaa_sensor.update()
|
||||
if noaa_sensor.data is None:
|
||||
_LOGGER.error("Unable to setup NOAA Tides Sensor")
|
||||
return
|
||||
add_devices([noaa_sensor], True)
|
||||
|
||||
|
||||
class NOAATidesAndCurrentsSensor(Entity):
|
||||
"""Representation of a NOAA Tides and Currents sensor."""
|
||||
|
||||
def __init__(self, name, station_id, timezone, unit_system):
|
||||
"""Initialize the sensor."""
|
||||
self._name = name
|
||||
self._station_id = station_id
|
||||
self._timezone = timezone
|
||||
self._unit_system = unit_system
|
||||
self.data = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of this device."""
|
||||
attr = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||
if self.data is None:
|
||||
return attr
|
||||
if self.data['hi_lo'][1] == 'H':
|
||||
attr['high_tide_time'] = \
|
||||
self.data.index[1].strftime('%Y-%m-%dT%H:%M')
|
||||
attr['high_tide_height'] = self.data['predicted_wl'][1]
|
||||
attr['low_tide_time'] = \
|
||||
self.data.index[2].strftime('%Y-%m-%dT%H:%M')
|
||||
attr['low_tide_height'] = self.data['predicted_wl'][2]
|
||||
elif self.data['hi_lo'][1] == 'L':
|
||||
attr['low_tide_time'] = \
|
||||
self.data.index[1].strftime('%Y-%m-%dT%H:%M')
|
||||
attr['low_tide_height'] = self.data['predicted_wl'][1]
|
||||
attr['high_tide_time'] = \
|
||||
self.data.index[2].strftime('%Y-%m-%dT%H:%M')
|
||||
attr['high_tide_height'] = self.data['predicted_wl'][2]
|
||||
return attr
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
if self.data is None:
|
||||
return None
|
||||
api_time = self.data.index[0]
|
||||
if self.data['hi_lo'][0] == 'H':
|
||||
tidetime = api_time.strftime('%-I:%M %p')
|
||||
return "High tide at {}".format(tidetime)
|
||||
if self.data['hi_lo'][0] == 'L':
|
||||
tidetime = api_time.strftime('%-I:%M %p')
|
||||
return "Low tide at {}".format(tidetime)
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data from NOAA Tides and Currents API."""
|
||||
from py_noaa import coops # pylint: disable=import-error
|
||||
begin = datetime.now()
|
||||
delta = timedelta(days=2)
|
||||
end = begin + delta
|
||||
try:
|
||||
df_predictions = coops.get_data(
|
||||
begin_date=begin.strftime("%Y%m%d %H:%M"),
|
||||
end_date=end.strftime("%Y%m%d %H:%M"),
|
||||
stationid=self._station_id,
|
||||
product="predictions",
|
||||
datum="MLLW",
|
||||
interval="hilo",
|
||||
units=self._unit_system,
|
||||
time_zone=self._timezone)
|
||||
self.data = df_predictions.head()
|
||||
_LOGGER.debug("Data = %s", self.data)
|
||||
_LOGGER.debug("Recent Tide data queried with start time set to %s",
|
||||
begin.strftime("%m-%d-%Y %H:%M"))
|
||||
except ValueError as err:
|
||||
_LOGGER.error("Check NOAA Tides and Currents: %s", err.args)
|
||||
self.data = None
|
||||
@@ -164,7 +164,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
data = PyNUTData(host, port, alias, username, password)
|
||||
|
||||
if data.status is None:
|
||||
_LOGGER.error("NUT Sensor has no data, unable to setup")
|
||||
_LOGGER.error("NUT Sensor has no data, unable to set up")
|
||||
raise PlatformNotReady
|
||||
|
||||
_LOGGER.debug('NUT Sensors Available: %s', data.status)
|
||||
|
||||
@@ -11,10 +11,10 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.components.openuv import (
|
||||
DATA_UV, DOMAIN, SENSORS, TOPIC_UPDATE, TYPE_CURRENT_OZONE_LEVEL,
|
||||
TYPE_CURRENT_UV_INDEX, TYPE_MAX_UV_INDEX, TYPE_SAFE_EXPOSURE_TIME_1,
|
||||
TYPE_SAFE_EXPOSURE_TIME_2, TYPE_SAFE_EXPOSURE_TIME_3,
|
||||
TYPE_SAFE_EXPOSURE_TIME_4, TYPE_SAFE_EXPOSURE_TIME_5,
|
||||
TYPE_SAFE_EXPOSURE_TIME_6, OpenUvEntity)
|
||||
TYPE_CURRENT_UV_INDEX, TYPE_CURRENT_UV_LEVEL, TYPE_MAX_UV_INDEX,
|
||||
TYPE_SAFE_EXPOSURE_TIME_1, TYPE_SAFE_EXPOSURE_TIME_2,
|
||||
TYPE_SAFE_EXPOSURE_TIME_3, TYPE_SAFE_EXPOSURE_TIME_4,
|
||||
TYPE_SAFE_EXPOSURE_TIME_5, TYPE_SAFE_EXPOSURE_TIME_6, OpenUvEntity)
|
||||
from homeassistant.util.dt import as_local, parse_datetime
|
||||
|
||||
DEPENDENCIES = ['openuv']
|
||||
@@ -31,6 +31,12 @@ EXPOSURE_TYPE_MAP = {
|
||||
TYPE_SAFE_EXPOSURE_TIME_6: 'st6'
|
||||
}
|
||||
|
||||
UV_LEVEL_EXTREME = "Extreme"
|
||||
UV_LEVEL_VHIGH = "Very High"
|
||||
UV_LEVEL_HIGH = "High"
|
||||
UV_LEVEL_MODERATE = "Moderate"
|
||||
UV_LEVEL_LOW = "Low"
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_devices, discovery_info=None):
|
||||
@@ -105,6 +111,17 @@ class OpenUvSensor(OpenUvEntity):
|
||||
self._state = data['ozone']
|
||||
elif self._sensor_type == TYPE_CURRENT_UV_INDEX:
|
||||
self._state = data['uv']
|
||||
elif self._sensor_type == TYPE_CURRENT_UV_LEVEL:
|
||||
if data['uv'] >= 11:
|
||||
self._state = UV_LEVEL_EXTREME
|
||||
elif data['uv'] >= 8:
|
||||
self._state = UV_LEVEL_VHIGH
|
||||
elif data['uv'] >= 6:
|
||||
self._state = UV_LEVEL_HIGH
|
||||
elif data['uv'] >= 3:
|
||||
self._state = UV_LEVEL_MODERATE
|
||||
else:
|
||||
self._state = UV_LEVEL_LOW
|
||||
elif self._sensor_type == TYPE_MAX_UV_INDEX:
|
||||
self._state = data['uv_max']
|
||||
self._attrs.update({
|
||||
|
||||
@@ -14,7 +14,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
REQUIREMENTS = ['shodan==1.9.0']
|
||||
REQUIREMENTS = ['shodan==1.9.1']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the sensor platform."""
|
||||
"""Set up the sensor platform."""
|
||||
from Adafruit_SHT31 import SHT31
|
||||
|
||||
i2c_address = config.get(CONF_I2C_ADDRESS)
|
||||
|
||||
@@ -77,7 +77,7 @@ class SigfoxAPI:
|
||||
_LOGGER.error(
|
||||
"Unable to login to Sigfox API, error code %s", str(
|
||||
response.status_code))
|
||||
raise ValueError('Sigfox component not setup')
|
||||
raise ValueError('Sigfox component not set up')
|
||||
return True
|
||||
|
||||
def get_device_types(self):
|
||||
|
||||
@@ -79,15 +79,10 @@ class TankUtilitySensor(Entity):
|
||||
self._token = token
|
||||
self._device = device
|
||||
self._state = STATE_UNKNOWN
|
||||
self._name = "Tank Utility " + self.device
|
||||
self._name = "Tank Utility " + self._device
|
||||
self._unit_of_measurement = SENSOR_UNIT_OF_MEASUREMENT
|
||||
self._attributes = {}
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
"""Return the device identifier."""
|
||||
return self._device
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
@@ -117,14 +112,14 @@ class TankUtilitySensor(Entity):
|
||||
from tank_utility import auth, device
|
||||
data = {}
|
||||
try:
|
||||
data = device.get_device_data(self._token, self.device)
|
||||
data = device.get_device_data(self._token, self._device)
|
||||
except requests.exceptions.HTTPError as http_error:
|
||||
if (http_error.response.status_code ==
|
||||
requests.codes.unauthorized): # pylint: disable=no-member
|
||||
_LOGGER.info("Getting new token")
|
||||
self._token = auth.get_token(self._email, self._password,
|
||||
force=True)
|
||||
data = device.get_device_data(self._token, self.device)
|
||||
data = device.get_device_data(self._token, self._device)
|
||||
else:
|
||||
raise http_error
|
||||
data.update(data.pop("device", {}))
|
||||
|
||||
@@ -67,7 +67,7 @@ class TelldusLiveSensor(TelldusLiveEntity):
|
||||
@property
|
||||
def _value(self):
|
||||
"""Return value of the sensor."""
|
||||
return self.device.value(*self._id[1:])
|
||||
return self._device.value(*self._id[1:])
|
||||
|
||||
@property
|
||||
def _value_as_temperature(self):
|
||||
|
||||
@@ -29,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setting the platform in HASS and Case Information."""
|
||||
"""Set up the platform in HASS and Case Information."""
|
||||
uscis = UscisSensor(config['case_id'], config[CONF_FRIENDLY_NAME])
|
||||
uscis.update()
|
||||
if uscis.valid_case_id:
|
||||
@@ -72,7 +72,7 @@ class UscisSensor(Entity):
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
"""Using Request to access USCIS website and fetch data."""
|
||||
"""Fetch data from the USCIS website and update state attributes."""
|
||||
import uscisstatus
|
||||
try:
|
||||
status = uscisstatus.get_case_status(self._case_id)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Sensor support for Wirelss Sensor Tags platform.
|
||||
Sensor support for Wireless Sensor Tags platform.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.wirelesstag/
|
||||
@@ -58,7 +58,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the sensor platform."""
|
||||
"""Set up the sensor platform."""
|
||||
platform = hass.data.get(WIRELESSTAG_DOMAIN)
|
||||
sensors = []
|
||||
tags = platform.tags
|
||||
@@ -98,7 +98,7 @@ class WirelessTagSensor(WirelessTagBaseSensor):
|
||||
else all_sensors)
|
||||
|
||||
def __init__(self, api, tag, sensor_type, config):
|
||||
"""Constructor with platform(api), tag and hass sensor type."""
|
||||
"""Initialize a WirelessTag sensor."""
|
||||
super().__init__(api, tag)
|
||||
|
||||
self._sensor_type = sensor_type
|
||||
|
||||
@@ -25,7 +25,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
})
|
||||
|
||||
REQUIREMENTS = ['python-miio==0.4.0', 'construct==2.9.41']
|
||||
REQUIREMENTS = ['python-miio==0.4.1', 'construct==2.9.41']
|
||||
|
||||
ATTR_POWER = 'power'
|
||||
ATTR_CHARGING = 'charging'
|
||||
|
||||
Reference in new issue
Block a user