diff --git a/homeassistant/components/abode/__init__.py b/homeassistant/components/abode/__init__.py index 71a1dcdd590..591bae1a9cf 100644 --- a/homeassistant/components/abode/__init__.py +++ b/homeassistant/components/abode/__init__.py @@ -17,7 +17,8 @@ REQUIREMENTS = ['abodepy==0.15.0'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by goabode.com" +ATTRIBUTION = "Data provided by goabode.com" + CONF_POLLING = 'polling' DOMAIN = 'abode' @@ -280,7 +281,7 @@ class AbodeDevice(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'device_id': self._device.device_id, 'battery_low': self._device.battery_low, 'no_response': self._device.no_response, @@ -327,7 +328,7 @@ class AbodeAutomation(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'automation_id': self._automation.automation_id, 'type': self._automation.type, 'sub_type': self._automation.sub_type diff --git a/homeassistant/components/abode/alarm_control_panel.py b/homeassistant/components/abode/alarm_control_panel.py index ec5038a7a84..838d09b73af 100644 --- a/homeassistant/components/abode/alarm_control_panel.py +++ b/homeassistant/components/abode/alarm_control_panel.py @@ -2,7 +2,7 @@ import logging import homeassistant.components.alarm_control_panel as alarm -from homeassistant.components.abode import CONF_ATTRIBUTION, AbodeDevice +from homeassistant.components.abode import ATTRIBUTION, AbodeDevice from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN from homeassistant.const import ( ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, @@ -73,7 +73,7 @@ class AbodeAlarm(AbodeDevice, alarm.AlarmControlPanel): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'device_id': self._device.device_id, 'battery_backup': self._device.battery, 'cellular_backup': self._device.is_cellular, diff --git a/homeassistant/components/arlo/__init__.py b/homeassistant/components/arlo/__init__.py index 7e81836e522..cbb720778e5 100644 --- a/homeassistant/components/arlo/__init__.py +++ b/homeassistant/components/arlo/__init__.py @@ -15,7 +15,7 @@ REQUIREMENTS = ['pyarlo==0.2.3'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by arlo.netgear.com" +ATTRIBUTION = "Data provided by arlo.netgear.com" DATA_ARLO = 'data_arlo' DEFAULT_BRAND = 'Netgear Arlo' diff --git a/homeassistant/components/arlo/alarm_control_panel.py b/homeassistant/components/arlo/alarm_control_panel.py index 8c21a448a23..931dfa1b15d 100644 --- a/homeassistant/components/arlo/alarm_control_panel.py +++ b/homeassistant/components/arlo/alarm_control_panel.py @@ -9,7 +9,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.components.alarm_control_panel import ( AlarmControlPanel, PLATFORM_SCHEMA) from homeassistant.components.arlo import ( - DATA_ARLO, CONF_ATTRIBUTION, SIGNAL_UPDATE_ARLO) + DATA_ARLO, ATTRIBUTION, SIGNAL_UPDATE_ARLO) from homeassistant.const import ( ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_ARMED_NIGHT) @@ -117,7 +117,7 @@ class ArloBaseStation(AlarmControlPanel): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'device_id': self._base_station.device_id } diff --git a/homeassistant/components/arlo/sensor.py b/homeassistant/components/arlo/sensor.py index 3ad7b70a947..1c3cc933438 100644 --- a/homeassistant/components/arlo/sensor.py +++ b/homeassistant/components/arlo/sensor.py @@ -6,7 +6,7 @@ import voluptuous as vol from homeassistant.core import callback import homeassistant.helpers.config_validation as cv from homeassistant.components.arlo import ( - CONF_ATTRIBUTION, DEFAULT_BRAND, DATA_ARLO, SIGNAL_UPDATE_ARLO) + ATTRIBUTION, DEFAULT_BRAND, DATA_ARLO, SIGNAL_UPDATE_ARLO) from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS, TEMP_CELSIUS, @@ -177,7 +177,7 @@ class ArloSensor(Entity): """Return the device state attributes.""" attrs = {} - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION attrs['brand'] = DEFAULT_BRAND if self._sensor_type != 'total_cameras': diff --git a/homeassistant/components/binary_sensor/aurora.py b/homeassistant/components/binary_sensor/aurora.py index 04b402722b2..cfd683346ff 100644 --- a/homeassistant/components/binary_sensor/aurora.py +++ b/homeassistant/components/binary_sensor/aurora.py @@ -19,8 +19,8 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric" \ - "Administration" +ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric " \ + "Administration" CONF_THRESHOLD = 'forecast_threshold' DEFAULT_DEVICE_CLASS = 'visible' @@ -91,7 +91,7 @@ class AuroraSensor(BinarySensorDevice): if self.aurora_data: attrs['visibility_level'] = self.aurora_data.visibility_level attrs['message'] = self.aurora_data.is_visible_text - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION return attrs def update(self): diff --git a/homeassistant/components/binary_sensor/ring.py b/homeassistant/components/binary_sensor/ring.py index 5a65917f40b..79fc61a62d4 100644 --- a/homeassistant/components/binary_sensor/ring.py +++ b/homeassistant/components/binary_sensor/ring.py @@ -11,7 +11,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.ring import ( - CONF_ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING) + ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING) from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS) @@ -47,18 +47,14 @@ def setup_platform(hass, config, add_entities, discovery_info=None): for device in ring.doorbells: # ring.doorbells is doing I/O for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'doorbell' in SENSOR_TYPES[sensor_type][1]: - sensors.append(RingBinarySensor(hass, - device, - sensor_type)) + sensors.append(RingBinarySensor(hass, device, sensor_type)) for device in ring.stickup_cams: # ring.stickup_cams is doing I/O for sensor_type in config[CONF_MONITORED_CONDITIONS]: if 'stickup_cams' in SENSOR_TYPES[sensor_type][1]: - sensors.append(RingBinarySensor(hass, - device, - sensor_type)) + sensors.append(RingBinarySensor(hass, device, sensor_type)) + add_entities(sensors, True) - return True class RingBinarySensor(BinarySensorDevice): @@ -69,8 +65,8 @@ class RingBinarySensor(BinarySensorDevice): super(RingBinarySensor, self).__init__() self._sensor_type = sensor_type self._data = data - self._name = "{0} {1}".format(self._data.name, - SENSOR_TYPES.get(self._sensor_type)[0]) + self._name = "{0} {1}".format( + self._data.name, SENSOR_TYPES.get(self._sensor_type)[0]) self._device_class = SENSOR_TYPES.get(self._sensor_type)[2] self._state = None self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type) @@ -99,7 +95,7 @@ class RingBinarySensor(BinarySensorDevice): def device_state_attributes(self): """Return the state attributes.""" attrs = {} - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION attrs['device_id'] = self._data.id attrs['firmware'] = self._data.firmware diff --git a/homeassistant/components/binary_sensor/uptimerobot.py b/homeassistant/components/binary_sensor/uptimerobot.py index dbb83e53e9f..e48ac3039ae 100644 --- a/homeassistant/components/binary_sensor/uptimerobot.py +++ b/homeassistant/components/binary_sensor/uptimerobot.py @@ -19,7 +19,7 @@ _LOGGER = logging.getLogger(__name__) ATTR_TARGET = 'target' -CONF_ATTRIBUTION = "Data provided by Uptime Robot" +ATTRIBUTION = "Data provided by Uptime Robot" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, @@ -78,7 +78,7 @@ class UptimeRobotBinarySensor(BinarySensorDevice): def device_state_attributes(self): """Return the state attributes of the binary sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_TARGET: self._target, } diff --git a/homeassistant/components/camera/ring.py b/homeassistant/components/camera/ring.py index da1119281b3..ce9ceb7b76f 100644 --- a/homeassistant/components/camera/ring.py +++ b/homeassistant/components/camera/ring.py @@ -13,7 +13,7 @@ import voluptuous as vol from homeassistant.helpers import config_validation as cv from homeassistant.components.ring import ( - DATA_RING, CONF_ATTRIBUTION, NOTIFICATION_ID) + DATA_RING, ATTRIBUTION, NOTIFICATION_ID) from homeassistant.components.camera import Camera, PLATFORM_SCHEMA from homeassistant.components.ffmpeg import DATA_FFMPEG from homeassistant.const import ATTR_ATTRIBUTION, CONF_SCAN_INTERVAL @@ -34,8 +34,7 @@ SCAN_INTERVAL = timedelta(seconds=90) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string, - vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): - cv.time_period, + vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period, }) @@ -106,7 +105,7 @@ class RingCam(Camera): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'device_id': self._camera.id, 'firmware': self._camera.firmware, 'kind': self._camera.kind, diff --git a/homeassistant/components/digital_ocean/__init__.py b/homeassistant/components/digital_ocean/__init__.py index d061dad6726..7975a6eea0d 100644 --- a/homeassistant/components/digital_ocean/__init__.py +++ b/homeassistant/components/digital_ocean/__init__.py @@ -22,7 +22,8 @@ ATTR_MEMORY = 'memory' ATTR_REGION = 'region' ATTR_VCPUS = 'vcpus' -CONF_ATTRIBUTION = 'Data provided by Digital Ocean' +ATTRIBUTION = 'Data provided by Digital Ocean' + CONF_DROPLETS = 'droplets' DATA_DIGITAL_OCEAN = 'data_do' diff --git a/homeassistant/components/digital_ocean/binary_sensor.py b/homeassistant/components/digital_ocean/binary_sensor.py index 255f43b67ba..88df56cc629 100644 --- a/homeassistant/components/digital_ocean/binary_sensor.py +++ b/homeassistant/components/digital_ocean/binary_sensor.py @@ -9,7 +9,7 @@ from homeassistant.components.binary_sensor import ( from homeassistant.components.digital_ocean import ( CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME, ATTR_FEATURES, ATTR_IPV4_ADDRESS, ATTR_IPV6_ADDRESS, ATTR_MEMORY, - ATTR_REGION, ATTR_VCPUS, CONF_ATTRIBUTION, DATA_DIGITAL_OCEAN) + ATTR_REGION, ATTR_VCPUS, ATTRIBUTION, DATA_DIGITAL_OCEAN) from homeassistant.const import ATTR_ATTRIBUTION _LOGGER = logging.getLogger(__name__) @@ -71,7 +71,7 @@ class DigitalOceanBinarySensor(BinarySensorDevice): def device_state_attributes(self): """Return the state attributes of the Digital Ocean droplet.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CREATED_AT: self.data.created_at, ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_NAME: self.data.name, diff --git a/homeassistant/components/digital_ocean/switch.py b/homeassistant/components/digital_ocean/switch.py index a10c961b8e4..9b5ddda3408 100644 --- a/homeassistant/components/digital_ocean/switch.py +++ b/homeassistant/components/digital_ocean/switch.py @@ -8,7 +8,7 @@ from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.components.digital_ocean import ( CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME, ATTR_FEATURES, ATTR_IPV4_ADDRESS, ATTR_IPV6_ADDRESS, ATTR_MEMORY, - ATTR_REGION, ATTR_VCPUS, CONF_ATTRIBUTION, DATA_DIGITAL_OCEAN) + ATTR_REGION, ATTR_VCPUS, ATTRIBUTION, DATA_DIGITAL_OCEAN) from homeassistant.const import ATTR_ATTRIBUTION _LOGGER = logging.getLogger(__name__) @@ -65,7 +65,7 @@ class DigitalOceanSwitch(SwitchDevice): def device_state_attributes(self): """Return the state attributes of the Digital Ocean droplet.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CREATED_AT: self.data.created_at, ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_NAME: self.data.name, diff --git a/homeassistant/components/hydrawise/__init__.py b/homeassistant/components/hydrawise/__init__.py index 800d19d7efe..9c7baf6db2e 100644 --- a/homeassistant/components/hydrawise/__init__.py +++ b/homeassistant/components/hydrawise/__init__.py @@ -20,7 +20,8 @@ _LOGGER = logging.getLogger(__name__) ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60] -CONF_ATTRIBUTION = "Data provided by hydrawise.com" +ATTRIBUTION = "Data provided by hydrawise.com" + CONF_WATERING_TIME = 'watering_minutes' NOTIFICATION_ID = 'hydrawise_notification' @@ -141,6 +142,6 @@ class HydrawiseEntity(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'identifier': self.data.get('relay'), } diff --git a/homeassistant/components/logi_circle/__init__.py b/homeassistant/components/logi_circle/__init__.py index 50500f47e42..ef006ef8b4d 100644 --- a/homeassistant/components/logi_circle/__init__.py +++ b/homeassistant/components/logi_circle/__init__.py @@ -1,19 +1,19 @@ """Support for Logi Circle devices.""" -import logging import asyncio +import logging -import voluptuous as vol import async_timeout +import voluptuous as vol +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME import homeassistant.helpers.config_validation as cv -from homeassistant.const import CONF_USERNAME, CONF_PASSWORD REQUIREMENTS = ['logi_circle==0.1.7'] _LOGGER = logging.getLogger(__name__) _TIMEOUT = 15 # seconds -CONF_ATTRIBUTION = "Data provided by circle.logi.com" +ATTRIBUTION = "Data provided by circle.logi.com" NOTIFICATION_ID = 'logi_notification' NOTIFICATION_TITLE = 'Logi Circle Setup' diff --git a/homeassistant/components/logi_circle/camera.py b/homeassistant/components/logi_circle/camera.py index 51bd7c124a3..4f349dd986e 100644 --- a/homeassistant/components/logi_circle/camera.py +++ b/homeassistant/components/logi_circle/camera.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.helpers import config_validation as cv from homeassistant.components.logi_circle import ( - DOMAIN as LOGI_CIRCLE_DOMAIN, CONF_ATTRIBUTION) + DOMAIN as LOGI_CIRCLE_DOMAIN, ATTRIBUTION) from homeassistant.components.camera import ( Camera, PLATFORM_SCHEMA, CAMERA_SERVICE_SCHEMA, SUPPORT_ON_OFF, ATTR_ENTITY_ID, ATTR_FILENAME, DOMAIN) @@ -128,7 +128,7 @@ class LogiCam(Camera): def device_state_attributes(self): """Return the state attributes.""" state = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'battery_saving_mode': ( STATE_ON if self._camera.battery_saving else STATE_OFF), 'ip_address': self._camera.ip_address, diff --git a/homeassistant/components/logi_circle/sensor.py b/homeassistant/components/logi_circle/sensor.py index 74c2039c120..4830219091c 100644 --- a/homeassistant/components/logi_circle/sensor.py +++ b/homeassistant/components/logi_circle/sensor.py @@ -5,7 +5,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.logi_circle import ( - CONF_ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DOMAIN as LOGI_CIRCLE_DOMAIN) + ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DOMAIN as LOGI_CIRCLE_DOMAIN) from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( ATTR_ATTRIBUTION, ATTR_BATTERY_CHARGING, @@ -86,7 +86,7 @@ class LogiSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" state = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'battery_saving_mode': ( STATE_ON if self._camera.battery_saving else STATE_OFF), 'ip_address': self._camera.ip_address, diff --git a/homeassistant/components/raincloud/__init__.py b/homeassistant/components/raincloud/__init__.py index 47f6176d5f8..7ccf9f33ada 100644 --- a/homeassistant/components/raincloud/__init__.py +++ b/homeassistant/components/raincloud/__init__.py @@ -24,7 +24,8 @@ _LOGGER = logging.getLogger(__name__) ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60] -CONF_ATTRIBUTION = "Data provided by Melnor Aquatimer.com" +ATTRIBUTION = "Data provided by Melnor Aquatimer.com" + CONF_WATERING_TIME = 'watering_minutes' NOTIFICATION_ID = 'raincloud_notification' @@ -165,7 +166,7 @@ class RainCloudEntity(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'identifier': self.data.serial, } diff --git a/homeassistant/components/raincloud/switch.py b/homeassistant/components/raincloud/switch.py index 969169edc64..1b76e8974b0 100644 --- a/homeassistant/components/raincloud/switch.py +++ b/homeassistant/components/raincloud/switch.py @@ -1,16 +1,11 @@ -""" -Support for Melnor RainCloud sprinkler water timer. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/switch.raincloud/ -""" +"""Support for Melnor RainCloud sprinkler water timer.""" import logging import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.raincloud import ( - ALLOWED_WATERING_TIME, CONF_ATTRIBUTION, CONF_WATERING_TIME, + ALLOWED_WATERING_TIME, ATTRIBUTION, CONF_WATERING_TIME, DATA_RAINCLOUD, DEFAULT_WATERING_TIME, RainCloudEntity, SWITCHES) from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA from homeassistant.const import ( @@ -38,12 +33,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None): # create a sensor for each zone managed by faucet for zone in raincloud.controller.faucet.zones: sensors.append( - RainCloudSwitch(default_watering_timer, - zone, - sensor_type)) + RainCloudSwitch(default_watering_timer, zone, sensor_type)) add_entities(sensors, True) - return True class RainCloudSwitch(RainCloudEntity, SwitchDevice): @@ -87,7 +79,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchDevice): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'default_manual_timer': self._default_watering_timer, 'identifier': self.data.serial } diff --git a/homeassistant/components/ring/__init__.py b/homeassistant/components/ring/__init__.py index 526388a0918..94f3be305fa 100644 --- a/homeassistant/components/ring/__init__.py +++ b/homeassistant/components/ring/__init__.py @@ -1,17 +1,17 @@ """Support for Ring Doorbell/Chimes.""" import logging -from requests.exceptions import HTTPError, ConnectTimeout +from requests.exceptions import ConnectTimeout, HTTPError import voluptuous as vol +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME import homeassistant.helpers.config_validation as cv -from homeassistant.const import CONF_USERNAME, CONF_PASSWORD REQUIREMENTS = ['ring_doorbell==0.2.2'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by Ring.com" +ATTRIBUTION = "Data provided by Ring.com" NOTIFICATION_ID = 'ring_notification' NOTIFICATION_TITLE = 'Ring Setup' diff --git a/homeassistant/components/sensor/alpha_vantage.py b/homeassistant/components/sensor/alpha_vantage.py index 79943a8b084..774a3fe95f6 100644 --- a/homeassistant/components/sensor/alpha_vantage.py +++ b/homeassistant/components/sensor/alpha_vantage.py @@ -23,7 +23,8 @@ ATTR_CLOSE = 'close' ATTR_HIGH = 'high' ATTR_LOW = 'low' -CONF_ATTRIBUTION = "Stock market information provided by Alpha Vantage" +ATTRIBUTION = "Stock market information provided by Alpha Vantage" + CONF_FOREIGN_EXCHANGE = 'foreign_exchange' CONF_FROM = 'from' CONF_SYMBOL = 'symbol' @@ -143,7 +144,7 @@ class AlphaVantageSensor(Entity): """Return the state attributes.""" if self.values is not None: return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CLOSE: self.values['4. close'], ATTR_HIGH: self.values['2. high'], ATTR_LOW: self.values['3. low'], @@ -203,7 +204,7 @@ class AlphaVantageForeignExchange(Entity): """Return the state attributes.""" if self.values is not None: return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, CONF_FROM: self._from_currency, CONF_TO: self._to_currency, } diff --git a/homeassistant/components/sensor/bitcoin.py b/homeassistant/components/sensor/bitcoin.py index 34855d19104..e654f29f42a 100644 --- a/homeassistant/components/sensor/bitcoin.py +++ b/homeassistant/components/sensor/bitcoin.py @@ -19,7 +19,7 @@ REQUIREMENTS = ['blockchain==1.4.4'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by blockchain.info" +ATTRIBUTION = "Data provided by blockchain.info" DEFAULT_CURRENCY = 'USD' @@ -112,7 +112,7 @@ class BitcoinSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/blockchain.py b/homeassistant/components/sensor/blockchain.py index e51db7edcad..241c98d2328 100644 --- a/homeassistant/components/sensor/blockchain.py +++ b/homeassistant/components/sensor/blockchain.py @@ -18,8 +18,9 @@ REQUIREMENTS = ['python-blockchain-api==0.0.2'] _LOGGER = logging.getLogger(__name__) +ATTRIBUTION = "Data provided by blockchain.info" + CONF_ADDRESSES = 'addresses' -CONF_ATTRIBUTION = "Data provided by blockchain.info" DEFAULT_NAME = 'Bitcoin Balance' @@ -82,7 +83,7 @@ class BlockchainSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/bom.py b/homeassistant/components/sensor/bom.py index df8b5391359..62a3706034a 100644 --- a/homeassistant/components/sensor/bom.py +++ b/homeassistant/components/sensor/bom.py @@ -34,7 +34,8 @@ ATTR_STATION_ID = 'station_id' ATTR_STATION_NAME = 'station_name' ATTR_ZONE_ID = 'zone_id' -CONF_ATTRIBUTION = "Data provided by the Australian Bureau of Meteorology" +ATTRIBUTION = "Data provided by the Australian Bureau of Meteorology" + CONF_STATION = 'station' CONF_ZONE_ID = 'zone_id' CONF_WMO_ID = 'wmo_id' @@ -158,7 +159,7 @@ class BOMCurrentSensor(Entity): def device_state_attributes(self): """Return the state attributes of the device.""" attr = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_LAST_UPDATE: self.bom_data.last_updated, ATTR_SENSOR_ID: self._condition, ATTR_STATION_ID: self.bom_data.latest_data['wmo'], diff --git a/homeassistant/components/sensor/coinbase.py b/homeassistant/components/sensor/coinbase.py index d25b7b786f8..54af94944d6 100644 --- a/homeassistant/components/sensor/coinbase.py +++ b/homeassistant/components/sensor/coinbase.py @@ -16,9 +16,10 @@ CURRENCY_ICONS = { 'LTC': 'mdi:litecoin', 'USD': 'mdi:currency-usd' } + DEFAULT_COIN_ICON = 'mdi:coin' -CONF_ATTRIBUTION = "Data provided by coinbase.com" +ATTRIBUTION = "Data provided by coinbase.com" DATA_COINBASE = 'coinbase_cache' DEPENDENCIES = ['coinbase'] @@ -77,7 +78,7 @@ class AccountSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_NATIVE_BALANCE: "{} {}".format( self._native_balance, self._native_currency), } @@ -127,7 +128,7 @@ class ExchangeRateSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION + ATTR_ATTRIBUTION: ATTRIBUTION } def update(self): diff --git a/homeassistant/components/sensor/coinmarketcap.py b/homeassistant/components/sensor/coinmarketcap.py index 18d3f0a3d00..9143405a553 100644 --- a/homeassistant/components/sensor/coinmarketcap.py +++ b/homeassistant/components/sensor/coinmarketcap.py @@ -32,7 +32,8 @@ ATTR_RANK = 'rank' ATTR_SYMBOL = 'symbol' ATTR_TOTAL_SUPPLY = 'total_supply' -CONF_ATTRIBUTION = "Data provided by CoinMarketCap" +ATTRIBUTION = "Data provided by CoinMarketCap" + CONF_CURRENCY_ID = 'currency_id' CONF_DISPLAY_CURRENCY_DECIMALS = 'display_currency_decimals' @@ -115,7 +116,7 @@ class CoinMarketCapSensor(Entity): ATTR_VOLUME_24H: self._ticker.get('quotes').get(self.data.display_currency) .get('volume_24h'), - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_CIRCULATING_SUPPLY: self._ticker.get('circulating_supply'), ATTR_MARKET_CAP: self._ticker.get('quotes').get(self.data.display_currency) diff --git a/homeassistant/components/sensor/comed_hourly_pricing.py b/homeassistant/components/sensor/comed_hourly_pricing.py index 12b8e917f9d..1771fd0f1a3 100644 --- a/homeassistant/components/sensor/comed_hourly_pricing.py +++ b/homeassistant/components/sensor/comed_hourly_pricing.py @@ -25,7 +25,8 @@ _RESOURCE = 'https://hourlypricing.comed.com/api' SCAN_INTERVAL = timedelta(minutes=5) -CONF_ATTRIBUTION = "Data provided by ComEd Hourly Pricing service" +ATTRIBUTION = "Data provided by ComEd Hourly Pricing service" + CONF_CURRENT_HOUR_AVERAGE = 'current_hour_average' CONF_FIVE_MINUTE = 'five_minute' CONF_MONITORED_FEEDS = 'monitored_feeds' @@ -97,8 +98,7 @@ class ComedHourlyPricingSensor(Entity): @property def device_state_attributes(self): """Return the state attributes.""" - attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} - return attrs + return {ATTR_ATTRIBUTION: ATTRIBUTION} async def async_update(self): """Get the ComEd Hourly Pricing data from the web service.""" diff --git a/homeassistant/components/sensor/currencylayer.py b/homeassistant/components/sensor/currencylayer.py index 67c9c7bbf19..bbc63633c51 100644 --- a/homeassistant/components/sensor/currencylayer.py +++ b/homeassistant/components/sensor/currencylayer.py @@ -19,7 +19,7 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) _RESOURCE = 'http://apilayer.net/api/live' -CONF_ATTRIBUTION = "Data provided by currencylayer.com" +ATTRIBUTION = "Data provided by currencylayer.com" DEFAULT_BASE = 'USD' DEFAULT_NAME = 'CurrencyLayer Sensor' @@ -91,7 +91,7 @@ class CurrencylayerSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/discogs.py b/homeassistant/components/sensor/discogs.py index 70d7155fec7..c62cd3e759c 100644 --- a/homeassistant/components/sensor/discogs.py +++ b/homeassistant/components/sensor/discogs.py @@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__) ATTR_IDENTITY = 'identity' -CONF_ATTRIBUTION = "Data provided by Discogs" +ATTRIBUTION = "Data provided by Discogs" DEFAULT_NAME = 'Discogs' @@ -86,7 +86,7 @@ class DiscogsSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_IDENTITY: self._identity.name, } diff --git a/homeassistant/components/sensor/dublin_bus_transport.py b/homeassistant/components/sensor/dublin_bus_transport.py index 02527f1e333..7a70d7af3a7 100644 --- a/homeassistant/components/sensor/dublin_bus_transport.py +++ b/homeassistant/components/sensor/dublin_bus_transport.py @@ -28,7 +28,8 @@ ATTR_DUE_IN = 'Due in' ATTR_DUE_AT = 'Due at' ATTR_NEXT_UP = 'Later Bus' -CONF_ATTRIBUTION = "Data provided by data.dublinked.ie" +ATTRIBUTION = "Data provided by data.dublinked.ie" + CONF_STOP_ID = 'stopid' CONF_ROUTE = 'route' @@ -101,7 +102,7 @@ class DublinPublicTransportSensor(Entity): ATTR_DUE_AT: self._times[0][ATTR_DUE_AT], ATTR_STOP_ID: self._stop, ATTR_ROUTE: self._times[0][ATTR_ROUTE], - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_NEXT_UP: next_up } diff --git a/homeassistant/components/sensor/entur_public_transport.py b/homeassistant/components/sensor/entur_public_transport.py index 64884764523..330f5f8cc56 100644 --- a/homeassistant/components/sensor/entur_public_transport.py +++ b/homeassistant/components/sensor/entur_public_transport.py @@ -26,7 +26,8 @@ ATTR_NEXT_UP_IN = 'next_due_in' API_CLIENT_NAME = 'homeassistant-homeassistant' -CONF_ATTRIBUTION = "Data provided by entur.org under NLOD." +ATTRIBUTION = "Data provided by entur.org under NLOD" + CONF_STOP_IDS = 'stop_ids' CONF_EXPAND_PLATFORMS = 'expand_platforms' CONF_WHITELIST_LINES = 'line_whitelist' @@ -140,7 +141,7 @@ class EnturPublicTransportSensor(Entity): self._state = None self._icon = ICONS[DEFAULT_ICON_KEY] self._attributes = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_STOP_ID: self._stop, } diff --git a/homeassistant/components/sensor/etherscan.py b/homeassistant/components/sensor/etherscan.py index 24cf046cca0..3b76d888e26 100644 --- a/homeassistant/components/sensor/etherscan.py +++ b/homeassistant/components/sensor/etherscan.py @@ -15,10 +15,11 @@ from homeassistant.helpers.entity import Entity REQUIREMENTS = ['python-etherscan-api==0.0.3'] +ATTRIBUTION = "Data provided by etherscan.io" + CONF_ADDRESS = 'address' CONF_TOKEN = 'token' CONF_TOKEN_ADDRESS = 'token_address' -CONF_ATTRIBUTION = "Data provided by etherscan.io" SCAN_INTERVAL = timedelta(minutes=5) @@ -77,9 +78,7 @@ class EtherscanSensor(Entity): @property def device_state_attributes(self): """Return the state attributes of the sensor.""" - return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, - } + return {ATTR_ATTRIBUTION: ATTRIBUTION} def update(self): """Get the latest state of the sensor.""" diff --git a/homeassistant/components/sensor/fitbit.py b/homeassistant/components/sensor/fitbit.py index f5b44d577a7..d5d9150e4e8 100644 --- a/homeassistant/components/sensor/fitbit.py +++ b/homeassistant/components/sensor/fitbit.py @@ -35,7 +35,7 @@ ATTR_LAST_SAVED_AT = 'last_saved_at' CONF_MONITORED_RESOURCES = 'monitored_resources' CONF_CLOCK_FORMAT = 'clock_format' -CONF_ATTRIBUTION = 'Data provided by Fitbit.com' +ATTRIBUTION = 'Data provided by Fitbit.com' DEPENDENCIES = ['http'] @@ -423,8 +423,8 @@ class FitbitSensor(Entity): """Icon to use in the frontend, if any.""" if self.resource_type == 'devices/battery' and self.extra: battery_level = BATTERY_LEVELS[self.extra.get('battery')] - return icon_for_battery_level(battery_level=battery_level, - charging=None) + return icon_for_battery_level( + battery_level=battery_level, charging=None) return 'mdi:{}'.format(FITBIT_RESOURCES_LIST[self.resource_type][2]) @property @@ -432,7 +432,7 @@ class FitbitSensor(Entity): """Return the state attributes.""" attrs = {} - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION if self.extra: attrs['model'] = self.extra.get('deviceVersion') diff --git a/homeassistant/components/sensor/fixer.py b/homeassistant/components/sensor/fixer.py index 1bdd9e71272..c46fa751319 100644 --- a/homeassistant/components/sensor/fixer.py +++ b/homeassistant/components/sensor/fixer.py @@ -20,8 +20,8 @@ _LOGGER = logging.getLogger(__name__) ATTR_EXCHANGE_RATE = 'Exchange rate' ATTR_TARGET = 'Target currency' +ATTRIBUTION = "Data provided by the European Central Bank (ECB)" -CONF_ATTRIBUTION = "Data provided by the European Central Bank (ECB)" CONF_TARGET = 'target' DEFAULT_BASE = 'USD' @@ -86,7 +86,7 @@ class ExchangeRateSensor(Entity): """Return the state attributes.""" if self.data.rate is not None: return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target], ATTR_TARGET: self._target, } diff --git a/homeassistant/components/sensor/gitlab_ci.py b/homeassistant/components/sensor/gitlab_ci.py index 1e55a7d6997..7f3b444bb75 100644 --- a/homeassistant/components/sensor/gitlab_ci.py +++ b/homeassistant/components/sensor/gitlab_ci.py @@ -28,8 +28,8 @@ ATTR_BUILD_FINISHED = 'build_finished' ATTR_BUILD_ID = 'build id' ATTR_BUILD_STARTED = 'build_started' ATTR_BUILD_STATUS = 'build_status' +ATTRIBUTION = "Information provided by https://gitlab.com/" -CONF_ATTRIBUTION = "Information provided by https://gitlab.com/" CONF_GITLAB_ID = 'gitlab_id' DEFAULT_NAME = 'GitLab CI Status' @@ -101,7 +101,7 @@ class GitLabSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_BUILD_STATUS: self._state, ATTR_BUILD_STARTED: self._started_at, ATTR_BUILD_FINISHED: self._finished_at, diff --git a/homeassistant/components/sensor/haveibeenpwned.py b/homeassistant/components/sensor/haveibeenpwned.py index 4d651ea81c7..a4ae2349e24 100644 --- a/homeassistant/components/sensor/haveibeenpwned.py +++ b/homeassistant/components/sensor/haveibeenpwned.py @@ -12,7 +12,7 @@ import requests import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_EMAIL +from homeassistant.const import CONF_EMAIL, ATTR_ATTRIBUTION import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import track_point_in_time @@ -21,6 +21,8 @@ import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) +ATTRIBUTION = "Data provided by Have I Been Pwned (HIBP)" + DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S" HA_USER_AGENT = "Home Assistant HaveIBeenPwned Sensor Component" @@ -75,7 +77,7 @@ class HaveIBeenPwnedSensor(Entity): @property def device_state_attributes(self): """Return the attributes of the sensor.""" - val = {} + val = {ATTR_ATTRIBUTION: ATTRIBUTION} if self._email not in self._data.data: return val diff --git a/homeassistant/components/sensor/iperf3.py b/homeassistant/components/sensor/iperf3.py index 0eb6dfaa00c..32127c79a91 100644 --- a/homeassistant/components/sensor/iperf3.py +++ b/homeassistant/components/sensor/iperf3.py @@ -25,7 +25,8 @@ ATTR_REMOTE_HOST = 'Remote Server' ATTR_REMOTE_PORT = 'Remote Port' ATTR_VERSION = 'Version' -CONF_ATTRIBUTION = 'Data retrieved using Iperf3' +ATTRIBUTION = 'Data retrieved using Iperf3' + CONF_DURATION = 'duration' CONF_PARALLEL = 'parallel' @@ -106,11 +107,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None): class Iperf3Sensor(Entity): """A Iperf3 sensor implementation.""" - def __init__(self, server, port, duration, streams, - protocol, sensor_type): + def __init__(self, server, port, duration, streams, protocol, sensor_type): """Initialize the sensor.""" self._attrs = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_PROTOCOL: protocol, } self._name = \ @@ -144,7 +144,7 @@ class Iperf3Sensor(Entity): def device_state_attributes(self): """Return the state attributes.""" if self.result is not None: - self._attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + self._attrs[ATTR_ATTRIBUTION] = ATTRIBUTION self._attrs[ATTR_REMOTE_HOST] = self.result.remote_host self._attrs[ATTR_REMOTE_PORT] = self.result.remote_port self._attrs[ATTR_VERSION] = self.result.version diff --git a/homeassistant/components/sensor/irish_rail_transport.py b/homeassistant/components/sensor/irish_rail_transport.py index 10f4004ae74..e17ecfde59d 100644 --- a/homeassistant/components/sensor/irish_rail_transport.py +++ b/homeassistant/components/sensor/irish_rail_transport.py @@ -1,9 +1,4 @@ -""" -Support for Irish Rail RTPI information. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/sensor.irish_rail_transport/ -""" +"""Support for Irish Rail RTPI information.""" import logging from datetime import timedelta @@ -11,7 +6,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_NAME +from homeassistant.const import CONF_NAME, ATTR_ATTRIBUTION from homeassistant.helpers.entity import Entity REQUIREMENTS = ['pyirishrail==0.0.2'] @@ -28,6 +23,7 @@ ATTR_DUE_AT = "Due at" ATTR_EXPECT_AT = "Expected at" ATTR_NEXT_UP = "Later Train" ATTR_TRAIN_TYPE = "Train type" +ATTRIBUTION = "Data provided by Irish Rail" CONF_STATION = 'station' CONF_DESTINATION = 'destination' @@ -100,6 +96,7 @@ class IrishRailTransportSensor(Entity): next_up += self._times[1][ATTR_DUE_IN] return { + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_STATION: self._station, ATTR_ORIGIN: self._times[0][ATTR_ORIGIN], ATTR_DESTINATION: self._times[0][ATTR_DESTINATION], @@ -109,7 +106,7 @@ class IrishRailTransportSensor(Entity): ATTR_DIRECTION: self._times[0][ATTR_DIRECTION], ATTR_STOPS_AT: self._times[0][ATTR_STOPS_AT], ATTR_NEXT_UP: next_up, - ATTR_TRAIN_TYPE: self._times[0][ATTR_TRAIN_TYPE] + ATTR_TRAIN_TYPE: self._times[0][ATTR_TRAIN_TYPE], } @property @@ -146,22 +143,23 @@ class IrishRailTransportData: def update(self): """Get the latest data from irishrail.""" - trains = self._ir_api.get_station_by_name(self.station, - direction=self.direction, - destination=self.destination, - stops_at=self.stops_at) + trains = self._ir_api.get_station_by_name( + self.station, direction=self.direction, + destination=self.destination, stops_at=self.stops_at) stops_at = self.stops_at if self.stops_at else '' self.info = [] for train in trains: - train_data = {ATTR_STATION: self.station, - ATTR_ORIGIN: train.get('origin'), - ATTR_DESTINATION: train.get('destination'), - ATTR_DUE_IN: train.get('due_in_mins'), - ATTR_DUE_AT: train.get('scheduled_arrival_time'), - ATTR_EXPECT_AT: train.get('expected_departure_time'), - ATTR_DIRECTION: train.get('direction'), - ATTR_STOPS_AT: stops_at, - ATTR_TRAIN_TYPE: train.get('type')} + train_data = { + ATTR_STATION: self.station, + ATTR_ORIGIN: train.get('origin'), + ATTR_DESTINATION: train.get('destination'), + ATTR_DUE_IN: train.get('due_in_mins'), + ATTR_DUE_AT: train.get('scheduled_arrival_time'), + ATTR_EXPECT_AT: train.get('expected_departure_time'), + ATTR_DIRECTION: train.get('direction'), + ATTR_STOPS_AT: stops_at, + ATTR_TRAIN_TYPE: train.get('type'), + } self.info.append(train_data) if not self.info: @@ -180,4 +178,5 @@ class IrishRailTransportData: ATTR_EXPECT_AT: 'n/a', ATTR_DIRECTION: direction, ATTR_STOPS_AT: stops_at, - ATTR_TRAIN_TYPE: ''}] + ATTR_TRAIN_TYPE: '', + }] diff --git a/homeassistant/components/sensor/lastfm.py b/homeassistant/components/sensor/lastfm.py index fa69a916495..bb5a09771c2 100644 --- a/homeassistant/components/sensor/lastfm.py +++ b/homeassistant/components/sensor/lastfm.py @@ -1,16 +1,11 @@ -""" -Sensor for Last.fm account status. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/sensor.lastfm/ -""" +"""Sensor for Last.fm account status.""" import logging import re import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -from homeassistant.const import CONF_API_KEY +from homeassistant.const import CONF_API_KEY, ATTR_ATTRIBUTION import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity @@ -21,6 +16,7 @@ _LOGGER = logging.getLogger(__name__) ATTR_LAST_PLAYED = 'last_played' ATTR_PLAY_COUNT = 'play_count' ATTR_TOP_PLAYED = 'top_played' +ATTRIBUTION = "Data provided by Last.fm" CONF_USERS = 'users' @@ -105,6 +101,7 @@ class LastfmSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_LAST_PLAYED: self._lastplayed, ATTR_PLAY_COUNT: self._playcount, ATTR_TOP_PLAYED: self._topplayed, diff --git a/homeassistant/components/sensor/london_underground.py b/homeassistant/components/sensor/london_underground.py index d44806cf481..1c93d6a1bcb 100644 --- a/homeassistant/components/sensor/london_underground.py +++ b/homeassistant/components/sensor/london_underground.py @@ -18,8 +18,11 @@ REQUIREMENTS = ['london-tube-status==0.2'] _LOGGER = logging.getLogger(__name__) ATTRIBUTION = "Powered by TfL Open Data" + CONF_LINE = 'line' + SCAN_INTERVAL = timedelta(seconds=30) + TUBE_LINES = [ 'Bakerloo', 'Central', @@ -34,7 +37,8 @@ TUBE_LINES = [ 'Piccadilly', 'TfL Rail', 'Victoria', - 'Waterloo & City'] + 'Waterloo & City', +] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_LINE): diff --git a/homeassistant/components/sensor/metoffice.py b/homeassistant/components/sensor/metoffice.py index 8cebecb7124..3d9c9485da3 100644 --- a/homeassistant/components/sensor/metoffice.py +++ b/homeassistant/components/sensor/metoffice.py @@ -26,7 +26,7 @@ ATTR_SENSOR_ID = 'sensor_id' ATTR_SITE_ID = 'site_id' ATTR_SITE_NAME = 'site_name' -CONF_ATTRIBUTION = "Data provided by the Met Office" +ATTRIBUTION = "Data provided by the Met Office" CONDITION_CLASSES = { 'cloudy': ['7', '8'], @@ -162,7 +162,7 @@ class MetOfficeCurrentSensor(Entity): def device_state_attributes(self): """Return the state attributes of the device.""" attr = {} - attr[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attr[ATTR_ATTRIBUTION] = ATTRIBUTION attr[ATTR_LAST_UPDATE] = self.data.data.date attr[ATTR_SENSOR_ID] = self._condition attr[ATTR_SITE_ID] = self.site.id diff --git a/homeassistant/components/sensor/nederlandse_spoorwegen.py b/homeassistant/components/sensor/nederlandse_spoorwegen.py index 81cfada25f6..5d9376ad9eb 100644 --- a/homeassistant/components/sensor/nederlandse_spoorwegen.py +++ b/homeassistant/components/sensor/nederlandse_spoorwegen.py @@ -21,7 +21,8 @@ REQUIREMENTS = ['nsapi==2.7.4'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by NS" +ATTRIBUTION = "Data provided by NS" + CONF_ROUTES = 'routes' CONF_FROM = 'from' CONF_TO = 'to' @@ -155,7 +156,7 @@ class NSDepartureSensor(Entity): 'transfers': self._trips[0].nr_transfers, 'route': route, 'remarks': [r.message for r in self._trips[0].trip_remarks], - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } @Throttle(MIN_TIME_BETWEEN_UPDATES) diff --git a/homeassistant/components/sensor/nsw_fuel_station.py b/homeassistant/components/sensor/nsw_fuel_station.py index 60ad83a82f2..f0da619a6e7 100644 --- a/homeassistant/components/sensor/nsw_fuel_station.py +++ b/homeassistant/components/sensor/nsw_fuel_station.py @@ -28,7 +28,8 @@ CONF_FUEL_TYPES = 'fuel_types' CONF_ALLOWED_FUEL_TYPES = ["E10", "U91", "E85", "P95", "P98", "DL", "PDL", "B20", "LPG", "CNG", "EV"] CONF_DEFAULT_FUEL_TYPES = ["E10", "U91"] -CONF_ATTRIBUTION = "Data provided by NSW Government FuelCheck" + +ATTRIBUTION = "Data provided by NSW Government FuelCheck" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_STATION_ID): cv.positive_int, @@ -161,7 +162,7 @@ class StationPriceSensor(Entity): return { ATTR_STATION_ID: self._station_data.station_id, ATTR_STATION_NAME: self._station_data.get_station_name(), - ATTR_ATTRIBUTION: CONF_ATTRIBUTION + ATTR_ATTRIBUTION: ATTRIBUTION } @property diff --git a/homeassistant/components/sensor/openexchangerates.py b/homeassistant/components/sensor/openexchangerates.py index 01c84c63034..6361b823dea 100644 --- a/homeassistant/components/sensor/openexchangerates.py +++ b/homeassistant/components/sensor/openexchangerates.py @@ -20,7 +20,7 @@ from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) _RESOURCE = 'https://openexchangerates.org/api/latest.json' -CONF_ATTRIBUTION = "Data provided by openexchangerates.org" +ATTRIBUTION = "Data provided by openexchangerates.org" DEFAULT_BASE = 'USD' DEFAULT_NAME = 'Exchange Rate Sensor' @@ -82,7 +82,7 @@ class OpenexchangeratesSensor(Entity): def device_state_attributes(self): """Return other attributes of the sensor.""" attr = self.rest.data - attr[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attr[ATTR_ATTRIBUTION] = ATTRIBUTION return attr diff --git a/homeassistant/components/sensor/openweathermap.py b/homeassistant/components/sensor/openweathermap.py index b6a4ff0860e..a137836138b 100644 --- a/homeassistant/components/sensor/openweathermap.py +++ b/homeassistant/components/sensor/openweathermap.py @@ -21,7 +21,8 @@ REQUIREMENTS = ['pyowm==2.10.0'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by OpenWeatherMap" +ATTRIBUTION = "Data provided by OpenWeatherMap" + CONF_FORECAST = 'forecast' CONF_LANGUAGE = 'language' @@ -121,7 +122,7 @@ class OpenWeatherMapSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/rejseplanen.py b/homeassistant/components/sensor/rejseplanen.py index bade1bd6315..7a8cddb6179 100755 --- a/homeassistant/components/sensor/rejseplanen.py +++ b/homeassistant/components/sensor/rejseplanen.py @@ -31,7 +31,8 @@ ATTR_DUE_IN = 'Due in' ATTR_DUE_AT = 'Due at' ATTR_NEXT_UP = 'Later departure' -CONF_ATTRIBUTION = "Data provided by rejseplanen.dk" +ATTRIBUTION = "Data provided by rejseplanen.dk" + CONF_STOP_ID = 'stop_id' CONF_ROUTE = 'route' CONF_DIRECTION = 'direction' @@ -50,8 +51,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_DIRECTION, default=[]): vol.All(cv.ensure_list, [cv.string]), vol.Optional(CONF_DEPARTURE_TYPE, default=[]): - vol.All(cv.ensure_list, [vol.In(list(['BUS', 'EXB', 'M', - 'S', 'REG']))]) + vol.All(cv.ensure_list, + [vol.In(list(['BUS', 'EXB', 'M', 'S', 'REG']))]) }) @@ -75,12 +76,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): departure_type = config[CONF_DEPARTURE_TYPE] data = PublicTransportData(stop_id, route, direction, departure_type) - add_devices([RejseplanenTransportSensor(data, - stop_id, - route, - direction, - name)], - True) + add_devices([RejseplanenTransportSensor( + data, stop_id, route, direction, name)], True) class RejseplanenTransportSensor(Entity): @@ -111,13 +108,11 @@ class RejseplanenTransportSensor(Entity): if self._times is not None: next_up = None if len(self._times) > 1: - next_up = ('{} towards ' - '{} in ' - '{} from ' - '{}'.format(self._times[1][ATTR_ROUTE], - self._times[1][ATTR_DIRECTION], - str(self._times[1][ATTR_DUE_IN]), - self._times[1][ATTR_STOP_NAME])) + next_up = ('{} towards {} in {} from {}'.format( + self._times[1][ATTR_ROUTE], + self._times[1][ATTR_DIRECTION], + str(self._times[1][ATTR_DUE_IN]), + self._times[1][ATTR_STOP_NAME])) params = { ATTR_DUE_IN: str(self._times[0][ATTR_DUE_IN]), ATTR_DUE_AT: self._times[0][ATTR_DUE_AT], @@ -126,9 +121,9 @@ class RejseplanenTransportSensor(Entity): ATTR_DIRECTION: self._times[0][ATTR_DIRECTION], ATTR_STOP_NAME: self._times[0][ATTR_STOP_NAME], ATTR_STOP_ID: self._stop_id, - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_NEXT_UP: next_up - } + } return {k: v for k, v in params.items() if v} @property diff --git a/homeassistant/components/sensor/ring.py b/homeassistant/components/sensor/ring.py index 9478768f889..d58e0cf8b3f 100644 --- a/homeassistant/components/sensor/ring.py +++ b/homeassistant/components/sensor/ring.py @@ -11,7 +11,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.components.ring import ( - CONF_ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING) + ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING) from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, @@ -122,7 +122,7 @@ class RingSensor(Entity): """Return the state attributes.""" attrs = {} - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION attrs['device_id'] = self._data.id attrs['firmware'] = self._data.firmware attrs['kind'] = self._data.kind diff --git a/homeassistant/components/sensor/ripple.py b/homeassistant/components/sensor/ripple.py index beb7bf22269..4abbc4efe06 100644 --- a/homeassistant/components/sensor/ripple.py +++ b/homeassistant/components/sensor/ripple.py @@ -16,7 +16,7 @@ from homeassistant.helpers.entity import Entity REQUIREMENTS = ['python-ripple-api==0.0.3'] CONF_ADDRESS = 'address' -CONF_ATTRIBUTION = "Data provided by ripple.com" +ATTRIBUTION = "Data provided by ripple.com" DEFAULT_NAME = 'Ripple Balance' @@ -65,7 +65,7 @@ class RippleSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/sochain.py b/homeassistant/components/sensor/sochain.py index b582ba04567..d5bd4e5da82 100644 --- a/homeassistant/components/sensor/sochain.py +++ b/homeassistant/components/sensor/sochain.py @@ -19,9 +19,10 @@ REQUIREMENTS = ['python-sochain-api==0.0.2'] _LOGGER = logging.getLogger(__name__) +ATTRIBUTION = "Data provided by chain.so" + CONF_ADDRESS = 'address' CONF_NETWORK = 'network' -CONF_ATTRIBUTION = "Data provided by chain.so" DEFAULT_NAME = 'Crypto Balance' @@ -34,8 +35,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -async def async_setup_platform(hass, config, async_add_entities, - discovery_info=None): +async def async_setup_platform( + hass, config, async_add_entities, discovery_info=None): """Set up the sochain sensors.""" from pysochain import ChainSo address = config.get(CONF_ADDRESS) @@ -77,7 +78,7 @@ class SochainSensor(Entity): def device_state_attributes(self): """Return the state attributes of the sensor.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } async def async_update(self): diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 6b34930075a..d9f2410f8ca 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -30,7 +30,8 @@ ATTR_TARGET = 'destination' ATTR_TRAIN_NUMBER = 'train_number' ATTR_TRANSFERS = 'transfers' -CONF_ATTRIBUTION = "Data provided by transport.opendata.ch" +ATTRIBUTION = "Data provided by transport.opendata.ch" + CONF_DESTINATION = 'to' CONF_START = 'from' @@ -113,7 +114,7 @@ class SwissPublicTransportSensor(Entity): ATTR_START: self._opendata.from_name, ATTR_TARGET: self._opendata.to_name, ATTR_REMAINING_TIME: '{}'.format(self._remaining_time), - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } return attr diff --git a/homeassistant/components/sensor/synologydsm.py b/homeassistant/components/sensor/synologydsm.py index 39a9e75c47b..2b443738230 100644 --- a/homeassistant/components/sensor/synologydsm.py +++ b/homeassistant/components/sensor/synologydsm.py @@ -1,9 +1,4 @@ -""" -Support for Synology NAS Sensors. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/sensor.synologydsm/ -""" +"""Support for Synology NAS Sensors.""" import logging from datetime import timedelta @@ -22,7 +17,8 @@ REQUIREMENTS = ['python-synology==0.2.0'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = 'Data provided by Synology' +ATTRIBUTION = 'Data provided by Synology' + CONF_VOLUMES = 'volumes' DEFAULT_NAME = 'Synology DSM' DEFAULT_PORT = 5001 @@ -194,7 +190,7 @@ class SynoNasSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } diff --git a/homeassistant/components/sensor/sytadin.py b/homeassistant/components/sensor/sytadin.py index 082342a0393..f8ef18fcffe 100644 --- a/homeassistant/components/sensor/sytadin.py +++ b/homeassistant/components/sensor/sytadin.py @@ -24,8 +24,7 @@ _LOGGER = logging.getLogger(__name__) URL = 'http://www.sytadin.fr/sys/barometres_de_la_circulation.jsp.html' -CONF_ATTRIBUTION = "Data provided by Direction des routes Île-de-France" \ - "(DiRIF)" +ATTRIBUTION = "Data provided by Direction des routes Île-de-France (DiRIF)" DEFAULT_NAME = 'Sytadin' REGEX = r'(\d*\.\d+|\d+)' @@ -95,7 +94,7 @@ class SytadinSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } def update(self): diff --git a/homeassistant/components/sensor/trafikverket_weatherstation.py b/homeassistant/components/sensor/trafikverket_weatherstation.py index 433bb8e9ed1..38cc23dabbe 100644 --- a/homeassistant/components/sensor/trafikverket_weatherstation.py +++ b/homeassistant/components/sensor/trafikverket_weatherstation.py @@ -24,12 +24,13 @@ REQUIREMENTS = ['pytrafikverket==0.1.5.8'] _LOGGER = logging.getLogger(__name__) -SCAN_INTERVAL = timedelta(seconds=300) -MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10) +ATTRIBUTION = "Data provided by Trafikverket API" -CONF_ATTRIBUTION = "Data provided by Trafikverket API" CONF_STATION = 'station' +MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10) + +SCAN_INTERVAL = timedelta(seconds=300) SENSOR_TYPES = { 'air_temp': ['Air temperature', '°C', 'air_temp'], @@ -50,8 +51,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -async def async_setup_platform(hass, config, async_add_entities, - discovery_info=None): +async def async_setup_platform( + hass, config, async_add_entities, discovery_info=None): """Set up the Trafikverket sensor platform.""" from pytrafikverket.trafikverket_weather import TrafikverketWeather @@ -85,7 +86,7 @@ class TrafikverketWeatherStation(Entity): self._station = sensor_station self._weather_api = weather_api self._attributes = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } self._weather = None diff --git a/homeassistant/components/sensor/transport_nsw.py b/homeassistant/components/sensor/transport_nsw.py index 2e28d81a2c3..3c40bf4f709 100644 --- a/homeassistant/components/sensor/transport_nsw.py +++ b/homeassistant/components/sensor/transport_nsw.py @@ -1,9 +1,4 @@ -""" -Transport NSW (AU) sensor to query next leave event for a specified stop. - -For more details about this platform, please refer to the documentation at -https://home-assistant.io/components/sensor.transport_nsw/ -""" +"""Support for Transport NSW (AU) to query next leave event.""" from datetime import timedelta import logging @@ -26,7 +21,8 @@ ATTR_REAL_TIME = 'real_time' ATTR_DESTINATION = 'destination' ATTR_MODE = 'mode' -CONF_ATTRIBUTION = "Data provided by Transport NSW" +ATTRIBUTION = "Data provided by Transport NSW" + CONF_STOP_ID = 'stop_id' CONF_ROUTE = 'route' CONF_DESTINATION = 'destination' @@ -40,7 +36,7 @@ ICONS = { 'Ferry': 'mdi:ferry', 'Schoolbus': 'mdi:bus', 'n/a': 'mdi:clock', - None: 'mdi:clock' + None: 'mdi:clock', } SCAN_INTERVAL = timedelta(seconds=60) @@ -99,7 +95,7 @@ class TransportNSWSensor(Entity): ATTR_REAL_TIME: self._times[ATTR_REAL_TIME], ATTR_DESTINATION: self._times[ATTR_DESTINATION], ATTR_MODE: self._times[ATTR_MODE], - ATTR_ATTRIBUTION: CONF_ATTRIBUTION + ATTR_ATTRIBUTION: ATTRIBUTION } @property diff --git a/homeassistant/components/sensor/travisci.py b/homeassistant/components/sensor/travisci.py index e1bd74b993c..c96bb18e958 100644 --- a/homeassistant/components/sensor/travisci.py +++ b/homeassistant/components/sensor/travisci.py @@ -20,7 +20,8 @@ REQUIREMENTS = ['TravisPy==0.3.5'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Information provided by https://travis-ci.org/" +ATTRIBUTION = "Information provided by https://travis-ci.org/" + CONF_BRANCH = 'branch' CONF_REPOSITORY = 'repository' @@ -130,7 +131,7 @@ class TravisCISensor(Entity): def device_state_attributes(self): """Return the state attributes.""" attrs = {} - attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attrs[ATTR_ATTRIBUTION] = ATTRIBUTION if self._build and self._state is not None: if self._user and self._sensor_type == 'state': diff --git a/homeassistant/components/sensor/vasttrafik.py b/homeassistant/components/sensor/vasttrafik.py index 124b0ff44ea..8148a5c2fc7 100644 --- a/homeassistant/components/sensor/vasttrafik.py +++ b/homeassistant/components/sensor/vasttrafik.py @@ -24,8 +24,8 @@ ATTR_ACCESSIBILITY = 'accessibility' ATTR_DIRECTION = 'direction' ATTR_LINE = 'line' ATTR_TRACK = 'track' +ATTRIBUTION = "Data provided by Västtrafik" -CONF_ATTRIBUTION = "Data provided by Västtrafik" CONF_DELAY = 'delay' CONF_DEPARTURES = 'departures' CONF_FROM = 'from' @@ -137,7 +137,7 @@ class VasttrafikDepartureSensor(Entity): params = { ATTR_ACCESSIBILITY: departure.get('accessibility'), - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_DIRECTION: departure.get('direction'), ATTR_LINE: departure.get('sname'), ATTR_TRACK: departure.get('track'), diff --git a/homeassistant/components/sensor/viaggiatreno.py b/homeassistant/components/sensor/viaggiatreno.py index 82068c456b6..2b8de2042fa 100644 --- a/homeassistant/components/sensor/viaggiatreno.py +++ b/homeassistant/components/sensor/viaggiatreno.py @@ -18,7 +18,8 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Powered by ViaggiaTreno Data" +ATTRIBUTION = "Powered by ViaggiaTreno Data" + VIAGGIATRENO_ENDPOINT = ("http://www.viaggiatreno.it/viaggiatrenonew/" "resteasy/viaggiatreno/andamentoTreno/" "{station_id}/{train_id}") @@ -35,7 +36,7 @@ MONITORED_INFO = [ 'orarioPartenza', 'origine', 'subTitle', - ] +] DEFAULT_NAME = "Train {}" @@ -121,7 +122,7 @@ class ViaggiaTrenoSensor(Entity): @property def device_state_attributes(self): """Return extra attributes.""" - self._attributes[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + self._attributes[ATTR_ATTRIBUTION] = ATTRIBUTION return self._attributes @staticmethod diff --git a/homeassistant/components/sensor/waze_travel_time.py b/homeassistant/components/sensor/waze_travel_time.py index ae38c529fe2..6634339be4b 100644 --- a/homeassistant/components/sensor/waze_travel_time.py +++ b/homeassistant/components/sensor/waze_travel_time.py @@ -26,7 +26,8 @@ ATTR_DURATION = 'duration' ATTR_DISTANCE = 'distance' ATTR_ROUTE = 'route' -CONF_ATTRIBUTION = "Powered by Waze" +ATTRIBUTION = "Powered by Waze" + CONF_DESTINATION = 'destination' CONF_ORIGIN = 'origin' CONF_INCL_FILTER = 'incl_filter' @@ -138,7 +139,7 @@ class WazeTravelTime(Entity): if self._state is None: return None - res = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} + res = {ATTR_ATTRIBUTION: ATTRIBUTION} if 'duration' in self._state: res[ATTR_DURATION] = self._state['duration'] if 'distance' in self._state: diff --git a/homeassistant/components/sensor/worldtidesinfo.py b/homeassistant/components/sensor/worldtidesinfo.py index fea3e92a140..0f7bfeaa900 100644 --- a/homeassistant/components/sensor/worldtidesinfo.py +++ b/homeassistant/components/sensor/worldtidesinfo.py @@ -19,7 +19,7 @@ from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by WorldTides" +ATTRIBUTION = "Data provided by WorldTides" DEFAULT_NAME = 'WorldTidesInfo' @@ -72,7 +72,7 @@ class WorldTidesInfoSensor(Entity): @property def device_state_attributes(self): """Return the state attributes of this device.""" - attr = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} + attr = {ATTR_ATTRIBUTION: ATTRIBUTION} if 'High' in str(self.data['extremes'][0]['type']): attr['high_tide_time_utc'] = self.data['extremes'][0]['date'] diff --git a/homeassistant/components/sensor/wsdot.py b/homeassistant/components/sensor/wsdot.py index 84f2e8622c6..4e53a2c17c4 100644 --- a/homeassistant/components/sensor/wsdot.py +++ b/homeassistant/components/sensor/wsdot.py @@ -26,7 +26,7 @@ ATTR_DESCRIPTION = 'Description' ATTR_TIME_UPDATED = 'TimeUpdated' ATTR_TRAVEL_TIME_ID = 'TravelTimeID' -CONF_ATTRIBUTION = "Data provided by WSDOT" +ATTRIBUTION = "Data provided by WSDOT" CONF_TRAVEL_TIMES = 'travel_time' @@ -115,7 +115,7 @@ class WashingtonStateTravelTimeSensor(WashingtonStateTransportSensor): def device_state_attributes(self): """Return other details about the sensor state.""" if self._data is not None: - attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} + attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} for key in [ATTR_AVG_TIME, ATTR_NAME, ATTR_DESCRIPTION, ATTR_TRAVEL_TIME_ID]: attrs[key] = self._data.get(key) diff --git a/homeassistant/components/sensor/wunderground.py b/homeassistant/components/sensor/wunderground.py index be42e10e894..74a4c2089b2 100644 --- a/homeassistant/components/sensor/wunderground.py +++ b/homeassistant/components/sensor/wunderground.py @@ -29,7 +29,8 @@ import homeassistant.helpers.config_validation as cv _RESOURCE = 'http://api.wunderground.com/api/{}/{}/{}/q/' _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by the WUnderground weather service" +ATTRIBUTION = "Data provided by the WUnderground weather service" + CONF_PWS_ID = 'pws_id' CONF_LANG = 'lang' @@ -679,9 +680,7 @@ class WUndergroundSensor(Entity): self.rest = rest self._condition = condition self._state = None - self._attributes = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, - } + self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} self._icon = None self._entity_picture = None self._unit_of_measurement = self._cfg_expand("unit_of_measurement") diff --git a/homeassistant/components/sensor/yr.py b/homeassistant/components/sensor/yr.py index 0cb9c3765ec..665c482f050 100644 --- a/homeassistant/components/sensor/yr.py +++ b/homeassistant/components/sensor/yr.py @@ -29,8 +29,8 @@ REQUIREMENTS = ['xmltodict==0.11.0'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Weather forecast from met.no, delivered " \ - "by the Norwegian Meteorological Institute." +ATTRIBUTION = "Weather forecast from met.no, delivered by the Norwegian " \ + "Meteorological Institute." # https://api.met.no/license_data.html SENSOR_TYPES = { @@ -134,7 +134,7 @@ class YrSensor(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, } @property diff --git a/homeassistant/components/sensor/yweather.py b/homeassistant/components/sensor/yweather.py index 243329680e1..349ee2c7aae 100644 --- a/homeassistant/components/sensor/yweather.py +++ b/homeassistant/components/sensor/yweather.py @@ -21,7 +21,8 @@ REQUIREMENTS = ['yahooweather==0.10'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Weather details provided by Yahoo! Inc." +ATTRIBUTION = "Weather details provided by Yahoo! Inc." + CONF_FORECAST = 'forecast' CONF_WOEID = 'woeid' @@ -131,7 +132,7 @@ class YahooWeatherSensor(Entity): @property def device_state_attributes(self): """Return the state attributes.""" - attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} + attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} if self._code is not None and "weather" in self._type: attrs['condition_code'] = self._code diff --git a/homeassistant/components/sensor/zestimate.py b/homeassistant/components/sensor/zestimate.py index a04df22cf07..ed3af84d396 100644 --- a/homeassistant/components/sensor/zestimate.py +++ b/homeassistant/components/sensor/zestimate.py @@ -22,8 +22,9 @@ REQUIREMENTS = ['xmltodict==0.11.0'] _LOGGER = logging.getLogger(__name__) _RESOURCE = 'http://www.zillow.com/webservice/GetZestimate.htm' +ATTRIBUTION = "Data provided by Zillow.com" + CONF_ZPID = 'zpid' -CONF_ATTRIBUTION = "Data provided by Zillow.com" DEFAULT_NAME = 'Zestimate' NAME = 'zestimate' @@ -93,7 +94,7 @@ class ZestimateDataSensor(Entity): if self.data is not None: attributes = self.data attributes['address'] = self.address - attributes[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION + attributes[ATTR_ATTRIBUTION] = ATTRIBUTION return attributes @property diff --git a/homeassistant/components/skybell/__init__.py b/homeassistant/components/skybell/__init__.py index 8724f7d3d66..31d1339fbcf 100644 --- a/homeassistant/components/skybell/__init__.py +++ b/homeassistant/components/skybell/__init__.py @@ -13,7 +13,7 @@ REQUIREMENTS = ['skybellpy==0.3.0'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Data provided by Skybell.com" +ATTRIBUTION = "Data provided by Skybell.com" NOTIFICATION_ID = 'skybell_notification' NOTIFICATION_TITLE = 'Skybell Sensor Setup' @@ -76,7 +76,7 @@ class SkybellDevice(Entity): def device_state_attributes(self): """Return the state attributes.""" return { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_ATTRIBUTION: ATTRIBUTION, 'device_id': self._device.device_id, 'status': self._device.status, 'location': self._device.location, diff --git a/homeassistant/components/weather/met.py b/homeassistant/components/weather/met.py index 90978314a20..3ddbe5aed75 100644 --- a/homeassistant/components/weather/met.py +++ b/homeassistant/components/weather/met.py @@ -17,8 +17,8 @@ REQUIREMENTS = ['pyMetno==0.4.5'] _LOGGER = logging.getLogger(__name__) -CONF_ATTRIBUTION = "Weather forecast from met.no, delivered " \ - "by the Norwegian Meteorological Institute." +ATTRIBUTION = "Weather forecast from met.no, delivered by the Norwegian " \ + "Meteorological Institute." DEFAULT_NAME = "Met.no" URL = 'https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/' @@ -50,8 +50,8 @@ async def async_setup_platform(hass, config, async_add_entities, 'msl': str(elevation), } - async_add_entities([MetWeather(name, coordinates, - async_get_clientsession(hass))]) + async_add_entities([MetWeather( + name, coordinates, async_get_clientsession(hass))]) class MetWeather(WeatherEntity): @@ -61,18 +61,16 @@ class MetWeather(WeatherEntity): """Initialise the platform with a data instance and site.""" import metno self._name = name - self._weather_data = metno.MetWeatherData(coordinates, - clientsession, - URL - ) + self._weather_data = metno.MetWeatherData( + coordinates, clientsession, URL) self._current_weather_data = {} self._forecast_data = None async def async_added_to_hass(self): """Start fetching data.""" await self._fetch_data() - async_track_utc_time_change(self.hass, self._update, - minute=31, second=0) + async_track_utc_time_change( + self.hass, self._update, minute=31, second=0) async def _fetch_data(self, *_): """Get the latest data from met.no.""" @@ -141,7 +139,7 @@ class MetWeather(WeatherEntity): @property def attribution(self): """Return the attribution.""" - return CONF_ATTRIBUTION + return ATTRIBUTION @property def forecast(self): diff --git a/homeassistant/components/weather/metoffice.py b/homeassistant/components/weather/metoffice.py index 14738980482..3b52eebcff6 100644 --- a/homeassistant/components/weather/metoffice.py +++ b/homeassistant/components/weather/metoffice.py @@ -4,7 +4,7 @@ import logging import voluptuous as vol from homeassistant.components.sensor.metoffice import ( - CONDITION_CLASSES, CONF_ATTRIBUTION, MetOfficeCurrentData) + CONDITION_CLASSES, ATTRIBUTION, MetOfficeCurrentData) from homeassistant.components.weather import PLATFORM_SCHEMA, WeatherEntity from homeassistant.const import ( CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS) @@ -118,4 +118,4 @@ class MetOfficeWeather(WeatherEntity): @property def attribution(self): """Return the attribution.""" - return CONF_ATTRIBUTION + return ATTRIBUTION