Rename CONF_ATTRIBUTION to ATTRIBUTION (#21069)

* Rename CONF_ATTRIBUTION to ATTRIBUTION

* Update homeassistant/components/sensor/irish_rail_transport.py

Co-Authored-By: fabaff <mail@fabian-affolter.ch>
This commit is contained in:
Fabian Affolter 2019-02-14 22:09:22 +01:00 committed by GitHub
parent 03ec3ac16e
commit cdc4dc3f11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 232 additions and 239 deletions

View file

@ -17,7 +17,8 @@ REQUIREMENTS = ['abodepy==0.15.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by goabode.com" ATTRIBUTION = "Data provided by goabode.com"
CONF_POLLING = 'polling' CONF_POLLING = 'polling'
DOMAIN = 'abode' DOMAIN = 'abode'
@ -280,7 +281,7 @@ class AbodeDevice(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'device_id': self._device.device_id, 'device_id': self._device.device_id,
'battery_low': self._device.battery_low, 'battery_low': self._device.battery_low,
'no_response': self._device.no_response, 'no_response': self._device.no_response,
@ -327,7 +328,7 @@ class AbodeAutomation(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'automation_id': self._automation.automation_id, 'automation_id': self._automation.automation_id,
'type': self._automation.type, 'type': self._automation.type,
'sub_type': self._automation.sub_type 'sub_type': self._automation.sub_type

View file

@ -2,7 +2,7 @@
import logging import logging
import homeassistant.components.alarm_control_panel as alarm 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.components.abode import DOMAIN as ABODE_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME,
@ -73,7 +73,7 @@ class AbodeAlarm(AbodeDevice, alarm.AlarmControlPanel):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'device_id': self._device.device_id, 'device_id': self._device.device_id,
'battery_backup': self._device.battery, 'battery_backup': self._device.battery,
'cellular_backup': self._device.is_cellular, 'cellular_backup': self._device.is_cellular,

View file

@ -15,7 +15,7 @@ REQUIREMENTS = ['pyarlo==0.2.3']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by arlo.netgear.com" ATTRIBUTION = "Data provided by arlo.netgear.com"
DATA_ARLO = 'data_arlo' DATA_ARLO = 'data_arlo'
DEFAULT_BRAND = 'Netgear Arlo' DEFAULT_BRAND = 'Netgear Arlo'

View file

@ -9,7 +9,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.components.alarm_control_panel import ( from homeassistant.components.alarm_control_panel import (
AlarmControlPanel, PLATFORM_SCHEMA) AlarmControlPanel, PLATFORM_SCHEMA)
from homeassistant.components.arlo import ( from homeassistant.components.arlo import (
DATA_ARLO, CONF_ATTRIBUTION, SIGNAL_UPDATE_ARLO) DATA_ARLO, ATTRIBUTION, SIGNAL_UPDATE_ARLO)
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, ATTR_ATTRIBUTION, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME,
STATE_ALARM_DISARMED, STATE_ALARM_ARMED_NIGHT) STATE_ALARM_DISARMED, STATE_ALARM_ARMED_NIGHT)
@ -117,7 +117,7 @@ class ArloBaseStation(AlarmControlPanel):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'device_id': self._base_station.device_id 'device_id': self._base_station.device_id
} }

View file

@ -6,7 +6,7 @@ import voluptuous as vol
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.arlo import ( 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.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS, TEMP_CELSIUS, ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS, TEMP_CELSIUS,
@ -177,7 +177,7 @@ class ArloSensor(Entity):
"""Return the device state attributes.""" """Return the device state attributes."""
attrs = {} attrs = {}
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
attrs['brand'] = DEFAULT_BRAND attrs['brand'] = DEFAULT_BRAND
if self._sensor_type != 'total_cameras': if self._sensor_type != 'total_cameras':

View file

@ -19,8 +19,8 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric" \ ATTRIBUTION = "Data provided by the National Oceanic and Atmospheric " \
"Administration" "Administration"
CONF_THRESHOLD = 'forecast_threshold' CONF_THRESHOLD = 'forecast_threshold'
DEFAULT_DEVICE_CLASS = 'visible' DEFAULT_DEVICE_CLASS = 'visible'
@ -91,7 +91,7 @@ class AuroraSensor(BinarySensorDevice):
if self.aurora_data: if self.aurora_data:
attrs['visibility_level'] = self.aurora_data.visibility_level attrs['visibility_level'] = self.aurora_data.visibility_level
attrs['message'] = self.aurora_data.is_visible_text attrs['message'] = self.aurora_data.is_visible_text
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
return attrs return attrs
def update(self): def update(self):

View file

@ -11,7 +11,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.ring import ( from homeassistant.components.ring import (
CONF_ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING) ATTRIBUTION, DEFAULT_ENTITY_NAMESPACE, DATA_RING)
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS) 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 device in ring.doorbells: # ring.doorbells is doing I/O
for sensor_type in config[CONF_MONITORED_CONDITIONS]: for sensor_type in config[CONF_MONITORED_CONDITIONS]:
if 'doorbell' in SENSOR_TYPES[sensor_type][1]: if 'doorbell' in SENSOR_TYPES[sensor_type][1]:
sensors.append(RingBinarySensor(hass, sensors.append(RingBinarySensor(hass, device, sensor_type))
device,
sensor_type))
for device in ring.stickup_cams: # ring.stickup_cams is doing I/O for device in ring.stickup_cams: # ring.stickup_cams is doing I/O
for sensor_type in config[CONF_MONITORED_CONDITIONS]: for sensor_type in config[CONF_MONITORED_CONDITIONS]:
if 'stickup_cams' in SENSOR_TYPES[sensor_type][1]: if 'stickup_cams' in SENSOR_TYPES[sensor_type][1]:
sensors.append(RingBinarySensor(hass, sensors.append(RingBinarySensor(hass, device, sensor_type))
device,
sensor_type))
add_entities(sensors, True) add_entities(sensors, True)
return True
class RingBinarySensor(BinarySensorDevice): class RingBinarySensor(BinarySensorDevice):
@ -69,8 +65,8 @@ class RingBinarySensor(BinarySensorDevice):
super(RingBinarySensor, self).__init__() super(RingBinarySensor, self).__init__()
self._sensor_type = sensor_type self._sensor_type = sensor_type
self._data = data self._data = data
self._name = "{0} {1}".format(self._data.name, self._name = "{0} {1}".format(
SENSOR_TYPES.get(self._sensor_type)[0]) self._data.name, SENSOR_TYPES.get(self._sensor_type)[0])
self._device_class = SENSOR_TYPES.get(self._sensor_type)[2] self._device_class = SENSOR_TYPES.get(self._sensor_type)[2]
self._state = None self._state = None
self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type) self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type)
@ -99,7 +95,7 @@ class RingBinarySensor(BinarySensorDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {} attrs = {}
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
attrs['device_id'] = self._data.id attrs['device_id'] = self._data.id
attrs['firmware'] = self._data.firmware attrs['firmware'] = self._data.firmware

View file

@ -19,7 +19,7 @@ _LOGGER = logging.getLogger(__name__)
ATTR_TARGET = 'target' ATTR_TARGET = 'target'
CONF_ATTRIBUTION = "Data provided by Uptime Robot" ATTRIBUTION = "Data provided by Uptime Robot"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_API_KEY): cv.string,
@ -78,7 +78,7 @@ class UptimeRobotBinarySensor(BinarySensorDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the binary sensor.""" """Return the state attributes of the binary sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_TARGET: self._target, ATTR_TARGET: self._target,
} }

View file

@ -13,7 +13,7 @@ import voluptuous as vol
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.components.ring import ( 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.camera import Camera, PLATFORM_SCHEMA
from homeassistant.components.ffmpeg import DATA_FFMPEG from homeassistant.components.ffmpeg import DATA_FFMPEG
from homeassistant.const import ATTR_ATTRIBUTION, CONF_SCAN_INTERVAL from homeassistant.const import ATTR_ATTRIBUTION, CONF_SCAN_INTERVAL
@ -34,8 +34,7 @@ SCAN_INTERVAL = timedelta(seconds=90)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string, vol.Optional(CONF_FFMPEG_ARGUMENTS): cv.string,
vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): vol.Optional(CONF_SCAN_INTERVAL, default=SCAN_INTERVAL): cv.time_period,
cv.time_period,
}) })
@ -106,7 +105,7 @@ class RingCam(Camera):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'device_id': self._camera.id, 'device_id': self._camera.id,
'firmware': self._camera.firmware, 'firmware': self._camera.firmware,
'kind': self._camera.kind, 'kind': self._camera.kind,

