diff --git a/custom_components/antistorm/binary_sensor.py b/custom_components/antistorm/binary_sensor.py index af3a285..a6ceaa8 100644 --- a/custom_components/antistorm/binary_sensor.py +++ b/custom_components/antistorm/binary_sensor.py @@ -4,7 +4,7 @@ import voluptuous as vol from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, ENTITY_ID_FORMAT -from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME +from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, ATTR_ATTRIBUTION import homeassistant.helpers.config_validation as cv from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.helpers.entity import async_generate_entity_id @@ -14,6 +14,7 @@ CONF_STATION_ID = 'station_id' DEFAULT_NAME = 'Antistorm' +ATTRIBUTION = 'Information provided by Antistorm.eu.' SENSOR_TYPES = { 'storm_alarm': ['a_b', 'Alarm burzowy', 'mdi:weather-lightning'], @@ -56,6 +57,12 @@ def __init__(self, entity_id, name, city_name, sensor_type, station_id): self._jsonParameter = SENSOR_TYPES[sensor_type][0] self._name = SENSOR_TYPES[sensor_type][1] + @property + def device_state_attributes(self): + output = dict() + output[ATTR_ATTRIBUTION] = ATTRIBUTION + return output + @property def name(self): return '{} {} - {}'.format(self._name, self.city_name, SENSOR_TYPES[self.sensor_type][1]) diff --git a/custom_components/antistorm/sensor.py b/custom_components/antistorm/sensor.py index 68f91cb..54bb52e 100644 --- a/custom_components/antistorm/sensor.py +++ b/custom_components/antistorm/sensor.py @@ -4,7 +4,7 @@ import voluptuous as vol from homeassistant.components.sensor import (PLATFORM_SCHEMA, ENTITY_ID_FORMAT) -from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME +from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, ATTR_ATTRIBUTION import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import async_generate_entity_id @@ -14,6 +14,7 @@ CONF_STATION_ID = 'station_id' DEFAULT_NAME = 'Antistorm' +ATTRIBUTION = 'Information provided by Antistorm.eu.' SENSOR_TYPES = { 'storm_probability': ['p_b', 'PrawdopodobieĊ„stwo burzy', ' ', 'mdi:weather-lightning'], @@ -58,6 +59,12 @@ def __init__(self, entity_id, name, city_name, sensor_type, station_id): self._name = SENSOR_TYPES[sensor_type][1] self._unit_of_measurement = SENSOR_TYPES[sensor_type][2] + @property + def device_state_attributes(self): + output = dict() + output[ATTR_ATTRIBUTION] = ATTRIBUTION + return output + @property def name(self): return '{} {} - {}'.format(self._name, self.city_name, SENSOR_TYPES[self.sensor_type][1])