Introduce a colorize option for the weather status plugin.
Add an option to change the color and add an icon in the display based on the text returned from weather.com. For example, if the waether is considered "Sunny" by weather.com the weather text will be set to a golden yellow and a little snow will be added to the display.
This commit is contained in:
parent
beff75b9c0
commit
2a47e84cc2
@ -19,6 +19,7 @@ class Weather(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
"location_code",
|
"location_code",
|
||||||
|
("colorize", "Enable color with temperature and UTF-8 icons."),
|
||||||
("units", "Celsius (metric) or Fahrenheit (imperial)"),
|
("units", "Celsius (metric) or Fahrenheit (imperial)"),
|
||||||
"format",
|
"format",
|
||||||
)
|
)
|
||||||
@ -26,6 +27,14 @@ class Weather(IntervalModule):
|
|||||||
|
|
||||||
units = "metric"
|
units = "metric"
|
||||||
format = "{current_temp}"
|
format = "{current_temp}"
|
||||||
|
colorize = None
|
||||||
|
color_icons = {'Fair': (u'\u2600', '#FFCC00'),
|
||||||
|
'Cloudy': (u'\u2601', '#F8F8FF'),
|
||||||
|
'Rainy': (u'\u2614', '#CBD2C0'),
|
||||||
|
'Sunny': (u'\u263C', '#FFFF00'),
|
||||||
|
'Snow': (u'\u2603', '#FFFFFF'),
|
||||||
|
'default': ('', None),
|
||||||
|
}
|
||||||
|
|
||||||
@require(internet)
|
@require(internet)
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -34,7 +43,18 @@ class Weather(IntervalModule):
|
|||||||
temperature = conditions['temperature']
|
temperature = conditions['temperature']
|
||||||
humidity = conditions['humidity']
|
humidity = conditions['humidity']
|
||||||
units = result['units']
|
units = result['units']
|
||||||
|
color = None
|
||||||
current_temp = '{t}°{d} '.format(t=temperature, d=units['temperature'])
|
current_temp = '{t}°{d} '.format(t=temperature, d=units['temperature'])
|
||||||
|
|
||||||
|
if self.colorize:
|
||||||
|
icon, color = self.color_icons.get(conditions['text'],
|
||||||
|
self.color_icons['default'])
|
||||||
|
current_temp = '{t}°{d} {i}'.format(t=temperature,
|
||||||
|
d=units['temperature'],
|
||||||
|
i=icon)
|
||||||
|
color = color
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(current_temp=current_temp, humidity=humidity)
|
"full_text": self.format.format(current_temp=current_temp, humidity=humidity),
|
||||||
|
"color": color
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user