View file

@ -22,7 +22,8 @@ ATTR_MEMORY = 'memory'
ATTR_REGION = 'region' ATTR_REGION = 'region'
ATTR_VCPUS = 'vcpus' ATTR_VCPUS = 'vcpus'
CONF_ATTRIBUTION = 'Data provided by Digital Ocean' ATTRIBUTION = 'Data provided by Digital Ocean'
CONF_DROPLETS = 'droplets' CONF_DROPLETS = 'droplets'
DATA_DIGITAL_OCEAN = 'data_do' DATA_DIGITAL_OCEAN = 'data_do'

View file

@ -9,7 +9,7 @@ from homeassistant.components.binary_sensor import (
from homeassistant.components.digital_ocean import ( from homeassistant.components.digital_ocean import (
CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME, CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME,
ATTR_FEATURES, ATTR_IPV4_ADDRESS, ATTR_IPV6_ADDRESS, ATTR_MEMORY, 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 from homeassistant.const import ATTR_ATTRIBUTION
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -71,7 +71,7 @@ class DigitalOceanBinarySensor(BinarySensorDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the Digital Ocean droplet.""" """Return the state attributes of the Digital Ocean droplet."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_CREATED_AT: self.data.created_at, ATTR_CREATED_AT: self.data.created_at,
ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_ID: self.data.id,
ATTR_DROPLET_NAME: self.data.name, ATTR_DROPLET_NAME: self.data.name,

View file

@ -8,7 +8,7 @@ from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.components.digital_ocean import ( from homeassistant.components.digital_ocean import (
CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME, CONF_DROPLETS, ATTR_CREATED_AT, ATTR_DROPLET_ID, ATTR_DROPLET_NAME,
ATTR_FEATURES, ATTR_IPV4_ADDRESS, ATTR_IPV6_ADDRESS, ATTR_MEMORY, 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 from homeassistant.const import ATTR_ATTRIBUTION
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -65,7 +65,7 @@ class DigitalOceanSwitch(SwitchDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the Digital Ocean droplet.""" """Return the state attributes of the Digital Ocean droplet."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_CREATED_AT: self.data.created_at, ATTR_CREATED_AT: self.data.created_at,
ATTR_DROPLET_ID: self.data.id, ATTR_DROPLET_ID: self.data.id,
ATTR_DROPLET_NAME: self.data.name, ATTR_DROPLET_NAME: self.data.name,

View file

@ -20,7 +20,8 @@ _LOGGER = logging.getLogger(__name__)
ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60] 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' CONF_WATERING_TIME = 'watering_minutes'
NOTIFICATION_ID = 'hydrawise_notification' NOTIFICATION_ID = 'hydrawise_notification'
@ -141,6 +142,6 @@ class HydrawiseEntity(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'identifier': self.data.get('relay'), 'identifier': self.data.get('relay'),
} }

View file

@ -1,19 +1,19 @@
"""Support for Logi Circle devices.""" """Support for Logi Circle devices."""
import logging
import asyncio import asyncio
import logging
import voluptuous as vol
import async_timeout import async_timeout
import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
REQUIREMENTS = ['logi_circle==0.1.7'] REQUIREMENTS = ['logi_circle==0.1.7']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_TIMEOUT = 15 # seconds _TIMEOUT = 15 # seconds
CONF_ATTRIBUTION = "Data provided by circle.logi.com" ATTRIBUTION = "Data provided by circle.logi.com"
NOTIFICATION_ID = 'logi_notification' NOTIFICATION_ID = 'logi_notification'
NOTIFICATION_TITLE = 'Logi Circle Setup' NOTIFICATION_TITLE = 'Logi Circle Setup'

View file

@ -7,7 +7,7 @@ import voluptuous as vol
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.components.logi_circle import ( from homeassistant.components.logi_circle import (
DOMAIN as LOGI_CIRCLE_DOMAIN, CONF_ATTRIBUTION) DOMAIN as LOGI_CIRCLE_DOMAIN, ATTRIBUTION)
from homeassistant.components.camera import ( from homeassistant.components.camera import (
Camera, PLATFORM_SCHEMA, CAMERA_SERVICE_SCHEMA, SUPPORT_ON_OFF, Camera, PLATFORM_SCHEMA, CAMERA_SERVICE_SCHEMA, SUPPORT_ON_OFF,
ATTR_ENTITY_ID, ATTR_FILENAME, DOMAIN) ATTR_ENTITY_ID, ATTR_FILENAME, DOMAIN)
@ -128,7 +128,7 @@ class LogiCam(Camera):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
state = { state = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'battery_saving_mode': ( 'battery_saving_mode': (
STATE_ON if self._camera.battery_saving else STATE_OFF), STATE_ON if self._camera.battery_saving else STATE_OFF),
'ip_address': self._camera.ip_address, 'ip_address': self._camera.ip_address,

View file

@ -5,7 +5,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.logi_circle import ( 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.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_BATTERY_CHARGING, ATTR_ATTRIBUTION, ATTR_BATTERY_CHARGING,
@ -86,7 +86,7 @@ class LogiSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
state = { state = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'battery_saving_mode': ( 'battery_saving_mode': (
STATE_ON if self._camera.battery_saving else STATE_OFF), STATE_ON if self._camera.battery_saving else STATE_OFF),
'ip_address': self._camera.ip_address, 'ip_address': self._camera.ip_address,

View file

@ -24,7 +24,8 @@ _LOGGER = logging.getLogger(__name__)
ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60] 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' CONF_WATERING_TIME = 'watering_minutes'
NOTIFICATION_ID = 'raincloud_notification' NOTIFICATION_ID = 'raincloud_notification'
@ -165,7 +166,7 @@ class RainCloudEntity(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'identifier': self.data.serial, 'identifier': self.data.serial,
} }

View file

@ -1,16 +1,11 @@
""" """Support for Melnor RainCloud sprinkler water timer."""
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/
"""
import logging import logging
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.raincloud import ( 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) DATA_RAINCLOUD, DEFAULT_WATERING_TIME, RainCloudEntity, SWITCHES)
from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
from homeassistant.const import ( 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 # create a sensor for each zone managed by faucet
for zone in raincloud.controller.faucet.zones: for zone in raincloud.controller.faucet.zones:
sensors.append( sensors.append(
RainCloudSwitch(default_watering_timer, RainCloudSwitch(default_watering_timer, zone, sensor_type))
zone,
sensor_type))
add_entities(sensors, True) add_entities(sensors, True)
return True
class RainCloudSwitch(RainCloudEntity, SwitchDevice): class RainCloudSwitch(RainCloudEntity, SwitchDevice):
@ -87,7 +79,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchDevice):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'default_manual_timer': self._default_watering_timer, 'default_manual_timer': self._default_watering_timer,
'identifier': self.data.serial 'identifier': self.data.serial
} }

View file

@ -1,17 +1,17 @@
"""Support for Ring Doorbell/Chimes.""" """Support for Ring Doorbell/Chimes."""
import logging import logging
from requests.exceptions import HTTPError, ConnectTimeout
from requests.exceptions import ConnectTimeout, HTTPError
import voluptuous as vol import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
REQUIREMENTS = ['ring_doorbell==0.2.2'] REQUIREMENTS = ['ring_doorbell==0.2.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by Ring.com" ATTRIBUTION = "Data provided by Ring.com"
NOTIFICATION_ID = 'ring_notification' NOTIFICATION_ID = 'ring_notification'
NOTIFICATION_TITLE = 'Ring Setup' NOTIFICATION_TITLE = 'Ring Setup'

View file

@ -23,7 +23,8 @@ ATTR_CLOSE = 'close'
ATTR_HIGH = 'high' ATTR_HIGH = 'high'
ATTR_LOW = 'low' 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_FOREIGN_EXCHANGE = 'foreign_exchange'
CONF_FROM = 'from' CONF_FROM = 'from'
CONF_SYMBOL = 'symbol' CONF_SYMBOL = 'symbol'
@ -143,7 +144,7 @@ class AlphaVantageSensor(Entity):
"""Return the state attributes.""" """Return the state attributes."""
if self.values is not None: if self.values is not None:
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_CLOSE: self.values['4. close'], ATTR_CLOSE: self.values['4. close'],
ATTR_HIGH: self.values['2. high'], ATTR_HIGH: self.values['2. high'],
ATTR_LOW: self.values['3. low'], ATTR_LOW: self.values['3. low'],
@ -203,7 +204,7 @@ class AlphaVantageForeignExchange(Entity):
"""Return the state attributes.""" """Return the state attributes."""
if self.values is not None: if self.values is not None:
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
CONF_FROM: self._from_currency, CONF_FROM: self._from_currency,
CONF_TO: self._to_currency, CONF_TO: self._to_currency,
} }

View file

@ -19,7 +19,7 @@ REQUIREMENTS = ['blockchain==1.4.4']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by blockchain.info" ATTRIBUTION = "Data provided by blockchain.info"
DEFAULT_CURRENCY = 'USD' DEFAULT_CURRENCY = 'USD'
@ -112,7 +112,7 @@ class BitcoinSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -18,8 +18,9 @@ REQUIREMENTS = ['python-blockchain-api==0.0.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Data provided by blockchain.info"
CONF_ADDRESSES = 'addresses' CONF_ADDRESSES = 'addresses'
CONF_ATTRIBUTION = "Data provided by blockchain.info"
DEFAULT_NAME = 'Bitcoin Balance' DEFAULT_NAME = 'Bitcoin Balance'
@ -82,7 +83,7 @@ class BlockchainSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -34,7 +34,8 @@ ATTR_STATION_ID = 'station_id'
ATTR_STATION_NAME = 'station_name' ATTR_STATION_NAME = 'station_name'
ATTR_ZONE_ID = 'zone_id' 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_STATION = 'station'
CONF_ZONE_ID = 'zone_id' CONF_ZONE_ID = 'zone_id'
CONF_WMO_ID = 'wmo_id' CONF_WMO_ID = 'wmo_id'
@ -158,7 +159,7 @@ class BOMCurrentSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the device.""" """Return the state attributes of the device."""
attr = { attr = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_LAST_UPDATE: self.bom_data.last_updated, ATTR_LAST_UPDATE: self.bom_data.last_updated,
ATTR_SENSOR_ID: self._condition, ATTR_SENSOR_ID: self._condition,
ATTR_STATION_ID: self.bom_data.latest_data['wmo'], ATTR_STATION_ID: self.bom_data.latest_data['wmo'],

View file

@ -16,9 +16,10 @@ CURRENCY_ICONS = {
'LTC': 'mdi:litecoin', 'LTC': 'mdi:litecoin',
'USD': 'mdi:currency-usd' 'USD': 'mdi:currency-usd'
} }
DEFAULT_COIN_ICON = 'mdi:coin' DEFAULT_COIN_ICON = 'mdi:coin'
CONF_ATTRIBUTION = "Data provided by coinbase.com" ATTRIBUTION = "Data provided by coinbase.com"
DATA_COINBASE = 'coinbase_cache' DATA_COINBASE = 'coinbase_cache'
DEPENDENCIES = ['coinbase'] DEPENDENCIES = ['coinbase']
@ -77,7 +78,7 @@ class AccountSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_NATIVE_BALANCE: "{} {}".format( ATTR_NATIVE_BALANCE: "{} {}".format(
self._native_balance, self._native_currency), self._native_balance, self._native_currency),
} }
@ -127,7 +128,7 @@ class ExchangeRateSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION ATTR_ATTRIBUTION: ATTRIBUTION
} }
def update(self): def update(self):

View file

@ -32,7 +32,8 @@ ATTR_RANK = 'rank'
ATTR_SYMBOL = 'symbol' ATTR_SYMBOL = 'symbol'
ATTR_TOTAL_SUPPLY = 'total_supply' ATTR_TOTAL_SUPPLY = 'total_supply'
CONF_ATTRIBUTION = "Data provided by CoinMarketCap" ATTRIBUTION = "Data provided by CoinMarketCap"
CONF_CURRENCY_ID = 'currency_id' CONF_CURRENCY_ID = 'currency_id'
CONF_DISPLAY_CURRENCY_DECIMALS = 'display_currency_decimals' CONF_DISPLAY_CURRENCY_DECIMALS = 'display_currency_decimals'
@ -115,7 +116,7 @@ class CoinMarketCapSensor(Entity):
ATTR_VOLUME_24H: ATTR_VOLUME_24H:
self._ticker.get('quotes').get(self.data.display_currency) self._ticker.get('quotes').get(self.data.display_currency)
.get('volume_24h'), .get('volume_24h'),
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_CIRCULATING_SUPPLY: self._ticker.get('circulating_supply'), ATTR_CIRCULATING_SUPPLY: self._ticker.get('circulating_supply'),
ATTR_MARKET_CAP: ATTR_MARKET_CAP:
self._ticker.get('quotes').get(self.data.display_currency) self._ticker.get('quotes').get(self.data.display_currency)

View file

@ -25,7 +25,8 @@ _RESOURCE = 'https://hourlypricing.comed.com/api'
SCAN_INTERVAL = timedelta(minutes=5) 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_CURRENT_HOUR_AVERAGE = 'current_hour_average'
CONF_FIVE_MINUTE = 'five_minute' CONF_FIVE_MINUTE = 'five_minute'
CONF_MONITORED_FEEDS = 'monitored_feeds' CONF_MONITORED_FEEDS = 'monitored_feeds'
@ -97,8 +98,7 @@ class ComedHourlyPricingSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} return {ATTR_ATTRIBUTION: ATTRIBUTION}
return attrs
async def async_update(self): async def async_update(self):
"""Get the ComEd Hourly Pricing data from the web service.""" """Get the ComEd Hourly Pricing data from the web service."""

View file

@ -19,7 +19,7 @@ from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_RESOURCE = 'http://apilayer.net/api/live' _RESOURCE = 'http://apilayer.net/api/live'
CONF_ATTRIBUTION = "Data provided by currencylayer.com" ATTRIBUTION = "Data provided by currencylayer.com"
DEFAULT_BASE = 'USD' DEFAULT_BASE = 'USD'
DEFAULT_NAME = 'CurrencyLayer Sensor' DEFAULT_NAME = 'CurrencyLayer Sensor'
@ -91,7 +91,7 @@ class CurrencylayerSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
ATTR_IDENTITY = 'identity' ATTR_IDENTITY = 'identity'
CONF_ATTRIBUTION = "Data provided by Discogs" ATTRIBUTION = "Data provided by Discogs"
DEFAULT_NAME = 'Discogs' DEFAULT_NAME = 'Discogs'
@ -86,7 +86,7 @@ class DiscogsSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_IDENTITY: self._identity.name, ATTR_IDENTITY: self._identity.name,
} }

View file

@ -28,7 +28,8 @@ ATTR_DUE_IN = 'Due in'
ATTR_DUE_AT = 'Due at' ATTR_DUE_AT = 'Due at'
ATTR_NEXT_UP = 'Later Bus' 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_STOP_ID = 'stopid'
CONF_ROUTE = 'route' CONF_ROUTE = 'route'
@ -101,7 +102,7 @@ class DublinPublicTransportSensor(Entity):
ATTR_DUE_AT: self._times[0][ATTR_DUE_AT], ATTR_DUE_AT: self._times[0][ATTR_DUE_AT],
ATTR_STOP_ID: self._stop, ATTR_STOP_ID: self._stop,
ATTR_ROUTE: self._times[0][ATTR_ROUTE], ATTR_ROUTE: self._times[0][ATTR_ROUTE],
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_NEXT_UP: next_up ATTR_NEXT_UP: next_up
} }

View file

@ -26,7 +26,8 @@ ATTR_NEXT_UP_IN = 'next_due_in'
API_CLIENT_NAME = 'homeassistant-homeassistant' 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_STOP_IDS = 'stop_ids'
CONF_EXPAND_PLATFORMS = 'expand_platforms' CONF_EXPAND_PLATFORMS = 'expand_platforms'
CONF_WHITELIST_LINES = 'line_whitelist' CONF_WHITELIST_LINES = 'line_whitelist'
@ -140,7 +141,7 @@ class EnturPublicTransportSensor(Entity):
self._state = None self._state = None
self._icon = ICONS[DEFAULT_ICON_KEY] self._icon = ICONS[DEFAULT_ICON_KEY]
self._attributes = { self._attributes = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_STOP_ID: self._stop, ATTR_STOP_ID: self._stop,
} }

View file

@ -15,10 +15,11 @@ from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['python-etherscan-api==0.0.3'] REQUIREMENTS = ['python-etherscan-api==0.0.3']
ATTRIBUTION = "Data provided by etherscan.io"
CONF_ADDRESS = 'address' CONF_ADDRESS = 'address'
CONF_TOKEN = 'token' CONF_TOKEN = 'token'
CONF_TOKEN_ADDRESS = 'token_address' CONF_TOKEN_ADDRESS = 'token_address'
CONF_ATTRIBUTION = "Data provided by etherscan.io"
SCAN_INTERVAL = timedelta(minutes=5) SCAN_INTERVAL = timedelta(minutes=5)
@ -77,9 +78,7 @@ class EtherscanSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {ATTR_ATTRIBUTION: ATTRIBUTION}
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
}
def update(self): def update(self):
"""Get the latest state of the sensor.""" """Get the latest state of the sensor."""

View file

@ -35,7 +35,7 @@ ATTR_LAST_SAVED_AT = 'last_saved_at'
CONF_MONITORED_RESOURCES = 'monitored_resources' CONF_MONITORED_RESOURCES = 'monitored_resources'
CONF_CLOCK_FORMAT = 'clock_format' CONF_CLOCK_FORMAT = 'clock_format'
CONF_ATTRIBUTION = 'Data provided by Fitbit.com' ATTRIBUTION = 'Data provided by Fitbit.com'
DEPENDENCIES = ['http'] DEPENDENCIES = ['http']
@ -423,8 +423,8 @@ class FitbitSensor(Entity):
"""Icon to use in the frontend, if any.""" """Icon to use in the frontend, if any."""
if self.resource_type == 'devices/battery' and self.extra: if self.resource_type == 'devices/battery' and self.extra:
battery_level = BATTERY_LEVELS[self.extra.get('battery')] battery_level = BATTERY_LEVELS[self.extra.get('battery')]
return icon_for_battery_level(battery_level=battery_level, return icon_for_battery_level(
charging=None) battery_level=battery_level, charging=None)
return 'mdi:{}'.format(FITBIT_RESOURCES_LIST[self.resource_type][2]) return 'mdi:{}'.format(FITBIT_RESOURCES_LIST[self.resource_type][2])
@property @property
@ -432,7 +432,7 @@ class FitbitSensor(Entity):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {} attrs = {}
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
if self.extra: if self.extra:
attrs['model'] = self.extra.get('deviceVersion') attrs['model'] = self.extra.get('deviceVersion')

View file

@ -20,8 +20,8 @@ _LOGGER = logging.getLogger(__name__)
ATTR_EXCHANGE_RATE = 'Exchange rate' ATTR_EXCHANGE_RATE = 'Exchange rate'
ATTR_TARGET = 'Target currency' 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' CONF_TARGET = 'target'
DEFAULT_BASE = 'USD' DEFAULT_BASE = 'USD'
@ -86,7 +86,7 @@ class ExchangeRateSensor(Entity):
"""Return the state attributes.""" """Return the state attributes."""
if self.data.rate is not None: if self.data.rate is not None:
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target], ATTR_EXCHANGE_RATE: self.data.rate['rates'][self._target],
ATTR_TARGET: self._target, ATTR_TARGET: self._target,
} }

View file

@ -28,8 +28,8 @@ ATTR_BUILD_FINISHED = 'build_finished'
ATTR_BUILD_ID = 'build id' ATTR_BUILD_ID = 'build id'
ATTR_BUILD_STARTED = 'build_started' ATTR_BUILD_STARTED = 'build_started'
ATTR_BUILD_STATUS = 'build_status' 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' CONF_GITLAB_ID = 'gitlab_id'
DEFAULT_NAME = 'GitLab CI Status' DEFAULT_NAME = 'GitLab CI Status'
@ -101,7 +101,7 @@ class GitLabSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_BUILD_STATUS: self._state, ATTR_BUILD_STATUS: self._state,
ATTR_BUILD_STARTED: self._started_at, ATTR_BUILD_STARTED: self._started_at,
ATTR_BUILD_FINISHED: self._finished_at, ATTR_BUILD_FINISHED: self._finished_at,

View file

@ -12,7 +12,7 @@ import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA 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 import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import track_point_in_time from homeassistant.helpers.event import track_point_in_time
@ -21,6 +21,8 @@ import homeassistant.util.dt as dt_util
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Data provided by Have I Been Pwned (HIBP)"
DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S" DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S"
HA_USER_AGENT = "Home Assistant HaveIBeenPwned Sensor Component" HA_USER_AGENT = "Home Assistant HaveIBeenPwned Sensor Component"
@ -75,7 +77,7 @@ class HaveIBeenPwnedSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the attributes of the sensor.""" """Return the attributes of the sensor."""
val = {} val = {ATTR_ATTRIBUTION: ATTRIBUTION}
if self._email not in self._data.data: if self._email not in self._data.data:
return val return val

View file

@ -25,7 +25,8 @@ ATTR_REMOTE_HOST = 'Remote Server'
ATTR_REMOTE_PORT = 'Remote Port' ATTR_REMOTE_PORT = 'Remote Port'
ATTR_VERSION = 'Version' ATTR_VERSION = 'Version'
CONF_ATTRIBUTION = 'Data retrieved using Iperf3' ATTRIBUTION = 'Data retrieved using Iperf3'
CONF_DURATION = 'duration' CONF_DURATION = 'duration'
CONF_PARALLEL = 'parallel' CONF_PARALLEL = 'parallel'
@ -106,11 +107,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class Iperf3Sensor(Entity): class Iperf3Sensor(Entity):
"""A Iperf3 sensor implementation.""" """A Iperf3 sensor implementation."""
def __init__(self, server, port, duration, streams, def __init__(self, server, port, duration, streams, protocol, sensor_type):
protocol, sensor_type):
"""Initialize the sensor.""" """Initialize the sensor."""
self._attrs = { self._attrs = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_PROTOCOL: protocol, ATTR_PROTOCOL: protocol,
} }
self._name = \ self._name = \
@ -144,7 +144,7 @@ class Iperf3Sensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
if self.result is not None: 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_HOST] = self.result.remote_host
self._attrs[ATTR_REMOTE_PORT] = self.result.remote_port self._attrs[ATTR_REMOTE_PORT] = self.result.remote_port
self._attrs[ATTR_VERSION] = self.result.version self._attrs[ATTR_VERSION] = self.result.version

View file

@ -1,9 +1,4 @@
""" """Support for Irish Rail RTPI information."""
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/
"""
import logging import logging
from datetime import timedelta from datetime import timedelta
@ -11,7 +6,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA 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 from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['pyirishrail==0.0.2'] REQUIREMENTS = ['pyirishrail==0.0.2']
@ -28,6 +23,7 @@ ATTR_DUE_AT = "Due at"
ATTR_EXPECT_AT = "Expected at" ATTR_EXPECT_AT = "Expected at"
ATTR_NEXT_UP = "Later Train" ATTR_NEXT_UP = "Later Train"
ATTR_TRAIN_TYPE = "Train type" ATTR_TRAIN_TYPE = "Train type"
ATTRIBUTION = "Data provided by Irish Rail"
CONF_STATION = 'station' CONF_STATION = 'station'
CONF_DESTINATION = 'destination' CONF_DESTINATION = 'destination'
@ -100,6 +96,7 @@ class IrishRailTransportSensor(Entity):
next_up += self._times[1][ATTR_DUE_IN] next_up += self._times[1][ATTR_DUE_IN]
return { return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_STATION: self._station, ATTR_STATION: self._station,
ATTR_ORIGIN: self._times[0][ATTR_ORIGIN], ATTR_ORIGIN: self._times[0][ATTR_ORIGIN],
ATTR_DESTINATION: self._times[0][ATTR_DESTINATION], ATTR_DESTINATION: self._times[0][ATTR_DESTINATION],
@ -109,7 +106,7 @@ class IrishRailTransportSensor(Entity):
ATTR_DIRECTION: self._times[0][ATTR_DIRECTION], ATTR_DIRECTION: self._times[0][ATTR_DIRECTION],
ATTR_STOPS_AT: self._times[0][ATTR_STOPS_AT], ATTR_STOPS_AT: self._times[0][ATTR_STOPS_AT],
ATTR_NEXT_UP: next_up, ATTR_NEXT_UP: next_up,
ATTR_TRAIN_TYPE: self._times[0][ATTR_TRAIN_TYPE] ATTR_TRAIN_TYPE: self._times[0][ATTR_TRAIN_TYPE],
} }
@property @property
@ -146,22 +143,23 @@ class IrishRailTransportData:
def update(self): def update(self):
"""Get the latest data from irishrail.""" """Get the latest data from irishrail."""
trains = self._ir_api.get_station_by_name(self.station, trains = self._ir_api.get_station_by_name(
direction=self.direction, self.station, direction=self.direction,
destination=self.destination, destination=self.destination, stops_at=self.stops_at)
stops_at=self.stops_at)
stops_at = self.stops_at if self.stops_at else '' stops_at = self.stops_at if self.stops_at else ''
self.info = [] self.info = []
for train in trains: for train in trains:
train_data = {ATTR_STATION: self.station, train_data = {
ATTR_ORIGIN: train.get('origin'), ATTR_STATION: self.station,
ATTR_DESTINATION: train.get('destination'), ATTR_ORIGIN: train.get('origin'),
ATTR_DUE_IN: train.get('due_in_mins'), ATTR_DESTINATION: train.get('destination'),
ATTR_DUE_AT: train.get('scheduled_arrival_time'), ATTR_DUE_IN: train.get('due_in_mins'),
ATTR_EXPECT_AT: train.get('expected_departure_time'), ATTR_DUE_AT: train.get('scheduled_arrival_time'),
ATTR_DIRECTION: train.get('direction'), ATTR_EXPECT_AT: train.get('expected_departure_time'),
ATTR_STOPS_AT: stops_at, ATTR_DIRECTION: train.get('direction'),
ATTR_TRAIN_TYPE: train.get('type')} ATTR_STOPS_AT: stops_at,
ATTR_TRAIN_TYPE: train.get('type'),
}
self.info.append(train_data) self.info.append(train_data)
if not self.info: if not self.info:
@ -180,4 +178,5 @@ class IrishRailTransportData:
ATTR_EXPECT_AT: 'n/a', ATTR_EXPECT_AT: 'n/a',
ATTR_DIRECTION: direction, ATTR_DIRECTION: direction,
ATTR_STOPS_AT: stops_at, ATTR_STOPS_AT: stops_at,
ATTR_TRAIN_TYPE: ''}] ATTR_TRAIN_TYPE: '',
}]

