mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Darksky: Add icon to summary sensors (#18275)
The icon changes dynamically, based on summary.
This commit is contained in:
parent
65be458ce0
commit
5cee9942a6
@ -135,16 +135,26 @@ SENSOR_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CONDITION_PICTURES = {
|
CONDITION_PICTURES = {
|
||||||
'clear-day': '/static/images/darksky/weather-sunny.svg',
|
'clear-day': ['/static/images/darksky/weather-sunny.svg',
|
||||||
'clear-night': '/static/images/darksky/weather-night.svg',
|
'mdi:weather-sunny'],
|
||||||
'rain': '/static/images/darksky/weather-pouring.svg',
|
'clear-night': ['/static/images/darksky/weather-night.svg',
|
||||||
'snow': '/static/images/darksky/weather-snowy.svg',
|
'mdi:weather-sunny'],
|
||||||
'sleet': '/static/images/darksky/weather-hail.svg',
|
'rain': ['/static/images/darksky/weather-pouring.svg',
|
||||||
'wind': '/static/images/darksky/weather-windy.svg',
|
'mdi:weather-pouring'],
|
||||||
'fog': '/static/images/darksky/weather-fog.svg',
|
'snow': ['/static/images/darksky/weather-snowy.svg',
|
||||||
'cloudy': '/static/images/darksky/weather-cloudy.svg',
|
'mdi:weather-snowy'],
|
||||||
'partly-cloudy-day': '/static/images/darksky/weather-partlycloudy.svg',
|
'sleet': ['/static/images/darksky/weather-hail.svg',
|
||||||
'partly-cloudy-night': '/static/images/darksky/weather-cloudy.svg',
|
'mdi:weather-snowy-rainy'],
|
||||||
|
'wind': ['/static/images/darksky/weather-windy.svg',
|
||||||
|
'mdi:weather-windy'],
|
||||||
|
'fog': ['/static/images/darksky/weather-fog.svg',
|
||||||
|
'mdi:weather-fog'],
|
||||||
|
'cloudy': ['/static/images/darksky/weather-cloudy.svg',
|
||||||
|
'mdi:weather-cloudy'],
|
||||||
|
'partly-cloudy-day': ['/static/images/darksky/weather-partlycloudy.svg',
|
||||||
|
'mdi:weather-partlycloudy'],
|
||||||
|
'partly-cloudy-night': ['/static/images/darksky/weather-cloudy.svg',
|
||||||
|
'mdi:weather-partlycloudy'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Language Supported Codes
|
# Language Supported Codes
|
||||||
@ -259,7 +269,7 @@ class DarkSkySensor(Entity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if self._icon in CONDITION_PICTURES:
|
if self._icon in CONDITION_PICTURES:
|
||||||
return CONDITION_PICTURES[self._icon]
|
return CONDITION_PICTURES[self._icon][0]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -277,6 +287,9 @@ class DarkSkySensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
|
if 'summary' in self.type and self._icon in CONDITION_PICTURES:
|
||||||
|
return CONDITION_PICTURES[self._icon][1]
|
||||||
|
|
||||||
return SENSOR_TYPES[self.type][6]
|
return SENSOR_TYPES[self.type][6]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user