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
id: humid_livingroom
- platform: homeassistant
entity_id: sensor.wohnzimmer_co2
id: co2_livingroom
- platform: homeassistant
entity_id: sensor.temperatur_aussen
id: temp_outdoor
@ -91,16 +95,6 @@ sensor:
entity_id: sensor.schlafzimmer_luftdruck
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:
- platform: homeassistant
entity_id: sun.sun
@ -119,25 +113,11 @@ text_sensor:
attribute: next_setting
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
entity_id: sensor.moon
id: moonphase
# Webserver configuration entry
# Webserver configuration
web_server:
port: 80
# css_include: "esphome-docs/_static/webserver-v1.min.css"
@ -148,11 +128,6 @@ web_server:
username: admin
password: !secret web_server_password
sun:
latitude: id(home_lat)
longitude: id(home_long)
id: sun_sun
time:
- platform: homeassistant
id: homeassistant_time
@ -198,13 +173,13 @@ font:
- file: 'fonts/Roboto-Bold.ttf'
id: big_sensor_font
size: 80
size: 50
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_small
size: 31
glyphs: [
'󰔏', # mdi-themometer
'󰔏', # mdi-thermometer
'󰖎', # mdi-water-percent
'󰂵', # mdi-blur (pm2.5)
'󰟤', # mdi-co2
@ -219,14 +194,14 @@ font:
'󰽥', # mdi-moon-waning-crescent
'󰽦', # mdi-moon-waning-gibbous
'󰽧', # mdi-moon-waxing-crescent
'󰽨', # mdi-moon-waxing-gibbous
'󰽨' # mdi-moon-waxing-gibbous
]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_wifi
size: 20
glyphs: [
# Wifi
# WiFi
'󰤫', # mdi-wifi-strength-alert-outline
'󰤟', # mdi-wifi-strength-1
'󰤢', # mdi-wifi-strength-2
@ -265,15 +240,17 @@ display:
float livingroom_temp = id(temp_livingroom).state;
int livingroom_humid = int(id(humid_livingroom).state);
int livingroom_pm25 = int(id(pm25_livingroom).state);
float livingroom_co2 = id(co2_livingroom).state;
char sunrise[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
// desperation to format sunrise / sunset times.
// 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
struct tm tm;
memset (&tm, 0, sizeof (tm));
@ -291,27 +268,23 @@ display:
/* OUTSIDE */
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);
if(id(sun_state).has_state()) {
ESP_LOGI("Sun", "State of the sun: %s", id(sun_state).state.c_str());
ESP_LOGD("Sun", "Sunrise: %s", sunrise);
ESP_LOGD("Sun", "Sunset: %s", sunset);
ESP_LOGI("Sun", "State of the sun: %s, sunrise: %s, sunset: %s",
id(sun_state).state.c_str(), sunrise, sunset);
//if(id(sun_state).state == "above_horizon") {
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.print(135, 75, id(mdi_small), TextAlign::BASELINE_LEFT, "󰖛"); // sun-down
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(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "󰔏"); //thermometer
it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰖎"); //water-percent
it.print(250, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "󰊚"); // air pressure 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
if(outdoor_temp > -100 && outdoor_temp < 100) {
it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", outdoor_temp);
@ -377,14 +350,15 @@ display:
}
}
/* INSIDE */
/* Livingroom */
int offsetY = 137;
it.print(10, 10 + offsetY, id(big_sensor_unit), "INSIDE");
it.filled_rectangle(78, 21 + offsetY, 305, 3);
it.print(10, 10 + offsetY, id(big_sensor_unit), "Wohnzimmer");
it.filled_rectangle(136, 21 + offsetY, 247, 3);
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, 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){
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 , " - %");
}
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 > 99){
@ -420,7 +399,7 @@ display:
/* 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 */
if(id(wifisignal).has_state()) {