View file

@ -1,16 +1,11 @@
""" """Sensor for Last.fm account status."""
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/
"""
import logging import logging
import re import re
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA 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 import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -21,6 +16,7 @@ _LOGGER = logging.getLogger(__name__)
ATTR_LAST_PLAYED = 'last_played' ATTR_LAST_PLAYED = 'last_played'
ATTR_PLAY_COUNT = 'play_count' ATTR_PLAY_COUNT = 'play_count'
ATTR_TOP_PLAYED = 'top_played' ATTR_TOP_PLAYED = 'top_played'
ATTRIBUTION = "Data provided by Last.fm"
CONF_USERS = 'users' CONF_USERS = 'users'
@ -105,6 +101,7 @@ class LastfmSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_LAST_PLAYED: self._lastplayed, ATTR_LAST_PLAYED: self._lastplayed,
ATTR_PLAY_COUNT: self._playcount, ATTR_PLAY_COUNT: self._playcount,
ATTR_TOP_PLAYED: self._topplayed, ATTR_TOP_PLAYED: self._topplayed,

View file

@ -18,8 +18,11 @@ REQUIREMENTS = ['london-tube-status==0.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Powered by TfL Open Data" ATTRIBUTION = "Powered by TfL Open Data"
CONF_LINE = 'line' CONF_LINE = 'line'
SCAN_INTERVAL = timedelta(seconds=30) SCAN_INTERVAL = timedelta(seconds=30)
TUBE_LINES = [ TUBE_LINES = [
'Bakerloo', 'Bakerloo',
'Central', 'Central',
@ -34,7 +37,8 @@ TUBE_LINES = [
'Piccadilly', 'Piccadilly',
'TfL Rail', 'TfL Rail',
'Victoria', 'Victoria',
'Waterloo & City'] 'Waterloo & City',
]
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_LINE): vol.Required(CONF_LINE):

View file

@ -26,7 +26,7 @@ ATTR_SENSOR_ID = 'sensor_id'
ATTR_SITE_ID = 'site_id' ATTR_SITE_ID = 'site_id'
ATTR_SITE_NAME = 'site_name' ATTR_SITE_NAME = 'site_name'
CONF_ATTRIBUTION = "Data provided by the Met Office" ATTRIBUTION = "Data provided by the Met Office"
CONDITION_CLASSES = { CONDITION_CLASSES = {
'cloudy': ['7', '8'], 'cloudy': ['7', '8'],
@ -162,7 +162,7 @@ class MetOfficeCurrentSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the device.""" """Return the state attributes of the device."""
attr = {} attr = {}
attr[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attr[ATTR_ATTRIBUTION] = ATTRIBUTION
attr[ATTR_LAST_UPDATE] = self.data.data.date attr[ATTR_LAST_UPDATE] = self.data.data.date
attr[ATTR_SENSOR_ID] = self._condition attr[ATTR_SENSOR_ID] = self._condition
attr[ATTR_SITE_ID] = self.site.id attr[ATTR_SITE_ID] = self.site.id

View file

@ -21,7 +21,8 @@ REQUIREMENTS = ['nsapi==2.7.4']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by NS" ATTRIBUTION = "Data provided by NS"
CONF_ROUTES = 'routes' CONF_ROUTES = 'routes'
CONF_FROM = 'from' CONF_FROM = 'from'
CONF_TO = 'to' CONF_TO = 'to'
@ -155,7 +156,7 @@ class NSDepartureSensor(Entity):
'transfers': self._trips[0].nr_transfers, 'transfers': self._trips[0].nr_transfers,
'route': route, 'route': route,
'remarks': [r.message for r in self._trips[0].trip_remarks], 'remarks': [r.message for r in self._trips[0].trip_remarks],
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)

View file

@ -28,7 +28,8 @@ CONF_FUEL_TYPES = 'fuel_types'
CONF_ALLOWED_FUEL_TYPES = ["E10", "U91", "E85", "P95", "P98", "DL", CONF_ALLOWED_FUEL_TYPES = ["E10", "U91", "E85", "P95", "P98", "DL",
"PDL", "B20", "LPG", "CNG", "EV"] "PDL", "B20", "LPG", "CNG", "EV"]
CONF_DEFAULT_FUEL_TYPES = ["E10", "U91"] 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({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_STATION_ID): cv.positive_int, vol.Required(CONF_STATION_ID): cv.positive_int,
@ -161,7 +162,7 @@ class StationPriceSensor(Entity):
return { return {
ATTR_STATION_ID: self._station_data.station_id, ATTR_STATION_ID: self._station_data.station_id,
ATTR_STATION_NAME: self._station_data.get_station_name(), ATTR_STATION_NAME: self._station_data.get_station_name(),
ATTR_ATTRIBUTION: CONF_ATTRIBUTION ATTR_ATTRIBUTION: ATTRIBUTION
} }
@property @property

View file

@ -20,7 +20,7 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_RESOURCE = 'https://openexchangerates.org/api/latest.json' _RESOURCE = 'https://openexchangerates.org/api/latest.json'
CONF_ATTRIBUTION = "Data provided by openexchangerates.org" ATTRIBUTION = "Data provided by openexchangerates.org"
DEFAULT_BASE = 'USD' DEFAULT_BASE = 'USD'
DEFAULT_NAME = 'Exchange Rate Sensor' DEFAULT_NAME = 'Exchange Rate Sensor'
@ -82,7 +82,7 @@ class OpenexchangeratesSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return other attributes of the sensor.""" """Return other attributes of the sensor."""
attr = self.rest.data attr = self.rest.data
attr[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attr[ATTR_ATTRIBUTION] = ATTRIBUTION
return attr return attr

View file

@ -21,7 +21,8 @@ REQUIREMENTS = ['pyowm==2.10.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by OpenWeatherMap" ATTRIBUTION = "Data provided by OpenWeatherMap"
CONF_FORECAST = 'forecast' CONF_FORECAST = 'forecast'
CONF_LANGUAGE = 'language' CONF_LANGUAGE = 'language'
@ -121,7 +122,7 @@ class OpenWeatherMapSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -31,7 +31,8 @@ ATTR_DUE_IN = 'Due in'
ATTR_DUE_AT = 'Due at' ATTR_DUE_AT = 'Due at'
ATTR_NEXT_UP = 'Later departure' ATTR_NEXT_UP = 'Later departure'
CONF_ATTRIBUTION = "Data provided by rejseplanen.dk" ATTRIBUTION = "Data provided by rejseplanen.dk"
CONF_STOP_ID = 'stop_id' CONF_STOP_ID = 'stop_id'
CONF_ROUTE = 'route' CONF_ROUTE = 'route'
CONF_DIRECTION = 'direction' CONF_DIRECTION = 'direction'
@ -50,8 +51,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_DIRECTION, default=[]): vol.Optional(CONF_DIRECTION, default=[]):
vol.All(cv.ensure_list, [cv.string]), vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_DEPARTURE_TYPE, default=[]): vol.Optional(CONF_DEPARTURE_TYPE, default=[]):
vol.All(cv.ensure_list, [vol.In(list(['BUS', 'EXB', 'M', vol.All(cv.ensure_list,
'S', 'REG']))]) [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] departure_type = config[CONF_DEPARTURE_TYPE]
data = PublicTransportData(stop_id, route, direction, departure_type) data = PublicTransportData(stop_id, route, direction, departure_type)
add_devices([RejseplanenTransportSensor(data, add_devices([RejseplanenTransportSensor(
stop_id, data, stop_id, route, direction, name)], True)
route,
direction,
name)],
True)
class RejseplanenTransportSensor(Entity): class RejseplanenTransportSensor(Entity):
@ -111,13 +108,11 @@ class RejseplanenTransportSensor(Entity):
if self._times is not None: if self._times is not None:
next_up = None next_up = None
if len(self._times) > 1: if len(self._times) > 1:
next_up = ('{} towards ' next_up = ('{} towards {} in {} from {}'.format(
'{} in ' self._times[1][ATTR_ROUTE],
'{} from ' self._times[1][ATTR_DIRECTION],
'{}'.format(self._times[1][ATTR_ROUTE], str(self._times[1][ATTR_DUE_IN]),
self._times[1][ATTR_DIRECTION], self._times[1][ATTR_STOP_NAME]))
str(self._times[1][ATTR_DUE_IN]),
self._times[1][ATTR_STOP_NAME]))
params = { params = {
ATTR_DUE_IN: str(self._times[0][ATTR_DUE_IN]), ATTR_DUE_IN: str(self._times[0][ATTR_DUE_IN]),
ATTR_DUE_AT: self._times[0][ATTR_DUE_AT], ATTR_DUE_AT: self._times[0][ATTR_DUE_AT],
@ -126,9 +121,9 @@ class RejseplanenTransportSensor(Entity):
ATTR_DIRECTION: self._times[0][ATTR_DIRECTION], ATTR_DIRECTION: self._times[0][ATTR_DIRECTION],
ATTR_STOP_NAME: self._times[0][ATTR_STOP_NAME], ATTR_STOP_NAME: self._times[0][ATTR_STOP_NAME],
ATTR_STOP_ID: self._stop_id, ATTR_STOP_ID: self._stop_id,
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_NEXT_UP: next_up ATTR_NEXT_UP: next_up
} }
return {k: v for k, v in params.items() if v} return {k: v for k, v in params.items() if v}
@property @property

View file

@ -11,7 +11,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.components.ring import ( 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.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import ( from homeassistant.const import (
CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS, CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS,
@ -122,7 +122,7 @@ class RingSensor(Entity):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {} attrs = {}
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
attrs['device_id'] = self._data.id attrs['device_id'] = self._data.id
attrs['firmware'] = self._data.firmware attrs['firmware'] = self._data.firmware
attrs['kind'] = self._data.kind attrs['kind'] = self._data.kind

View file

@ -16,7 +16,7 @@ from homeassistant.helpers.entity import Entity
REQUIREMENTS = ['python-ripple-api==0.0.3'] REQUIREMENTS = ['python-ripple-api==0.0.3']
CONF_ADDRESS = 'address' CONF_ADDRESS = 'address'
CONF_ATTRIBUTION = "Data provided by ripple.com" ATTRIBUTION = "Data provided by ripple.com"
DEFAULT_NAME = 'Ripple Balance' DEFAULT_NAME = 'Ripple Balance'
@ -65,7 +65,7 @@ class RippleSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -19,9 +19,10 @@ REQUIREMENTS = ['python-sochain-api==0.0.2']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Data provided by chain.so"
CONF_ADDRESS = 'address' CONF_ADDRESS = 'address'
CONF_NETWORK = 'network' CONF_NETWORK = 'network'
CONF_ATTRIBUTION = "Data provided by chain.so"
DEFAULT_NAME = 'Crypto Balance' DEFAULT_NAME = 'Crypto Balance'
@ -34,8 +35,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
}) })
async def async_setup_platform(hass, config, async_add_entities, async def async_setup_platform(
discovery_info=None): hass, config, async_add_entities, discovery_info=None):
"""Set up the sochain sensors.""" """Set up the sochain sensors."""
from pysochain import ChainSo from pysochain import ChainSo
address = config.get(CONF_ADDRESS) address = config.get(CONF_ADDRESS)
@ -77,7 +78,7 @@ class SochainSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
async def async_update(self): async def async_update(self):

View file

@ -30,7 +30,8 @@ ATTR_TARGET = 'destination'
ATTR_TRAIN_NUMBER = 'train_number' ATTR_TRAIN_NUMBER = 'train_number'
ATTR_TRANSFERS = 'transfers' ATTR_TRANSFERS = 'transfers'
CONF_ATTRIBUTION = "Data provided by transport.opendata.ch" ATTRIBUTION = "Data provided by transport.opendata.ch"
CONF_DESTINATION = 'to' CONF_DESTINATION = 'to'
CONF_START = 'from' CONF_START = 'from'
@ -113,7 +114,7 @@ class SwissPublicTransportSensor(Entity):
ATTR_START: self._opendata.from_name, ATTR_START: self._opendata.from_name,
ATTR_TARGET: self._opendata.to_name, ATTR_TARGET: self._opendata.to_name,
ATTR_REMAINING_TIME: '{}'.format(self._remaining_time), ATTR_REMAINING_TIME: '{}'.format(self._remaining_time),
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
return attr return attr

View file

@ -1,9 +1,4 @@
""" """Support for Synology NAS Sensors."""
Support for Synology NAS Sensors.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.synologydsm/
"""
import logging import logging
from datetime import timedelta from datetime import timedelta
@ -22,7 +17,8 @@ REQUIREMENTS = ['python-synology==0.2.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = 'Data provided by Synology' ATTRIBUTION = 'Data provided by Synology'
CONF_VOLUMES = 'volumes' CONF_VOLUMES = 'volumes'
DEFAULT_NAME = 'Synology DSM' DEFAULT_NAME = 'Synology DSM'
DEFAULT_PORT = 5001 DEFAULT_PORT = 5001
@ -194,7 +190,7 @@ class SynoNasSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }

View file

@ -24,8 +24,7 @@ _LOGGER = logging.getLogger(__name__)
URL = 'http://www.sytadin.fr/sys/barometres_de_la_circulation.jsp.html' URL = 'http://www.sytadin.fr/sys/barometres_de_la_circulation.jsp.html'
CONF_ATTRIBUTION = "Data provided by Direction des routes Île-de-France" \ ATTRIBUTION = "Data provided by Direction des routes Île-de-France (DiRIF)"
"(DiRIF)"
DEFAULT_NAME = 'Sytadin' DEFAULT_NAME = 'Sytadin'
REGEX = r'(\d*\.\d+|\d+)' REGEX = r'(\d*\.\d+|\d+)'
@ -95,7 +94,7 @@ class SytadinSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
def update(self): def update(self):

View file

@ -24,12 +24,13 @@ REQUIREMENTS = ['pytrafikverket==0.1.5.8']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=300) ATTRIBUTION = "Data provided by Trafikverket API"
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
CONF_ATTRIBUTION = "Data provided by Trafikverket API"
CONF_STATION = 'station' CONF_STATION = 'station'
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
SCAN_INTERVAL = timedelta(seconds=300)
SENSOR_TYPES = { SENSOR_TYPES = {
'air_temp': ['Air temperature', '°C', 'air_temp'], '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, async def async_setup_platform(
discovery_info=None): hass, config, async_add_entities, discovery_info=None):
"""Set up the Trafikverket sensor platform.""" """Set up the Trafikverket sensor platform."""
from pytrafikverket.trafikverket_weather import TrafikverketWeather from pytrafikverket.trafikverket_weather import TrafikverketWeather
@ -85,7 +86,7 @@ class TrafikverketWeatherStation(Entity):
self._station = sensor_station self._station = sensor_station
self._weather_api = weather_api self._weather_api = weather_api
self._attributes = { self._attributes = {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
self._weather = None self._weather = None

View file

@ -1,9 +1,4 @@
""" """Support for Transport NSW (AU) to query next leave event."""
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/
"""
from datetime import timedelta from datetime import timedelta
import logging import logging
@ -26,7 +21,8 @@ ATTR_REAL_TIME = 'real_time'
ATTR_DESTINATION = 'destination' ATTR_DESTINATION = 'destination'
ATTR_MODE = 'mode' ATTR_MODE = 'mode'
CONF_ATTRIBUTION = "Data provided by Transport NSW" ATTRIBUTION = "Data provided by Transport NSW"
CONF_STOP_ID = 'stop_id' CONF_STOP_ID = 'stop_id'
CONF_ROUTE = 'route' CONF_ROUTE = 'route'
CONF_DESTINATION = 'destination' CONF_DESTINATION = 'destination'
@ -40,7 +36,7 @@ ICONS = {
'Ferry': 'mdi:ferry', 'Ferry': 'mdi:ferry',
'Schoolbus': 'mdi:bus', 'Schoolbus': 'mdi:bus',
'n/a': 'mdi:clock', 'n/a': 'mdi:clock',
None: 'mdi:clock' None: 'mdi:clock',
} }
SCAN_INTERVAL = timedelta(seconds=60) SCAN_INTERVAL = timedelta(seconds=60)
@ -99,7 +95,7 @@ class TransportNSWSensor(Entity):
ATTR_REAL_TIME: self._times[ATTR_REAL_TIME], ATTR_REAL_TIME: self._times[ATTR_REAL_TIME],
ATTR_DESTINATION: self._times[ATTR_DESTINATION], ATTR_DESTINATION: self._times[ATTR_DESTINATION],
ATTR_MODE: self._times[ATTR_MODE], ATTR_MODE: self._times[ATTR_MODE],
ATTR_ATTRIBUTION: CONF_ATTRIBUTION ATTR_ATTRIBUTION: ATTRIBUTION
} }
@property @property

View file

@ -20,7 +20,8 @@ REQUIREMENTS = ['TravisPy==0.3.5']
_LOGGER = logging.getLogger(__name__) _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_BRANCH = 'branch'
CONF_REPOSITORY = 'repository' CONF_REPOSITORY = 'repository'
@ -130,7 +131,7 @@ class TravisCISensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {} attrs = {}
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
if self._build and self._state is not None: if self._build and self._state is not None:
if self._user and self._sensor_type == 'state': if self._user and self._sensor_type == 'state':

View file

@ -24,8 +24,8 @@ ATTR_ACCESSIBILITY = 'accessibility'
ATTR_DIRECTION = 'direction' ATTR_DIRECTION = 'direction'
ATTR_LINE = 'line' ATTR_LINE = 'line'
ATTR_TRACK = 'track' ATTR_TRACK = 'track'
ATTRIBUTION = "Data provided by Västtrafik"
CONF_ATTRIBUTION = "Data provided by Västtrafik"
CONF_DELAY = 'delay' CONF_DELAY = 'delay'
CONF_DEPARTURES = 'departures' CONF_DEPARTURES = 'departures'
CONF_FROM = 'from' CONF_FROM = 'from'
@ -137,7 +137,7 @@ class VasttrafikDepartureSensor(Entity):
params = { params = {
ATTR_ACCESSIBILITY: departure.get('accessibility'), ATTR_ACCESSIBILITY: departure.get('accessibility'),
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_DIRECTION: departure.get('direction'), ATTR_DIRECTION: departure.get('direction'),
ATTR_LINE: departure.get('sname'), ATTR_LINE: departure.get('sname'),
ATTR_TRACK: departure.get('track'), ATTR_TRACK: departure.get('track'),

View file

@ -18,7 +18,8 @@ from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Powered by ViaggiaTreno Data" ATTRIBUTION = "Powered by ViaggiaTreno Data"
VIAGGIATRENO_ENDPOINT = ("http://www.viaggiatreno.it/viaggiatrenonew/" VIAGGIATRENO_ENDPOINT = ("http://www.viaggiatreno.it/viaggiatrenonew/"
"resteasy/viaggiatreno/andamentoTreno/" "resteasy/viaggiatreno/andamentoTreno/"
"{station_id}/{train_id}") "{station_id}/{train_id}")
@ -35,7 +36,7 @@ MONITORED_INFO = [
'orarioPartenza', 'orarioPartenza',
'origine', 'origine',
'subTitle', 'subTitle',
] ]
DEFAULT_NAME = "Train {}" DEFAULT_NAME = "Train {}"
@ -121,7 +122,7 @@ class ViaggiaTrenoSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return extra attributes.""" """Return extra attributes."""
self._attributes[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION self._attributes[ATTR_ATTRIBUTION] = ATTRIBUTION
return self._attributes return self._attributes
@staticmethod @staticmethod

View file

@ -26,7 +26,8 @@ ATTR_DURATION = 'duration'
ATTR_DISTANCE = 'distance' ATTR_DISTANCE = 'distance'
ATTR_ROUTE = 'route' ATTR_ROUTE = 'route'
CONF_ATTRIBUTION = "Powered by Waze" ATTRIBUTION = "Powered by Waze"
CONF_DESTINATION = 'destination' CONF_DESTINATION = 'destination'
CONF_ORIGIN = 'origin' CONF_ORIGIN = 'origin'
CONF_INCL_FILTER = 'incl_filter' CONF_INCL_FILTER = 'incl_filter'
@ -138,7 +139,7 @@ class WazeTravelTime(Entity):
if self._state is None: if self._state is None:
return None return None
res = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} res = {ATTR_ATTRIBUTION: ATTRIBUTION}
if 'duration' in self._state: if 'duration' in self._state:
res[ATTR_DURATION] = self._state['duration'] res[ATTR_DURATION] = self._state['duration']
if 'distance' in self._state: if 'distance' in self._state:

View file

@ -19,7 +19,7 @@ from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by WorldTides" ATTRIBUTION = "Data provided by WorldTides"
DEFAULT_NAME = 'WorldTidesInfo' DEFAULT_NAME = 'WorldTidesInfo'
@ -72,7 +72,7 @@ class WorldTidesInfoSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of this device.""" """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']): if 'High' in str(self.data['extremes'][0]['type']):
attr['high_tide_time_utc'] = self.data['extremes'][0]['date'] attr['high_tide_time_utc'] = self.data['extremes'][0]['date']

View file

@ -26,7 +26,7 @@ ATTR_DESCRIPTION = 'Description'
ATTR_TIME_UPDATED = 'TimeUpdated' ATTR_TIME_UPDATED = 'TimeUpdated'
ATTR_TRAVEL_TIME_ID = 'TravelTimeID' ATTR_TRAVEL_TIME_ID = 'TravelTimeID'
CONF_ATTRIBUTION = "Data provided by WSDOT" ATTRIBUTION = "Data provided by WSDOT"
CONF_TRAVEL_TIMES = 'travel_time' CONF_TRAVEL_TIMES = 'travel_time'
@ -115,7 +115,7 @@ class WashingtonStateTravelTimeSensor(WashingtonStateTransportSensor):
def device_state_attributes(self): def device_state_attributes(self):
"""Return other details about the sensor state.""" """Return other details about the sensor state."""
if self._data is not None: 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, for key in [ATTR_AVG_TIME, ATTR_NAME, ATTR_DESCRIPTION,
ATTR_TRAVEL_TIME_ID]: ATTR_TRAVEL_TIME_ID]:
attrs[key] = self._data.get(key) attrs[key] = self._data.get(key)

View file

@ -29,7 +29,8 @@ import homeassistant.helpers.config_validation as cv
_RESOURCE = 'http://api.wunderground.com/api/{}/{}/{}/q/' _RESOURCE = 'http://api.wunderground.com/api/{}/{}/{}/q/'
_LOGGER = logging.getLogger(__name__) _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_PWS_ID = 'pws_id'
CONF_LANG = 'lang' CONF_LANG = 'lang'
@ -679,9 +680,7 @@ class WUndergroundSensor(Entity):
self.rest = rest self.rest = rest
self._condition = condition self._condition = condition
self._state = None self._state = None
self._attributes = { self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
ATTR_ATTRIBUTION: CONF_ATTRIBUTION,
}
self._icon = None self._icon = None
self._entity_picture = None self._entity_picture = None
self._unit_of_measurement = self._cfg_expand("unit_of_measurement") self._unit_of_measurement = self._cfg_expand("unit_of_measurement")

View file

@ -29,8 +29,8 @@ REQUIREMENTS = ['xmltodict==0.11.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Weather forecast from met.no, delivered " \ ATTRIBUTION = "Weather forecast from met.no, delivered by the Norwegian " \
"by the Norwegian Meteorological Institute." "Meteorological Institute."
# https://api.met.no/license_data.html # https://api.met.no/license_data.html
SENSOR_TYPES = { SENSOR_TYPES = {
@ -134,7 +134,7 @@ class YrSensor(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
} }
@property @property

View file

@ -21,7 +21,8 @@ REQUIREMENTS = ['yahooweather==0.10']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Weather details provided by Yahoo! Inc." ATTRIBUTION = "Weather details provided by Yahoo! Inc."
CONF_FORECAST = 'forecast' CONF_FORECAST = 'forecast'
CONF_WOEID = 'woeid' CONF_WOEID = 'woeid'
@ -131,7 +132,7 @@ class YahooWeatherSensor(Entity):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
attrs = {ATTR_ATTRIBUTION: CONF_ATTRIBUTION} attrs = {ATTR_ATTRIBUTION: ATTRIBUTION}
if self._code is not None and "weather" in self._type: if self._code is not None and "weather" in self._type:
attrs['condition_code'] = self._code attrs['condition_code'] = self._code

View file

@ -22,8 +22,9 @@ REQUIREMENTS = ['xmltodict==0.11.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
_RESOURCE = 'http://www.zillow.com/webservice/GetZestimate.htm' _RESOURCE = 'http://www.zillow.com/webservice/GetZestimate.htm'
ATTRIBUTION = "Data provided by Zillow.com"
CONF_ZPID = 'zpid' CONF_ZPID = 'zpid'
CONF_ATTRIBUTION = "Data provided by Zillow.com"
DEFAULT_NAME = 'Zestimate' DEFAULT_NAME = 'Zestimate'
NAME = 'zestimate' NAME = 'zestimate'
@ -93,7 +94,7 @@ class ZestimateDataSensor(Entity):
if self.data is not None: if self.data is not None:
attributes = self.data attributes = self.data
attributes['address'] = self.address attributes['address'] = self.address
attributes[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION attributes[ATTR_ATTRIBUTION] = ATTRIBUTION
return attributes return attributes
@property @property

View file

@ -13,7 +13,7 @@ REQUIREMENTS = ['skybellpy==0.3.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Data provided by Skybell.com" ATTRIBUTION = "Data provided by Skybell.com"
NOTIFICATION_ID = 'skybell_notification' NOTIFICATION_ID = 'skybell_notification'
NOTIFICATION_TITLE = 'Skybell Sensor Setup' NOTIFICATION_TITLE = 'Skybell Sensor Setup'
@ -76,7 +76,7 @@ class SkybellDevice(Entity):
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_ATTRIBUTION: CONF_ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
'device_id': self._device.device_id, 'device_id': self._device.device_id,
'status': self._device.status, 'status': self._device.status,
'location': self._device.location, 'location': self._device.location,

View file

@ -17,8 +17,8 @@ REQUIREMENTS = ['pyMetno==0.4.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONF_ATTRIBUTION = "Weather forecast from met.no, delivered " \ ATTRIBUTION = "Weather forecast from met.no, delivered by the Norwegian " \
"by the Norwegian Meteorological Institute." "Meteorological Institute."
DEFAULT_NAME = "Met.no" DEFAULT_NAME = "Met.no"
URL = 'https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/' 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), 'msl': str(elevation),
} }
async_add_entities([MetWeather(name, coordinates, async_add_entities([MetWeather(
async_get_clientsession(hass))]) name, coordinates, async_get_clientsession(hass))])
class MetWeather(WeatherEntity): class MetWeather(WeatherEntity):
@ -61,18 +61,16 @@ class MetWeather(WeatherEntity):
"""Initialise the platform with a data instance and site.""" """Initialise the platform with a data instance and site."""
import metno import metno
self._name = name self._name = name
self._weather_data = metno.MetWeatherData(coordinates, self._weather_data = metno.MetWeatherData(
clientsession, coordinates, clientsession, URL)
URL
)
self._current_weather_data = {} self._current_weather_data = {}
self._forecast_data = None self._forecast_data = None
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Start fetching data.""" """Start fetching data."""
await self._fetch_data() await self._fetch_data()
async_track_utc_time_change(self.hass, self._update, async_track_utc_time_change(
minute=31, second=0) self.hass, self._update, minute=31, second=0)
async def _fetch_data(self, *_): async def _fetch_data(self, *_):
"""Get the latest data from met.no.""" """Get the latest data from met.no."""
@ -141,7 +139,7 @@ class MetWeather(WeatherEntity):
@property @property
def attribution(self): def attribution(self):
"""Return the attribution.""" """Return the attribution."""
return CONF_ATTRIBUTION return ATTRIBUTION
@property @property
def forecast(self): def forecast(self):

View file

@ -4,7 +4,7 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.components.sensor.metoffice import ( 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.components.weather import PLATFORM_SCHEMA, WeatherEntity
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS) CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS)
@ -118,4 +118,4 @@ class MetOfficeWeather(WeatherEntity):
@property @property
def attribution(self): def attribution(self):
"""Return the attribution.""" """Return the attribution."""
return CONF_ATTRIBUTION return ATTRIBUTION