Various changes to layout and sensors.

This commit is contained in:
Marcus Scholz 2021-12-02 15:23:28 +01:00
parent 75c7c918fe
commit a54654226b

View File

@ -50,6 +50,22 @@ binary_sensor:
format: 'Button pressed, refreshing screen!' format: 'Button pressed, refreshing screen!'
- component.update: epaper - component.update: epaper
# Switch to next page
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: True
name: "Next page"
internal: True
on_click:
then:
- logger.log:
level: INFO
format: 'Button pressed, rendering next page!'
- display.page.show_next: epaper
- component.update: epaper
# DHT22 sensor # DHT22 sensor
sensor: sensor:
- platform: dht - platform: dht
@ -268,6 +284,11 @@ font:
'󰀦' # mdi-alert '󰀦' # mdi-alert
] ]
image:
- file: "epaperframe/C1024_logo_flat.png"
id: c1024_logo
type: binary
spi: spi:
clk_pin: 23 clk_pin: 23
mosi_pin: 32 mosi_pin: 32
@ -282,355 +303,361 @@ display:
model: 7.50in model: 7.50in
# full_update_every: 30 # not supported on this display # full_update_every: 30 # not supported on this display
update_interval: never update_interval: never
lambda: |- pages:
- id: environment
int pm25_danger_thres = 40; lambda: |-
float outdoor_temp = id(temp_outdoor).state; int pm25_danger_thres = 40;
int outdoor_humid = int(id(humid_outdoor).state);
float air_pressure = id(airpressure).state; float outdoor_temp = id(temp_outdoor).state;
float livingroom_temp = id(temp_livingroom).state; int outdoor_humid = int(id(humid_outdoor).state);
int livingroom_humid = int(id(humid_livingroom).state); float air_pressure = id(airpressure).state;
int livingroom_pm25 = int(id(pm25_livingroom).state); float livingroom_temp = id(temp_livingroom).state;
float livingroom_co2 = id(co2_livingroom).state; int livingroom_humid = int(id(humid_livingroom).state);
float sleepingroom_temp = id(temp_sleepingroom).state; int livingroom_pm25 = int(id(pm25_livingroom).state);
int sleepingroom_humid = int(id(humid_sleepingroom).state); float livingroom_co2 = id(co2_livingroom).state;
int sleepingroom_pm25 = int(id(pm25_sleepingroom).state); float sleepingroom_temp = id(temp_sleepingroom).state;
float sleepingroom_co2 = id(co2_sleepingroom).state; int sleepingroom_humid = int(id(humid_sleepingroom).state);
float serverroom_temp = id(temp_serverroom).state; int sleepingroom_pm25 = int(id(pm25_sleepingroom).state);
int serverroom_humid = id(humid_serverroom).state; float sleepingroom_co2 = id(co2_sleepingroom).state;
char sunrise[5] = ""; float serverroom_temp = id(temp_serverroom).state;
char sunset[5] = ""; int serverroom_humid = id(humid_serverroom).state;
int offsetX = 0; char sunrise[5] = "";
int offsetY = 0; char sunset[5] = "";
int offsetX = 0;
int offsetY = 0;
/* /*
This is Commander1024 doing awful string / time fuckerey full of This is Commander1024 doing awful string / time fuckerey full of
desperation to format sunrise / sunset times. desperation to format sunrise / sunset times.
Don't be like Commander1024 Don't be like Commander1024
Format: 2021-10-08T05:40:47.467076+00:00 -> 7:40 (dst) Format: 2021-10-08T05:40:47.467076+00:00 -> 7:40 (dst)
*/ */
int dst = id(homeassistant_time).now().is_dst; // returns 1 for dst, otherwise 0 int dst = id(homeassistant_time).now().is_dst; // returns 1 for dst, otherwise 0
struct tm tm; struct tm tm;
memset (&tm, 0, sizeof (tm)); memset (&tm, 0, sizeof (tm));
strptime(id(sun_rise).state.c_str(), "%Y-%m-%dT%H:%M:%S", &tm); strptime(id(sun_rise).state.c_str(), "%Y-%m-%dT%H:%M:%S", &tm);
time_t rawtime = mktime(&tm); time_t rawtime = mktime(&tm);
struct tm* ltm = localtime(&rawtime); struct tm* ltm = localtime(&rawtime);
sprintf(sunrise, "%d:%02d", ltm->tm_hour + dst, ltm->tm_min); sprintf(sunrise, "%d:%02d", ltm->tm_hour + dst, ltm->tm_min);
memset (&tm, 0, sizeof (tm)); memset (&tm, 0, sizeof (tm));
strptime(id(sun_set).state.c_str(), "%Y-%m-%dT%H:%M:%S", &tm); strptime(id(sun_set).state.c_str(), "%Y-%m-%dT%H:%M:%S", &tm);
rawtime = mktime(&tm); rawtime = mktime(&tm);
ltm = localtime(&rawtime); ltm = localtime(&rawtime);
sprintf(sunset, "%d:%02d", ltm->tm_hour + dst, ltm->tm_min); sprintf(sunset, "%d:%02d", ltm->tm_hour + dst, ltm->tm_min);
/* OUTSIDE */ /* OUTSIDE */
it.print(10, 10, id(sensor_unit), "Umwelt"); it.print(10, 10, id(sensor_unit), "Umwelt");
/* /*
Draw the outline of a rectangle with the top left at [78,21], Draw the outline of a rectangle with the top left at [78,21],
a width of 305 and a height of 3 a width of 305 and a height of 3
*/ */
it.filled_rectangle(86, 21, 297, 3); it.filled_rectangle(86, 21, 297, 3);
it.print(10, 115, id(mdi_small), TextAlign::BASELINE_LEFT, "󰊚"); // air pressure icon it.print(10, 115, id(mdi_small), TextAlign::BASELINE_LEFT, "󰊚"); // air pressure icon
it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer icon it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer icon
it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent icon it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent icon
if(outdoor_temp > -100 && outdoor_temp < 100) { if(outdoor_temp > -100 && outdoor_temp < 100) {
it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", outdoor_temp); it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", outdoor_temp);
} }
else { else {
it.print(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); it.print(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC");
} }
if(outdoor_humid >=0 && outdoor_humid <= 100) { if(outdoor_humid >=0 && outdoor_humid <= 100) {
it.printf(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", outdoor_humid); it.printf(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", outdoor_humid);
} }
else { else {
it.print(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); it.print(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
} }
if(air_pressure < 1200 && air_pressure >=800) { if(air_pressure < 1200 && air_pressure >=800) {
it.printf(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1f", air_pressure); it.printf(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1f", air_pressure);
it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa");
} }
else { else {
it.print(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); it.print(220, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- ");
it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa"); it.print(225, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "hPa");
} }
/* Livingroom */ /* Livingroom */
offsetY = 127; offsetY = 127;
it.print(10, 10 + offsetY, id(sensor_unit), "Wohnzimmer"); it.print(10, 10 + offsetY, id(sensor_unit), "Wohnzimmer");
it.filled_rectangle(136, 21 + offsetY, 247, 3); it.filled_rectangle(136, 21 + offsetY, 247, 3);
it.print(10, 114 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰮬"); // PM2.5 it.print(10, 114 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰮬"); // PM2.5
it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent
it.print(10, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰟤"); // CO2 it.print(10, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰟤"); // CO2
if(livingroom_temp > -100 && livingroom_temp < 100) { if(livingroom_temp > -100 && livingroom_temp < 100) {
it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", livingroom_temp); it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", livingroom_temp);
} }
else { else {
it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC");
} }
if(livingroom_humid >=0 && livingroom_humid <= 100) { if(livingroom_humid >=0 && livingroom_humid <= 100) {
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", livingroom_humid); it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", livingroom_humid);
} }
else { else {
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
} }
if(livingroom_co2 >=380 && livingroom_co2 <= 20000) { if(livingroom_co2 >=380 && livingroom_co2 <= 20000) {
it.printf(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.0f", livingroom_co2); it.printf(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.0f", livingroom_co2);
it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm"); it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm");
} }
else { else {
it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- ");
it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³"); it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³");
} }
if(livingroom_pm25 < 255 && livingroom_pm25 >=0) { if(livingroom_pm25 < 255 && livingroom_pm25 >=0) {
it.printf(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%3d", livingroom_pm25); it.printf(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%3d", livingroom_pm25);
it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³"); it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³");
if(livingroom_pm25 >= pm25_danger_thres) { if(livingroom_pm25 >= pm25_danger_thres) {
it.print(37, 114 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); // warning it.print(37, 114 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); // warning
} }
} }
else { else {
it.print(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); it.print(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- ");
it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³"); it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³");
} }
/* Sleepingroom */ /* Sleepingroom */
offsetY = 247; offsetY = 247;
it.print(10, 10 + offsetY, id(sensor_unit), "Schlafzimmer"); it.print(10, 10 + offsetY, id(sensor_unit), "Schlafzimmer");
it.filled_rectangle(144, 21 + offsetY, 239, 3); it.filled_rectangle(144, 21 + offsetY, 239, 3);
it.print(10, 114 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰮬"); // PM2.5 it.print(10, 114 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰮬"); // PM2.5
it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent
it.print(10, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰟤"); // CO2 it.print(10, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, "󰟤"); // CO2
if(sleepingroom_temp > -100 && sleepingroom_temp < 100) { if(sleepingroom_temp > -100 && sleepingroom_temp < 100) {
it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", sleepingroom_temp); it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", sleepingroom_temp);
} }
else { else {
it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC");
} }
if(sleepingroom_humid >=0 && sleepingroom_humid <= 100) { if(sleepingroom_humid >=0 && sleepingroom_humid <= 100) {
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", sleepingroom_humid); it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", sleepingroom_humid);
} }
else { else {
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
} }
if(sleepingroom_co2 >=380 && sleepingroom_co2 <= 20000) { if(sleepingroom_co2 >=380 && sleepingroom_co2 <= 20000) {
it.printf(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.0f", sleepingroom_co2); it.printf(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%4.0f", sleepingroom_co2);
it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm"); it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm");
} }
else { else {
it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- ");
it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³"); it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³");
} }
if(sleepingroom_pm25 < 255 && sleepingroom_pm25 >=0) { if(sleepingroom_pm25 < 255 && sleepingroom_pm25 >=0) {
it.printf(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%3d", sleepingroom_pm25); it.printf(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%3d", sleepingroom_pm25);
it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³"); it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³");
if(sleepingroom_pm25 >= pm25_danger_thres) { if(sleepingroom_pm25 >= pm25_danger_thres) {
it.print(37, 114 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); // warning it.print(37, 114 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); // warning
} }
} }
else { else {
it.print(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); it.print(200, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- ");
it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³"); it.print(205, 114 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "µg/m³");
} }
/* Weather */ /* Weather */
offsetX = 390; offsetX = 390;
it.print(10 + offsetX, 10, id(sensor_unit), "Wetter"); it.print(10 + offsetX, 10, id(sensor_unit), "Wetter");
it.filled_rectangle(80 + offsetX, 21, 155, 3); it.filled_rectangle(80 + offsetX, 21, 155, 3);
/* Current weather */ /* Current weather */
if(id(weather).has_state()) { if(id(weather).has_state()) {
int x = 227 + offsetX; int x = 227 + offsetX;
int y = 116; int y = 116;
if (id(weather).state == "clear-night") { if (id(weather).state == "clear-night") {
// clear night // clear night
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖔"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖔");
ESP_LOGI("Weather", "clear night"); ESP_LOGI("Weather", "clear night");
} else if (id(weather).state == "cloudy") { } else if (id(weather).state == "cloudy") {
// cloudy // cloudy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖐"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖐");
ESP_LOGI("Weather", "cloudy"); ESP_LOGI("Weather", "cloudy");
} else if (id(weather).state == "fog") { } else if (id(weather).state == "fog") {
// fog // fog
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖑"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖑");
ESP_LOGI("Weather", "fog"); ESP_LOGI("Weather", "fog");
} else if (id(weather).state == "hail") { } else if (id(weather).state == "hail") {
// hail // hail
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖒"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖒");
ESP_LOGI("Weather", "hail"); ESP_LOGI("Weather", "hail");
} else if (id(weather).state == "lightning") { } else if (id(weather).state == "lightning") {
// lightning // lightning
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖓"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖓");
ESP_LOGI("Weather", "lightning"); ESP_LOGI("Weather", "lightning");
} else if (id(weather).state == "lightning-rainy") { } else if (id(weather).state == "lightning-rainy") {
// lightning-rainy // lightning-rainy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰙾"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰙾");
ESP_LOGI("Weather", "lightning-rainy"); ESP_LOGI("Weather", "lightning-rainy");
} else if (id(weather).state == "partlycloudy") { } else if (id(weather).state == "partlycloudy") {
// partly cloudy // partly cloudy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖕"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖕");
ESP_LOGI("Weather", "partlycloudy"); ESP_LOGI("Weather", "partlycloudy");
} else if (id(weather).state == "pouring") { } else if (id(weather).state == "pouring") {
// pouring // pouring
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖖"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖖");
ESP_LOGI("Weather", "pouring"); ESP_LOGI("Weather", "pouring");
} else if (id(weather).state == "rainy") { } else if (id(weather).state == "rainy") {
// rainy // rainy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖗"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖗");
ESP_LOGI("Weather", "rainy"); ESP_LOGI("Weather", "rainy");
} else if (id(weather).state == "snowy") { } else if (id(weather).state == "snowy") {
// snowy // snowy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖘"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖘");
ESP_LOGI("Weather", "snowy"); ESP_LOGI("Weather", "snowy");
} else if (id(weather).state == "snowy-rainy") { } else if (id(weather).state == "snowy-rainy") {
// snowy-rainy // snowy-rainy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰙿"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰙿");
ESP_LOGI("Weather", "snowy-rainy"); ESP_LOGI("Weather", "snowy-rainy");
} else if (id(weather).state == "sunny") { } else if (id(weather).state == "sunny") {
// sunny // sunny
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖙"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖙");
ESP_LOGI("Weather", "sunny"); ESP_LOGI("Weather", "sunny");
} else if (id(weather).state == "windy") { } else if (id(weather).state == "windy") {
// windy // windy
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖝"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖝");
ESP_LOGI("Weather", "windy"); ESP_LOGI("Weather", "windy");
} else if (id(weather).state == "windy-variant") { } else if (id(weather).state == "windy-variant") {
// windy variant // windy variant
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖞"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰖞");
ESP_LOGI("Weather", "windy variant"); ESP_LOGI("Weather", "windy variant");
} else if (id(weather).state == "exceptional") { } else if (id(weather).state == "exceptional") {
// exceptional // exceptional
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰳥"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_RIGHT, "󰳥");
ESP_LOGI("Weather", "exceptional"); ESP_LOGI("Weather", "exceptional");
} else { } else {
// N/A // N/A
it.print(x, y, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "-"); it.print(x, y, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "-");
ESP_LOGE("Weather", "No data"); ESP_LOGE("Weather", "No data");
} }
} }
/* Moon phase display */ /* Moon phase display */
if(id(moonphase).has_state()) { if(id(moonphase).has_state()) {
int x = 10 + offsetX; int x = 10 + offsetX;
int y = 200; int y = 200;
if (id(moonphase).state == "new_moon") { if (id(moonphase).state == "new_moon") {
// new moon // new moon
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽤"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽤");
ESP_LOGI("Moonphase", "new moon"); ESP_LOGI("Moonphase", "new moon");
} else if (id(moonphase).state == "waxing_crescent") { } else if (id(moonphase).state == "waxing_crescent") {
// waxing crescent // waxing crescent
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽧"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽧");
ESP_LOGI("Moonphase", "waxing crescent"); ESP_LOGI("Moonphase", "waxing crescent");
} else if (id(moonphase).state == "first_quarter") { } else if (id(moonphase).state == "first_quarter") {
// first_quarter // first_quarter
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽡"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽡");
ESP_LOGI("Moonphase", "first quarter"); ESP_LOGI("Moonphase", "first quarter");
} else if (id(moonphase).state == "waxing_gibbous") { } else if (id(moonphase).state == "waxing_gibbous") {
// waxing gibbous // waxing gibbous
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽨"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽨");
ESP_LOGI("Moonphase", "waxing gibbous"); ESP_LOGI("Moonphase", "waxing gibbous");
} else if (id(moonphase).state == "full_moon") { } else if (id(moonphase).state == "full_moon") {
// full moon // full moon
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽢"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽢");
ESP_LOGI("Moonphase", "full moon"); ESP_LOGI("Moonphase", "full moon");
} else if (id(moonphase).state == "waning_gibbous") { } else if (id(moonphase).state == "waning_gibbous") {
// waning gibbous // waning gibbous
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽦"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽦");
ESP_LOGI("Moonphase", "waning gibbous"); ESP_LOGI("Moonphase", "waning gibbous");
} else if (id(moonphase).state == "last_quarter") { } else if (id(moonphase).state == "last_quarter") {
// last quarter // last quarter
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽣"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽣");
ESP_LOGI("Moonphase", "last quarter"); ESP_LOGI("Moonphase", "last quarter");
} else if (id(moonphase).state == "waning_crescent") { } else if (id(moonphase).state == "waning_crescent") {
// waning crescent // waning crescent
it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽥"); it.print(x, y, id(mdi_weather), TextAlign::BASELINE_LEFT, "󰽥");
ESP_LOGI("Moonphase", "waning crescent"); ESP_LOGI("Moonphase", "waning crescent");
} else { } else {
// N/A // N/A
it.print(x, y, id(big_sensor_font), TextAlign::BASELINE_LEFT, "-"); it.print(x, y, id(big_sensor_font), TextAlign::BASELINE_LEFT, "-");
ESP_LOGE("Moonphase", "No data"); ESP_LOGE("Moonphase", "No data");
} }
} }
if(id(sun_state).has_state()) { if(id(sun_state).has_state()) {
ESP_LOGI("Sun", "State of the sun: %s, sunrise: %s, sunset: %s", ESP_LOGI("Sun", "State of the sun: %s, sunrise: %s, sunset: %s",
id(sun_state).state.c_str(), sunrise, sunset); id(sun_state).state.c_str(), sunrise, sunset);
it.print(10 + offsetX, 250, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖜"); // sun-up it.print(10 + offsetX, 250, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖜"); // sun-up
it.printf(50 + offsetX, 250, id(sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunrise); it.printf(50 + offsetX, 250, id(sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunrise);
it.print(135 + offsetX, 250, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); // sun-down it.print(135 + offsetX, 250, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); // sun-down
it.printf(175 + offsetX, 250, id(sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunset); it.printf(175 + offsetX, 250, id(sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunset);
} }
/* Serverroom */ /* Serverroom */
offsetY = 247; offsetY = 247;
it.print(10 + offsetX, 10 + offsetY, id(sensor_unit), "Serverraum"); it.print(10 + offsetX, 10 + offsetY, id(sensor_unit), "Serverraum");
it.filled_rectangle(125 + offsetX, 21 + offsetY, 110, 3); it.filled_rectangle(125 + offsetX, 21 + offsetY, 110, 3);
it.print(227 + offsetX, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer it.print(227 + offsetX, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer
it.print(227+ offsetX, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent it.print(227+ offsetX, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); // water percent
if(serverroom_temp > -100 && serverroom_temp < 100) { if(serverroom_temp > -100 && serverroom_temp < 100) {
it.printf(207 + offsetX, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", serverroom_temp); it.printf(207 + offsetX, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", serverroom_temp);
} }
else { else {
it.print(207 + offsetX, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); it.print(207 + offsetX, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC");
} }
if(serverroom_humid >=0 && serverroom_humid <= 100) { if(serverroom_humid >=0 && serverroom_humid <= 100) {
it.printf(207 + offsetX, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", serverroom_humid); it.printf(207 + offsetX, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", serverroom_humid);
} }
else { else {
it.print(207 + offsetX, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %"); it.print(207 + offsetX, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
} }
/* FOOTER */ /* FOOTER */
it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT , "Aktualisiert um %d.%m.%Y %H:%M", id(homeassistant_time).now()); it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT , "Aktualisiert um %d.%m.%Y %H:%M", id(homeassistant_time).now());
/* WiFi Signal Strenght */ /* WiFi Signal Strenght */
if(id(wifisignal).has_state()) { if(id(wifisignal).has_state()) {
int x = 630; int x = 630;
int y = 384; int y = 384;
if (id(wifisignal).state >= -50) { if (id(wifisignal).state >= -50) {
//Excellent //Excellent
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤨"); it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤨");
ESP_LOGI("WiFi", "Excellent"); ESP_LOGI("WiFi", "Excellent");
} else if (id(wifisignal).state >= -60) { } else if (id(wifisignal).state >= -60) {
//Good //Good
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤥"); it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤥");
ESP_LOGI("WiFi", "Good"); ESP_LOGI("WiFi", "Good");
} else if (id(wifisignal).state >= -75) { } else if (id(wifisignal).state >= -75) {
//Fair //Fair
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤢"); it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤢");
ESP_LOGI("WiFi", "Fair"); ESP_LOGI("WiFi", "Fair");
} else if (id(wifisignal).state >= -100) { } else if (id(wifisignal).state >= -100) {
//Weak //Weak
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤟"); it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤟");
ESP_LOGI("WiFi", "Weak"); ESP_LOGI("WiFi", "Weak");
} else { } else {
//Unlikely working signal //Unlikely working signal
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤫"); it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "󰤫");
ESP_LOGI("WiFi", "Unlikely"); ESP_LOGI("WiFi", "Unlikely");
} }
} }
- id: logo
lambda: |-
it.image(1, 48, id(c1024_logo));