I frankensteined the code of Hellis81 a little bit, so five day is now more like three day forecast , I changed the font and the output format as well and I’m sure you will find more differences, if you look for them…
Check with your weather integration, if you find a list of conditions and check against my provided list. It seems some integrations are not using the names of the icons…
Have fun!
So for the template:
weather_fivedays:
friendly_name: "Five day weather"
value_template: >
{% set weather = {
"cloudy": "",
"cloudy-alert": "",
"cloudy-arrow-right": "",
"cloudy-clock": "",
"fog": "",
"hail": "",
"hazy": "",
"hurricane": "",
"lightning": "",
"lightning-rainy": "",
"clear-night": "",
"night-partly-cloudy": "",
"partlycloudy": "",
"partly-lightning": "",
"partly-rainy": "",
"partly-snowy": "",
"partly-snowy-rainy": "",
"pouring": "",
"rainy": "",
"snowy": "",
"snowy-heavy": "",
"snowy-rainy": "",
'sunny': '',
"sunny-alert": "",
"sunny-off": "",
"sunset": "",
"sunset-down": "",
"sunset-up": "",
"tornado": "",
"windy": "",
"windy-variant": "",
} %}
{% set days = {'Mon':'Mån','Tue':'Tis','Wed':'Ons','Thu':'Tors','Fri':'Fre','Sat':'Lör','Sun':'Sön'} %}
{% for state in states.weather.##INTEGRATION.OF.YOUR.CHOICE##.attributes.forecast[1:4] -%}
{{ days[as_timestamp(state.datetime)| timestamp_custom("%a")] }};{{state.templow| round(0)}}|{{ state.temperature| round(0) }}°;{{ state.precipitation | replace('.', ',') }}mm;{{weather[state.condition]}}#
{%- endfor %}
The esp_sensor:
text_sensor:
- platform: homeassistant
id: w_fivedays
entity_id: sensor.weather_fivedays
The font:
- file: 'fonts/MaterialDesignIconsDesktop.ttf'
id: weather_s
size: 60
glyphs:
- "\U000F0591" #fog
- "\U000F0592" #hail
- "\U000F0F30" #hazy
- "\U000F0898" #hurricane
- "\U000F0593" #lightning
- "\U000F067E" #lightning-rainy
- "\U000F0594" #night
- "\U000F0F31" #night-partly-cloudy
- "\U000F0595" #partly-cloudy
- "\U000F0F32" #partly-lightning
- "\U000F0F33" #partly-rainy
- "\U000F0F34" #partly-snowy
- "\U000F0F35" #partly-snowy-rainy
- "\U000F0596" #pouring
- "\U000F0597" #rainy
- "\U000F0598" #snowy
- "\U000F0F36" #snowy-heavy
- "\U000F067F" #snowy-rainy
- "\U000F0599" #sunny
- "\U000F0F37" #sunny-alert
- "\U000F14E4" #sunny-off
- "\U000F059A" #sunset
- "\U000F059B" #sunset-down
- "\U000F059C" #sunset-up
- "\U000F0F38" #tornado
- "\U000F059D" #windy
- "\U000F059E" #windy-variant
- "" #cloudy
- file: 'fonts/GoogleSans-Bold.ttf'
id: roboto_40
size: 40
glyphs:
['&', '@', '!', '?', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', '/', '€', '’','|']
- file: 'fonts/GoogleSans-Bold.ttf'
id: num_xs
size: 28
glyphs:
['&', '@', '!', '?', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '|', 'm']
The display lambda:
#define xRes 960
#define yRes 540
std::string fivedays = id(w_fivedays).state;
std::vector<std::string> five;
std::vector<std::string> v;
#//ESP_LOGD("%s", fivedays.c_str());
five.clear();
int count = 0;
int wx = 160; // start position x
int wy = 330; // start position y
char *token = strtok(const_cast<char*>(fivedays.c_str()), "#");
while (token != nullptr)
{
five.push_back(token);
token = strtok(nullptr, "#");
}
// here we loop the days
for ( std::string fiv : five ) {
std::string str = "";
str = fiv;
//ESP_LOGD("test: ", "String to Vector: %s", str.c_str());
v.clear();
token = strtok (&str[0],";");
while (token != NULL)
{
v.push_back(token);
token = strtok (NULL, ";");
}
// this is the loop for each value in the "day"
for ( std::string s : v ) {
if(count == 0){
// Day (Mon/Tue...)
it.printf(wx, wy+60, id(roboto_40), "%s", s.c_str());
}else if(count == 1){
// Temperature
it.printf(wx-5, wy+110, id(num_xs), "%s", s.c_str());
}else if(count == 2){
// Precipitation
it.printf(wx-15, wy+148, id(num_xs), "%s", s.c_str());
}else if(count == 3){
// weather icon
it.printf(wx+60, wy, id(weather_s), TextAlign::TOP_RIGHT, "%s", s.c_str());
}
//ESP_LOGD("test: ", "String to Vector: %s", s.c_str());
count += 1;
}
count = 0;
wx += 100; // move right 80 pixels and output next day
}