mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Pollen.com: Added attributes on top 3 allergens (#14018)
This commit is contained in:
parent
6ccb83584e
commit
cb490780c9
@ -160,7 +160,7 @@ class BaseSensor(Entity):
|
|||||||
|
|
||||||
def __init__(self, data, data_params, name, icon, unique_id):
|
def __init__(self, data, data_params, name, icon, unique_id):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._attrs = {}
|
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||||
self._icon = icon
|
self._icon = icon
|
||||||
self._name = name
|
self._name = name
|
||||||
self._data_params = data_params
|
self._data_params = data_params
|
||||||
@ -172,7 +172,6 @@ class BaseSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
self._attrs.update({ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION})
|
|
||||||
return self._attrs
|
return self._attrs
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -254,10 +253,25 @@ class AllergyIndexSensor(BaseSensor):
|
|||||||
i['label'] for i in RATING_MAPPING
|
i['label'] for i in RATING_MAPPING
|
||||||
if i['minimum'] <= period['Index'] <= i['maximum']
|
if i['minimum'] <= period['Index'] <= i['maximum']
|
||||||
]
|
]
|
||||||
self._attrs[ATTR_ALLERGEN_GENUS] = period['Triggers'][0]['Genus']
|
|
||||||
self._attrs[ATTR_ALLERGEN_NAME] = period['Triggers'][0]['Name']
|
for i in range(3):
|
||||||
self._attrs[ATTR_ALLERGEN_TYPE] = period['Triggers'][0][
|
index = i + 1
|
||||||
'PlantType']
|
try:
|
||||||
|
data = period['Triggers'][i]
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_GENUS, index)] = data['Genus']
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_NAME, index)] = data['Name']
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_TYPE, index)] = data['PlantType']
|
||||||
|
except IndexError:
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_GENUS, index)] = None
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_NAME, index)] = None
|
||||||
|
self._attrs['{0}_{1}'.format(
|
||||||
|
ATTR_ALLERGEN_TYPE, index)] = None
|
||||||
|
|
||||||
self._attrs[ATTR_RATING] = rating
|
self._attrs[ATTR_RATING] = rating
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user