Added, CO2, removed obsolete sensors, minor code cleanups, minor design modifications.

This commit is contained in:
Marcus Scholz 2021-10-09 02:55:13 +02:00
parent 42cc970a41
commit bba90cf32f

View File

@ -79,6 +79,10 @@ sensor:
entity_id: sensor.wohnzimmer_luftfeuchtigkeit entity_id: sensor.wohnzimmer_luftfeuchtigkeit
id: humid_livingroom id: humid_livingroom
- platform: homeassistant
entity_id: sensor.wohnzimmer_co2
id: co2_livingroom
- platform: homeassistant - platform: homeassistant
entity_id: sensor.temperatur_aussen entity_id: sensor.temperatur_aussen
id: temp_outdoor id: temp_outdoor
@ -91,16 +95,6 @@ sensor:
entity_id: sensor.schlafzimmer_luftdruck entity_id: sensor.schlafzimmer_luftdruck
id: airpressure id: airpressure
- platform: homeassistant
entity_id: zone.home
attribute: latitude
id: home_lat
- platform: homeassistant
entity_id: zone.home
attribute: longitude
id: home_long
text_sensor: text_sensor:
- platform: homeassistant - platform: homeassistant
entity_id: sun.sun entity_id: sun.sun
@ -119,25 +113,11 @@ text_sensor:
attribute: next_setting attribute: next_setting
internal: True internal: True
# - platform: sun
# name: "Nächster Sonnenaufgang"
# id: sun_rise
# type: sunrise
# format: "%H:%M"
# internal: True
# - platform: sun
# name: "Nächster Sonnenuntergang"
# id: sun_set
# type: sunset
# format: "%H:%M"
# internal: True
- platform: homeassistant - platform: homeassistant
entity_id: sensor.moon entity_id: sensor.moon
id: moonphase id: moonphase
# Webserver configuration entry # Webserver configuration
web_server: web_server:
port: 80 port: 80
# css_include: "esphome-docs/_static/webserver-v1.min.css" # css_include: "esphome-docs/_static/webserver-v1.min.css"
@ -148,11 +128,6 @@ web_server:
username: admin username: admin
password: !secret web_server_password password: !secret web_server_password
sun:
latitude: id(home_lat)
longitude: id(home_long)
id: sun_sun
time: time:
- platform: homeassistant - platform: homeassistant
id: homeassistant_time id: homeassistant_time
@ -172,7 +147,7 @@ font:
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', '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', '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', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'ä', 'ö', '/','º','µ','³','ß'] 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/', 'º', 'µ', '³', 'ß']
- file: 'fonts/Roboto-Regular.ttf' - file: 'fonts/Roboto-Regular.ttf'
id: big_sensor_unit id: big_sensor_unit
@ -183,7 +158,7 @@ font:
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', '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', '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', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/','º','µ','³','ß'] 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/', 'º', 'µ', '³', 'ß']
- file: 'fonts/Roboto-Medium.ttf' - file: 'fonts/Roboto-Medium.ttf'
id: sub_sensor_font id: sub_sensor_font
@ -194,17 +169,17 @@ font:
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', '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', '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', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/','º','µ','³','ß'] 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/', 'º', 'µ', '³', 'ß']
- file: 'fonts/Roboto-Bold.ttf' - file: 'fonts/Roboto-Bold.ttf'
id: big_sensor_font id: big_sensor_font
size: 80 size: 50
- file: 'fonts/materialdesignicons-webfont.ttf' - file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_small id: mdi_small
size: 31 size: 31
glyphs: [ glyphs: [
'󰔏', # mdi-themometer '󰔏', # mdi-thermometer
'󰖎', # mdi-water-percent '󰖎', # mdi-water-percent
'󰂵', # mdi-blur (pm2.5) '󰂵', # mdi-blur (pm2.5)
'󰟤', # mdi-co2 '󰟤', # mdi-co2
@ -219,14 +194,14 @@ font:
'󰽥', # mdi-moon-waning-crescent '󰽥', # mdi-moon-waning-crescent
'󰽦', # mdi-moon-waning-gibbous '󰽦', # mdi-moon-waning-gibbous
'󰽧', # mdi-moon-waxing-crescent '󰽧', # mdi-moon-waxing-crescent
'󰽨', # mdi-moon-waxing-gibbous '󰽨' # mdi-moon-waxing-gibbous
] ]
- file: 'fonts/materialdesignicons-webfont.ttf' - file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_wifi id: mdi_wifi
size: 20 size: 20
glyphs: [ glyphs: [
# Wifi # WiFi
'󰤫', # mdi-wifi-strength-alert-outline '󰤫', # mdi-wifi-strength-alert-outline
'󰤟', # mdi-wifi-strength-1 '󰤟', # mdi-wifi-strength-1
'󰤢', # mdi-wifi-strength-2 '󰤢', # mdi-wifi-strength-2
@ -265,15 +240,17 @@ display:
float livingroom_temp = id(temp_livingroom).state; float livingroom_temp = id(temp_livingroom).state;
int livingroom_humid = int(id(humid_livingroom).state); int livingroom_humid = int(id(humid_livingroom).state);
int livingroom_pm25 = int(id(pm25_livingroom).state); int livingroom_pm25 = int(id(pm25_livingroom).state);
float livingroom_co2 = id(co2_livingroom).state;
char sunrise[5] = ""; char sunrise[5] = "";
char sunset[5] = ""; char sunset[5] = "";
/*
This is Commander1024 doing awful string / time fuckerey full of
desperation to format sunrise / sunset times.
Don't be like Commander1024
// This is Commander1024 doing awful string / time fuckerey full of Format: 2021-10-08T05:40:47.467076+00:00 -> 7:40 (dst)
// desperation to format sunrise / sunset times. */
// Don't be like Commander1024
// 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));
@ -291,27 +268,23 @@ display:
/* OUTSIDE */ /* OUTSIDE */
it.print(10, 10, id(big_sensor_unit), "Umwelt"); it.print(10, 10, id(big_sensor_unit), "Umwelt");
// Draw the outline of a rectangle with the top left at [78,21], a width of 305 and a height of 3 /*
Draw the outline of a rectangle with the top left at [78,21],
a width of 305 and a height of 3
*/
it.filled_rectangle(86, 21, 297, 3); it.filled_rectangle(86, 21, 297, 3);
if(id(sun_state).has_state()) { if(id(sun_state).has_state()) {
ESP_LOGI("Sun", "State of the sun: %s", id(sun_state).state.c_str()); ESP_LOGI("Sun", "State of the sun: %s, sunrise: %s, sunset: %s",
ESP_LOGD("Sun", "Sunrise: %s", sunrise); id(sun_state).state.c_str(), sunrise, sunset);
ESP_LOGD("Sun", "Sunset: %s", sunset);
//if(id(sun_state).state == "above_horizon") { it.print(10, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖜"); // sun-up
it.print(10, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖜"); //sun-up
it.printf(50, 75, id(big_sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunrise); it.printf(50, 75, id(big_sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunrise);
it.print(135, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); //sun-down it.print(135, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); // sun-down
it.printf(175, 75, id(big_sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunset); it.printf(175, 75, id(big_sensor_unit), TextAlign::BASELINE_LEFT, "%s", sunset);
//}
//else {
//it.print(10, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); //sun-down
//it.strftime(50, 75, id(footer_font), TextAlign::BASELINE_LEFT, "Nächster Sonnenaufgang %d.%m.%Y %H:%M", id(sun_rise));
//}
} }
it.print(250, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰊚"); //air-pressure it.print(250, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰊚"); // air pressure icon
it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); //thermometer it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); // thermometer icon
it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); //water-percent 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);
@ -327,10 +300,10 @@ display:
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) { //Has valid value if(air_pressure < 1200 && air_pressure >=800) { // Has valid value
it.printf(228, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1fhPa", air_pressure); it.printf(228, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%4.1fhPa", air_pressure);
} }
else { //Invalid or error value else { // Invalid or error value
it.print(228, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "- hPa"); it.print(228, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "- hPa");
} }
@ -377,14 +350,15 @@ display:
} }
} }
/* INSIDE */ /* Livingroom */
int offsetY = 137; int offsetY = 137;
it.print(10, 10 + offsetY, id(big_sensor_unit), "INSIDE"); it.print(10, 10 + offsetY, id(big_sensor_unit), "Wohnzimmer");
it.filled_rectangle(78, 21 + offsetY, 305, 3); it.filled_rectangle(136, 21 + offsetY, 247, 3);
it.print(10, 114 + offsetY, id(big_sensor_unit), TextAlign::BASELINE_LEFT, "PM2.5"); it.print(10, 114 + offsetY, id(big_sensor_unit), 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
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);
@ -398,6 +372,11 @@ display:
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){
it.printf(50, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_LEFT , "%4.1fppm", livingroom_co2);
}else{
it.print(50, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_LEFT , " - ppm");
}
if(livingroom_pm25 < 255 && livingroom_pm25 >=0){ if(livingroom_pm25 < 255 && livingroom_pm25 >=0){
if (livingroom_pm25 > 99){ if (livingroom_pm25 > 99){
@ -409,18 +388,18 @@ display:
} }
if(livingroom_pm25 >= pm25_danger_thres){ if(livingroom_pm25 >= pm25_danger_thres){
it.print(37, 87 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); //warning it.print(37, 87 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "󰀦"); // warning
} }
} }
else{ else {
it.print(175, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT , "- "); it.print(175, 114 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT , "- ");
it.print(180, 114 + offsetY, id(big_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³"); it.print(180, 114 + offsetY, id(big_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
} }
/* FOOTER */ /* FOOTER */
it.strftime(610, 374 , id(footer_font), TextAlign::BASELINE_RIGHT , "Letzte Aktualisierung %d.%m.%Y %H:%M", id(homeassistant_time).now()); it.strftime(610, 374 , 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()) {