Kód: Vybrat vše
#-------------------------------------------
# DISPLAY
#-------------------------------------------
display:
- platform: waveshare_epaper
cs_pin: "$eink_cs_pin"
dc_pin: "$eink_dc_pin"
busy_pin: "$eink_busy_pin"
reset_pin: "$eink_reset_pin"
model: 4.20in
update_interval: never
id: eink42
pages:
#-------------------------------------------
# PAGE 1 - PAGE RUN
#-------------------------------------------
- id: pagerun
lambda: |-
//--------------------------------------------------------------------------
// START PAGE - log updating display
//--------------------------------------------------------------------------
ESP_LOGI("display", "Updating Eink42 Display...");
//--------------------------------------------------------------------------
// Define wheaterdays to string
//--------------------------------------------------------------------------
std::string weather_days = id(weatherdays).state;
//--------------------------------------------------------------------------
// Map weather states to MDI characters.
//--------------------------------------------------------------------------
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"clear-night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
//--------------------------------------------------------------------------
// Divider char
//--------------------------------------------------------------------------
char delimm = ';';
//--------------------------------------------------------------------------
// INTERNAL TEMPERATURE AND HUMIDITY SENSOR - AHT10
//--------------------------------------------------------------------------
it.printf(0, 2, id(fontpixel_height), "%.1fŘ%.0f%%", id(aht_temp).state, id(aht_humidity).state);
//--------------------------------------------------------------------------
// METEOALARM SENSOR - print text alarm
//--------------------------------------------------------------------------
if (id(meteoalarm).state) {
it.printf(66, -3, id(fonttext2), "%s", id(meteoalarm_event).state.c_str());
}
//--------------------------------------------------------------------------
// WIFI SIGNAL SENSOR mdi print
//--------------------------------------------------------------------------
int signal_wifi = int(id(signal_strange).state); //convert state to int
if (signal_wifi < 0 && signal_wifi >= -50) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BE");
}
if (signal_wifi < -50 && signal_wifi >= -70) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BD");
}
if (signal_wifi < -70 && signal_wifi >= -100) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BC");
}
else {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BF");
}
//--------------------------------------------------------------------------
// BATTERY SENSOR - mdi print
//--------------------------------------------------------------------------
float bat_level = (id(batlevel).state); //convert batlevel state to float
//>100%
if (bat_level >= 98) {
it.printf(it.get_width() -1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0079");
}
//>90%
else if (bat_level < 98 && bat_level >= 90) {
it.printf(it.get_width() -1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0082");
}
//>80%
else if (bat_level < 90 && bat_level >= 80) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0081");
}
//>70%
else if (bat_level < 80 && bat_level >= 70) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0080");
}
//>60%
else if (bat_level < 70 && bat_level >= 60) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007F");
}
//>50%
else if (bat_level < 60 && bat_level >= 50) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007E");
}
//>40%
else if (bat_level < 50 && bat_level >= 40) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007D");
}
//>30%
else if (bat_level < 40 && bat_level >= 30) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007C");
}
//>20%
else if (bat_level < 30 && bat_level >= 20) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007B");
}
//>10%
else if (bat_level < 20 && bat_level >= 10) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007A");
}
//>0%
else {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0083");
}
//--------------------------------------------------------------------------
// BATTERY CHARGE SENSOR - mdi print
//--------------------------------------------------------------------------
if (id(charger).state) {
if (bat_level >= 98) {
it.printf(392, 3, id(fonticon), TextAlign::TOP_CENTER, "\U000F0090");
} else {
it.printf(392, 3, id(fonticon), TextAlign::TOP_CENTER, "\U000F0086");
}
}
//--------------------------------------------------------------------------
// LINE
//--------------------------------------------------------------------------
it.line(0, 19, 393, 19);
//--------------------------------------------------------------------------
// TIME
//--------------------------------------------------------------------------
it.strftime(8, 5, id(fontlarge), "%H:%M", id(ds1307_time).now());
it.strftime(70, 112, id(font1), "%m.%d.%Y", id(ds1307_time).now());
it.printf(9, 112, id(font1), "%s", id(days).state.c_str());
//--------------------------------------------------------------------------
// MENINY
//--------------------------------------------------------------------------
it.printf(9, 140, id(fonttext2), "%s", id(calendar_name).state.c_str());
//--------------------------------------------------------------------------
// WEATHER NOW
//--------------------------------------------------------------------------
// temp, humidity, pressure
it.printf(260, 16, id(font2), "%.1f", id(temp_now_temp).state);
it.print(320, 23, id(font1), "°C");
it.printf(393, 23, id(font1), TextAlign::TOP_RIGHT, "%.0f%%", id(humidity_now).state);
it.printf(393, 47, id(font1), TextAlign::TOP_RIGHT, "%.0f hPa", id(pressure_now).state);
// line
it.line(260, 77, 393, 77);
// uv, wind, rain
it.printf(260, 80, id(font1), "%.1f UV", id(uv_now).state);
it.printf(310, 80, id(fonticon), "\U000F059D");
it.printf(393, 76, id(fonttext2), TextAlign::TOP_RIGHT, "%.1f km/h", id(wind_now).state);
it.printf(310, 96, id(fonticon), "\U000F0597");
it.printf(384, 90, id(fonttext2), TextAlign::TOP_RIGHT, "%.1f mm", id(rain_now).state);
// condition now
it.printf(200, 20, id(fontweater_large), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_now).state.c_str()].c_str());
//--------------------------------------------------------------------------
// WEATHER FORECAST
//--------------------------------------------------------------------------
std::size_t currentWeather, previousWeather = 0;
char delimWeather = '#';
currentWeather = weather_days.find(delimWeather);
int wx = 175; // start position x
int wy = 110; // start position y
/* Loop for the single string day */
for (int i=0; i<4; i++) {
std::string forecastInfo = weather_days.substr(previousWeather, currentWeather - previousWeather).c_str();
std::size_t currentInfo, previousInfo = 0;
currentInfo = forecastInfo.find(delimm);
/* Inner loop to get single information for each day */
for (int j=0; j<3; j++) {
if (j == 0) {
// Day (Mon/Tue...)
it.printf(wx, wy + 44, id(fonttext2), TextAlign::TOP_CENTER, "%s", forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str());
//it.line(wx + 51, wy + 5, wx + 51, wy + 65);
} else if (j == 1) {
// Temperature
it.printf(wx, wy + 32, id(fonttext3), TextAlign::TOP_CENTER, "%s", forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str());
} else if (j == 2) {
// Weather Icon
it.printf(wx, wy, id(fontweater_medium), TextAlign::TOP_CENTER, "%s", weather_icon_map[forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str()].c_str() );
}
previousInfo = currentInfo + 1;
currentInfo = forecastInfo.find(delimm, previousInfo);
}
wx += 63; // move right 50 pixels and output next day
previousWeather = currentWeather + 1;
currentWeather = weather_days.find(delimWeather, previousWeather);
}
//--------------------------------------------------------------------------
// CONSUMPTION
//--------------------------------------------------------------------------
std::string energy_house = id(energyconsumption).state;
std::size_t currentEnergy, previousEnergy = 0;
char delimEnergy = '#';
currentEnergy = energy_house.find(delimEnergy);
int x5 = 27, y5 = 205, offsetx = 100;
for (int i=0; i<4; i++) {
if (i == 0) {
it.printf(x5, y5, id(font1), TextAlign::BOTTOM_LEFT, "%skWh", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 1) {
it.printf(x5 + offsetx, y5, id(font1), TextAlign::BOTTOM_LEFT, "%sm³", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 2) {
it.printf(x5 + (offsetx * 2), y5, id(font1), TextAlign::BOTTOM_LEFT, "%sl", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 3) {
it.printf(x5 + (offsetx * 3), y5, id(font1), TextAlign::BOTTOM_LEFT, "%sW", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
previousEnergy = currentEnergy + 1;
currentEnergy = energy_house.find(delimEnergy, previousEnergy);
}
int x3 = 27, x4 = 100, y2 = 205;
it.line(0, y2 + 2, 397, y2 + 2);
it.printf(0, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F1904");
it.printf(x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F0238");
it.printf(2 * x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F058C");
it.printf(3 * x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F1A73");
//--------------------------------------------------------------------------
// ROOM AIRQUALITY AND CONTACT SENSORS
//--------------------------------------------------------------------------
// room icon and open
int x1 = 15, y1 = 209, z1 = 12, q1 = 240, p1 = 41;
//----- Zádverie -----
it.printf(x1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F109E");
if (id(magnet_zadverie).state) {
it.rectangle(x1 - 13, y1, 26, 22);
}
//-------------------Chodba
it.printf(x1 + p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0F91");
//if (id(magnet_chodba).state) {
// it.printf(51, 224, id(fonttext3), TextAlign::TOP_CENTER, "ř");
//}
//-------------------Spálňa
it.printf(x1 + 2 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F02E3");
if (id(magnet_spalna).state) {
it.rectangle(x1 + 2 * p1 - 13, y1, 27, 22);
}
//-------------------Kuchyňa
it.printf(x1 + 3 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F04DE");
if (id(magnet_kuchyna).state) {
it.rectangle(x1 + 3 * p1 - 12, y1, 24, 22);
}
//-------------------Living room
it.printf(x1 + 4 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F04B9");
if (id(magnet_obyv1).state) {
it.rectangle(x1 + 4 * p1 - 13, y1, 27, 22);
}
if (id(magnet_obyv2).state) {
it.rectangle(x1 + 4 * p1 - 13, y1, 27, 22);
}
//-------------------Bathroom
it.printf(x1 + 5 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F1819");
if (id(magnet_kup).state) {
it.rectangle(x1 + 5 * p1 - 13, y1, 26, 22);
}
//-------------------Kids room
it.printf(x1 + 6 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F18FB");
if (id(magnet_dets).state) {
it.rectangle(x1 + 6 * p1 - 13, y1, 26, 22);
}
//-------------------Basement
it.printf(x1 + 7 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0074");
if (id(magnet_piv1).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
if (id(magnet_piv2).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
if (id(magnet_piv3).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
//-------------------Roof
it.printf(x1 + 8 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F112B");
//-------------------Atelier
it.printf(x1 + 9 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0E0C");
if (id(magnet_atelier1).state) {
it.rectangle(x1 + 9 * p1 - 13, y1, 25, 22);
}
if (id(magnet_atelier2).state) {
it.rectangle(x1 + 9 * p1 - 13, y1, 25, 22);
}
//room temp and humidity
std::string air_room = id(airqualityroom).state;
std::size_t currentRoom, previousRoom = 0;
char delimRoom = '#';
currentRoom = air_room.find(delimRoom);
int x = 15, z = 12, q = 232;
for (int i=0; i<10; i++) {
std::string roomInfo = air_room.substr(previousRoom, currentRoom - previousRoom).c_str();
std::size_t temperature_air, humidity_air = 0;
char delimair = '/';
temperature_air = roomInfo.find(delimair);
/* Inner loop to get single information for each day */
for (int k=0; k<2; k++) {
if (k == 0) {
// Temperature
it.printf(x, q, id(fonttext3), TextAlign::TOP_CENTER, "%s", roomInfo.substr(humidity_air, temperature_air - humidity_air).c_str());
} else if (k == 1) {
// Humidity
it.printf(x, q + z, id(fonttext3), TextAlign::TOP_CENTER, "%s", roomInfo.substr(humidity_air, temperature_air - humidity_air).c_str());
}
humidity_air = temperature_air + 1;
temperature_air = roomInfo.find(delimair, humidity_air);
}
x += 41; // move right 50 pixels and output next day
previousRoom = currentRoom + 1;
currentRoom = air_room.find(delimRoom, previousRoom);
}
//--------------------------------------------------------------------------
// BUTTON
//--------------------------------------------------------------------------
it.print(0, 275, id(studiotiim), TextAlign::BOTTOM_LEFT, "©2022 StudioTiiM");
//BUTTON 1
it.rectangle(0, 274, 49, 24);
if (id(buttonleft).state) {
it.filled_rectangle(0, 274, 49, 24);
it.printf(25, 298, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F070D");
} else {
it.printf(25, 298, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F070D");
}
//BUTTON 2
it.rectangle(50, 274, 54, 24);
if (id(buttonmiddle).state) {
it.filled_rectangle(50, 274, 54, 24);
it.printf(76, 297, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F0D62");
} else {
it.printf(76, 297, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F0D62");
}
//BUTTON 3
it.rectangle(105, 274, 54, 24);
if (id(buttonright).state) {
it.filled_rectangle(105, 274, 54, 24);
it.printf(120, 298, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F0E69");
it.printf(159, 298, id(fonttext3), COLOR_OFF, TextAlign::BOTTOM_RIGHT, "%.0f%%", id(garden).state);
} else {
it.printf(120, 298, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F0E69");
it.printf(158, 298, id(fonttext3), COLOR_ON, TextAlign::BOTTOM_RIGHT, "%.0f%%", id(garden).state);
}
//--------------------------------------------------------------------------
// CALENDAR WASTE
//--------------------------------------------------------------------------
it.printf(it.get_width() - 54, it.get_height() - 20, id(fonttext2), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_odpad).state.c_str());
it.printf(it.get_width() - 18, it.get_height() - 22, id(fonttext3), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_odpad_time).state.c_str());
it.printf(it.get_width(), it.get_height() - 22, id(fonticon), TextAlign::BOTTOM_RIGHT, "\U000F0A7A");
//--------------------------------------------------------------------------
// CALENDAR EVENT
//--------------------------------------------------------------------------
it.printf(it.get_width() - 54, it.get_height() + 4, id(fonttext2), TextAlign::BOTTOM_RIGHT, "%s", id(calendar).state.c_str());
it.printf(it.get_width() - 18, it.get_height() + 2, id(fonttext3), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_time).state.c_str());
it.printf(it.get_width(), it.get_height() + 1, id(fonticon), TextAlign::BOTTOM_RIGHT, "\U000F00ED");
#-------------------------------------------
# PAGE 2 - PAGE SLEEP
#-------------------------------------------
- id: pagesleep
lambda: |-
//--------------------------------------------------------------------------
// START PAGE - log updating display
//--------------------------------------------------------------------------
ESP_LOGI("display", "Updating Eink42 Display...");
//--------------------------------------------------------------------------
// Define wheaterdays to string
//--------------------------------------------------------------------------
std::string weather_days = id(weatherdays).state;
//--------------------------------------------------------------------------
// Map weather states to MDI characters.
//--------------------------------------------------------------------------
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"clear-night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
//--------------------------------------------------------------------------
// Divider char
//--------------------------------------------------------------------------
char delimm = ';';
//--------------------------------------------------------------------------
// INTERNAL TEMPERATURE AND HUMIDITY SENSOR - AHT10
//--------------------------------------------------------------------------
it.printf(0, 2, id(fontpixel_height), "%.1fŘ%.0f%%", id(aht_temp).state, id(aht_humidity).state);
//--------------------------------------------------------------------------
// METEOALARM SENSOR - print text alarm
//--------------------------------------------------------------------------
if (id(meteoalarm).state) {
it.printf(66, -3, id(fonttext2), "%s", id(meteoalarm_event).state.c_str());
}
//--------------------------------------------------------------------------
// SLEEP STATUS
//--------------------------------------------------------------------------
it.printf(368, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F04B2");
//it.printf(250, 175, id(font2), TextAlign::TOP_CENTER, "I AM SLEEPING");
//--------------------------------------------------------------------------
// WIFI SIGNAL SENSOR mdi print
//--------------------------------------------------------------------------
int signal_wifi = int(id(signal_strange).state); //convert state to int
if (signal_wifi < 0 && signal_wifi >= -50) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BE");
}
if (signal_wifi < -50 && signal_wifi >= -70) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BD");
}
if (signal_wifi < -70 && signal_wifi >= -100) {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BC");
}
else {
it.printf(386, 4, id(fonticon), TextAlign::TOP_RIGHT, "\U000F08BF");
}
//--------------------------------------------------------------------------
// BATTERY SENSOR - mdi print
//--------------------------------------------------------------------------
float bat_level = (id(batlevel).state); //convert batlevel state to float
//>100%
if (bat_level >= 98) {
it.printf(it.get_width() -1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0079");
}
//>90%
else if (bat_level < 98 && bat_level >= 90) {
it.printf(it.get_width() -1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0082");
}
//>80%
else if (bat_level < 90 && bat_level >= 80) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0081");
}
//>70%
else if (bat_level < 80 && bat_level >= 70) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0080");
}
//>60%
else if (bat_level < 70 && bat_level >= 60) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007F");
}
//>50%
else if (bat_level < 60 && bat_level >= 50) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007E");
}
//>40%
else if (bat_level < 50 && bat_level >= 40) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007D");
}
//>30%
else if (bat_level < 40 && bat_level >= 30) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007C");
}
//>20%
else if (bat_level < 30 && bat_level >= 20) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007B");
}
//>10%
else if (bat_level < 20 && bat_level >= 10) {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F007A");
}
//>0%
else {
it.printf(it.get_width() - 1, 3, id(fonticon), TextAlign::TOP_RIGHT, "\U000F0083");
}
//--------------------------------------------------------------------------
// BATTERY CHARGE SENSOR - mdi print
//--------------------------------------------------------------------------
if (id(charger).state) {
if (bat_level >= 98) {
it.printf(392, 3, id(fonticon), TextAlign::TOP_CENTER, "\U000F0090");
} else {
it.printf(392, 3, id(fonticon), TextAlign::TOP_CENTER, "\U000F0086");
}
}
//--------------------------------------------------------------------------
// LINE
//--------------------------------------------------------------------------
it.line(0, 19, 393, 19);
//--------------------------------------------------------------------------
// TIME
//--------------------------------------------------------------------------
it.strftime(8, 5, id(fontlarge), "%H:%M", id(ds1307_time).now());
it.strftime(70, 112, id(font1), "%m.%d.%Y", id(ds1307_time).now());
it.printf(9, 112, id(font1), "%s", id(days).state.c_str());
//--------------------------------------------------------------------------
// MENINY
//--------------------------------------------------------------------------
it.printf(9, 140, id(fonttext2), "%s", id(calendar_name).state.c_str());
//--------------------------------------------------------------------------
// WEATHER NOW
//--------------------------------------------------------------------------
// temp, humidity, pressure
it.printf(260, 16, id(font2), "%.1f", id(temp_now_temp).state);
it.print(320, 23, id(font1), "°C");
it.printf(393, 23, id(font1), TextAlign::TOP_RIGHT, "%.0f%%", id(humidity_now).state);
it.printf(393, 47, id(font1), TextAlign::TOP_RIGHT, "%.0f hPa", id(pressure_now).state);
// line
it.line(260, 77, 393, 77);
// uv, wind, rain
it.printf(260, 80, id(font1), "%.1f UV", id(uv_now).state);
it.printf(310, 80, id(fonticon), "\U000F059D");
it.printf(393, 76, id(fonttext2), TextAlign::TOP_RIGHT, "%.1f km/h", id(wind_now).state);
it.printf(310, 96, id(fonticon), "\U000F0597");
it.printf(384, 90, id(fonttext2), TextAlign::TOP_RIGHT, "%.1f mm", id(rain_now).state);
// condition now
it.printf(200, 20, id(fontweater_large), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_now).state.c_str()].c_str());
//--------------------------------------------------------------------------
// WEATHER FORECAST
//--------------------------------------------------------------------------
std::size_t currentWeather, previousWeather = 0;
char delimWeather = '#';
currentWeather = weather_days.find(delimWeather);
int wx = 175; // start position x
int wy = 110; // start position y
/* Loop for the single string day */
for (int i=0; i<4; i++) {
std::string forecastInfo = weather_days.substr(previousWeather, currentWeather - previousWeather).c_str();
std::size_t currentInfo, previousInfo = 0;
currentInfo = forecastInfo.find(delimm);
/* Inner loop to get single information for each day */
for (int j=0; j<3; j++) {
if (j == 0) {
// Day (Mon/Tue...)
it.printf(wx, wy + 44, id(fonttext2), TextAlign::TOP_CENTER, "%s", forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str());
//it.line(wx + 51, wy + 5, wx + 51, wy + 65);
} else if (j == 1) {
// Temperature
it.printf(wx, wy + 32, id(fonttext3), TextAlign::TOP_CENTER, "%s", forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str());
} else if (j == 2) {
// Weather Icon
it.printf(wx, wy, id(fontweater_medium), TextAlign::TOP_CENTER, "%s", weather_icon_map[forecastInfo.substr(previousInfo, currentInfo - previousInfo).c_str()].c_str() );
}
previousInfo = currentInfo + 1;
currentInfo = forecastInfo.find(delimm, previousInfo);
}
wx += 63; // move right 50 pixels and output next day
previousWeather = currentWeather + 1;
currentWeather = weather_days.find(delimWeather, previousWeather);
}
//--------------------------------------------------------------------------
// CONSUMPTION
//--------------------------------------------------------------------------
std::string energy_house = id(energyconsumption).state;
std::size_t currentEnergy, previousEnergy = 0;
char delimEnergy = '#';
currentEnergy = energy_house.find(delimEnergy);
int x5 = 27, y5 = 205, offsetx = 100;
for (int i=0; i<4; i++) {
if (i == 0) {
it.printf(x5, y5, id(font1), TextAlign::BOTTOM_LEFT, "%skWh", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 1) {
it.printf(x5 + offsetx, y5, id(font1), TextAlign::BOTTOM_LEFT, "%sm³", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 2) {
it.printf(x5 + (offsetx * 2), y5, id(font1), TextAlign::BOTTOM_LEFT, "%sl", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
else if (i == 3) {
it.printf(x5 + (offsetx * 3), y5, id(font1), TextAlign::BOTTOM_LEFT, "%sW", energy_house.substr(previousEnergy, currentEnergy - previousEnergy).c_str());
}
previousEnergy = currentEnergy + 1;
currentEnergy = energy_house.find(delimEnergy, previousEnergy);
}
int x3 = 27, x4 = 100, y2 = 205;
it.line(0, y2 + 2, 397, y2 + 2);
it.printf(0, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F1904");
it.printf(x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F0238");
it.printf(2 * x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F058C");
it.printf(3 * x4, y2 - 2, id(fonticon_room), TextAlign::BOTTOM_LEFT, "\U000F1A73");
//--------------------------------------------------------------------------
// ROOM AIRQUALITY
//--------------------------------------------------------------------------
// room icon and open
int x1 = 15, y1 = 209, z1 = 12, q1 = 240, p1 = 41;
//----- Zádverie -----
it.printf(x1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F109E");
if (id(magnet_zadverie).state) {
it.rectangle(x1 - 13, y1, 26, 22);
}
//-------------------Chodba
it.printf(x1 + p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0F91");
//if (id(magnet_chodba).state) {
// it.printf(51, 224, id(fonttext3), TextAlign::TOP_CENTER, "ř");
//}
//-------------------Spálňa
it.printf(x1 + 2 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F02E3");
if (id(magnet_spalna).state) {
it.rectangle(x1 + 2 * p1 - 13, y1, 27, 22);
}
//-------------------Kuchyňa
it.printf(x1 + 3 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F04DE");
if (id(magnet_kuchyna).state) {
it.rectangle(x1 + 3 * p1 - 12, y1, 24, 22);
}
//-------------------Living room
it.printf(x1 + 4 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F04B9");
if (id(magnet_obyv1).state) {
it.rectangle(x1 + 4 * p1 - 13, y1, 27, 22);
}
if (id(magnet_obyv2).state) {
it.rectangle(x1 + 4 * p1 - 13, y1, 27, 22);
}
//-------------------Bathroom
it.printf(x1 + 5 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F1819");
if (id(magnet_kup).state) {
it.rectangle(x1 + 5 * p1 - 13, y1, 26, 22);
}
//-------------------Kids room
it.printf(x1 + 6 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F18FB");
if (id(magnet_dets).state) {
it.rectangle(x1 + 6 * p1 - 13, y1, 26, 22);
}
//-------------------Basement
it.printf(x1 + 7 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0074");
if (id(magnet_piv1).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
if (id(magnet_piv2).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
if (id(magnet_piv3).state) {
it.rectangle(x1 + 7 * p1 - 13, y1, 25, 22);
}
//-------------------Roof
it.printf(x1 + 8 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F112B");
//-------------------Atelier
it.printf(x1 + 9 * p1, y1, id(fonticon_room), TextAlign::TOP_CENTER, "\U000F0E0C");
if (id(magnet_atelier1).state) {
it.rectangle(x1 + 9 * p1 - 13, y1, 25, 22);
}
if (id(magnet_atelier2).state) {
it.rectangle(x1 + 9 * p1 - 13, y1, 25, 22);
}
//room temp and humidity
std::string air_room = id(airqualityroom).state;
std::size_t currentRoom, previousRoom = 0;
char delimRoom = '#';
currentRoom = air_room.find(delimRoom);
int x = 15, z = 12, q = 232;
for (int i=0; i<10; i++) {
std::string roomInfo = air_room.substr(previousRoom, currentRoom - previousRoom).c_str();
std::size_t temperature_air, humidity_air = 0;
char delimair = '/';
temperature_air = roomInfo.find(delimair);
/* Inner loop to get single information for each day */
for (int k=0; k<2; k++) {
if (k == 0) {
// Temperature
it.printf(x, q, id(fonttext3), TextAlign::TOP_CENTER, "%s", roomInfo.substr(humidity_air, temperature_air - humidity_air).c_str());
} else if (k == 1) {
// Humidity
it.printf(x, q + z, id(fonttext3), TextAlign::TOP_CENTER, "%s", roomInfo.substr(humidity_air, temperature_air - humidity_air).c_str());
}
humidity_air = temperature_air + 1;
temperature_air = roomInfo.find(delimair, humidity_air);
}
x += 41; // move right 50 pixels and output next day
previousRoom = currentRoom + 1;
currentRoom = air_room.find(delimRoom, previousRoom);
}
//--------------------------------------------------------------------------
// BUTTON
//--------------------------------------------------------------------------
it.print(0, 275, id(studiotiim), TextAlign::BOTTOM_LEFT, "©2022 StudioTiiM");
//BUTTON 1
it.rectangle(0, 274, 49, 24);
if (id(buttonleft).state) {
it.filled_rectangle(0, 274, 49, 24);
it.printf(25, 298, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F070D");
} else {
it.printf(25, 298, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F070D");
}
//BUTTON 2
it.rectangle(50, 274, 54, 24);
if (id(buttonmiddle).state) {
it.filled_rectangle(50, 274, 54, 24);
it.printf(76, 297, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F0D62");
} else {
it.printf(76, 297, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F0D62");
}
//BUTTON 3
it.rectangle(105, 274, 54, 24);
if (id(buttonright).state) {
it.filled_rectangle(105, 274, 54, 24);
it.printf(120, 298, id(fonticon_room), COLOR_OFF, TextAlign::BOTTOM_CENTER, "\U000F0E69");
it.printf(159, 298, id(fonttext3), COLOR_OFF, TextAlign::BOTTOM_RIGHT, "%.0f%%", id(garden).state);
} else {
it.printf(120, 298, id(fonticon_room), COLOR_ON, TextAlign::BOTTOM_CENTER, "\U000F0E69");
it.printf(158, 298, id(fonttext3), COLOR_ON, TextAlign::BOTTOM_RIGHT, "%.0f%%", id(garden).state);
}
//--------------------------------------------------------------------------
// CALENDAR WASTE
//--------------------------------------------------------------------------
it.printf(it.get_width() - 54, it.get_height() - 20, id(fonttext2), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_odpad).state.c_str());
it.printf(it.get_width() - 18, it.get_height() - 22, id(fonttext3), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_odpad_time).state.c_str());
it.printf(it.get_width(), it.get_height() - 22, id(fonticon), TextAlign::BOTTOM_RIGHT, "\U000F0A7A");
//--------------------------------------------------------------------------
// CALENDAR EVENT
//--------------------------------------------------------------------------
it.printf(it.get_width() - 54, it.get_height() + 4, id(fonttext2), TextAlign::BOTTOM_RIGHT, "%s", id(calendar).state.c_str());
it.printf(it.get_width() - 18, it.get_height() + 2, id(fonttext3), TextAlign::BOTTOM_RIGHT, "%s", id(calendar_time).state.c_str());
it.printf(it.get_width(), it.get_height() + 1, id(fonticon), TextAlign::BOTTOM_RIGHT, "\U000F00ED");
#-------------------------------------------
# FONTS
#-------------------------------------------
font:
- file: 'fonts/studiotiim.ttf'
id: studiotiim
size: 14
glyphs:
['0', '2', 'M', 'S', 'T', ' ', 'a', 'd', 'i', 'n', 'o', 't', 'u', '©',]
- file: 'fonts/steelfishedit.ttf'
id: font1
size: 24
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/font_bd.ttf'
id: font2
size: 54
- file: 'fonts/euxoi.ttf'
id: fonttext
size: 18
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/bahnschrift2.ttf'
id: fonttext2
size: 18
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/pixeloperator.ttf'
id: fonttext3
size: 14
glyphs:
['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'Ř', 'ř', '°', 'C', '/', '%', '.',
'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', '-', 'W',]
- file: 'fonts/pixeloperator-height.ttf'
id: fontpixel_height
size: 18
glyphs:
['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'Ř', 'ř', '°', 'C', '/', '%', '.',
'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/font-bd-large.ttf'
id: fontlarge
size: 100
- file: 'fonts/icons.ttf'
id: fonticon
size: 16
glyphs: [
"\U000F0079", # battery full
"\U000F0082", # battery 90
"\U000F0081", # battery 80
"\U000F0080", # battery 70
"\U000F007F", # battery 60
"\U000F007E", # battery 50
"\U000F007D", # battery 40
"\U000F007C", # battery 30
"\U000F007B", # battery 20
"\U000F007A", # battery 10
"\U000F0083", # battery empty
"\U000F0086", # battery empty charging
"\U000F0090", # battery empty full 100%
"\U000F08BF", # no wifi
"\U000F08BC", # wifi low
"\U000F08BD", # mwifi middle
"\U000F08BE", # wifi high
"\U000F06A5", # power
"\U000F10C2", # temp
"\U000F058E", # HUMIDITY
"\U000F0875", # PRESSURE
"\U000F1358", # GAS
"\U000F1402", # MOTOR
"\U000F1357", # WATER TANK
"\U000F1067", # PUMP
"\U000F0A7A", # WASTE TRASH
"\U000F00ED", # CALENDAR
"\U000F04E0", # SUNGLASS UV
"\U000F059D", # WIND
"\U000F0597", # RAIN
"\U000F05B1", # WINDOW OPEN
"\U000F04B2" # SLEEP
]
- file: 'fonts/icons.ttf'
id: fonticon_room
size: 24
glyphs: [
"\U000F109E", # 1 VESTIBUL RACK COAT
"\U000F0F91", # 2 HALLWAY CLOSET
"\U000F02E3", # 3 BED
"\U000F04DE", # 4 STOVE KITCHEN
"\U000F04B9", # 5 SOFA LIVING ROOM
"\U000F18FB", # 6 TEDDY KIDS ROOM
"\U000F1819", # 7 BATHROOM
"\U000F0290", # 8 FRIDGE
"\U000F0074", # 9 barrel stair BASEMENT
"\U000F0379", # 10 MONITOR PRACOVŇA
"\U000F112B", # 11 ROOF
"\U000F0E0C", # 12 ATELIER
"\U000F1904", # ELEKTROMER
"\U000F0238", # PLYNOMER
"\U000F1A73", # SOLAR
"\U000F058C", # LEAK, VODOMER
"\U000F070D", # VACCUM
"\U000F0D62", # AC
"\U000F0E69", # TREE GARDEN PUMP
]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: fontweater_large
size: 96
glyphs: &mdi-weather-glyphs
- "\U000F0590" # mdi-weather-cloudy
- "\U000F0F2F" # mdi-weather-cloudy-alert
- "\U000F0E6E" # mdi-weather-cloudy-arrow-right
- "\U000F0591" # mdi-weather-fog
- "\U000F0592" # mdi-weather-hail
- "\U000F0F30" # mdi-weather-hazy
- "\U000F0898" # mdi-weather-hurricane
- "\U000F0593" # mdi-weather-lightning
- "\U000F067E" # mdi-weather-lightning-rainy
- "\U000F0594" # mdi-weather-night
- "\U000F0F31" # mdi-weather-night-partly-cloudy
- "\U000F0595" # mdi-weather-partly-cloudy
- "\U000F0F32" # mdi-weather-partly-lightning
- "\U000F0F33" # mdi-weather-partly-rainy
- "\U000F0F34" # mdi-weather-partly-snowy
- "\U000F0F35" # mdi-weather-partly-snowy-rainy
- "\U000F0596" # mdi-weather-pouring
- "\U000F0597" # mdi-weather-rainy
- "\U000F0598" # mdi-weather-snowy
- "\U000F0F36" # mdi-weather-snowy-heavy
- "\U000F067F" # mdi-weather-snowy-rainy
- "\U000F0599" # mdi-weather-sunny
- "\U000F0F37" # mdi-weather-sunny-alert
- "\U000F14E4" # mdi-weather-sunny-off
- "\U000F059A" # mdi-weather-sunset
- "\U000F059B" # mdi-weather-sunset-down
- "\U000F059C" # mdi-weather-sunset-up
- "\U000F0F38" # mdi-weather-tornado
- "\U000F059D" # mdi-weather-windy
- "\U000F059E" # mdi-weather-windy-variant
- file: 'fonts/materialdesignicons-webfont.ttf'
id: fontweater_medium
size: 36
glyphs: *mdi-weather-glyphs
#-------------------------------------------
# TIMER
#-------------------------------------------
time:
- platform: ds1307
id: ds1307_time
timezone: "Europe/Bratislava"
update_interval: never
on_time:
- seconds: 0 # needs to be set, otherwise every second this is triggered!
minutes: /1 # Trigger every minute
# hours: 23
# days_of_week: MON-FRI
then:
if:
condition:
binary_sensor.is_on: time_accept_update
then:
component.update: eink42
# time sync whit internet
- platform: homeassistant
id: time_home
timezone: "Europe/Bratislava"
on_time_sync:
then:
ds1307.write_time: