Added power dashboard based on environment template. Added total and serverroom meter.
This commit is contained in:
		| @@ -6,6 +6,7 @@ esphome: | ||||
|     priority: -10 | ||||
|     then: | ||||
|       - delay: 10s | ||||
|       - display.page.show: power # temporary for power page dev | ||||
|       - component.update: epaper | ||||
|  | ||||
| wifi: | ||||
| @@ -28,8 +29,8 @@ logger: | ||||
| # Enable Home Assistant API | ||||
| api: | ||||
|   password: !secret api | ||||
| #  encryption: | ||||
| #    key: !secret apikey | ||||
|   encryption: | ||||
|     key: !secret apikey | ||||
|  | ||||
| ota: | ||||
|   password: !secret ota | ||||
| @@ -118,6 +119,14 @@ sensor: | ||||
|   - platform: homeassistant | ||||
|     entity_id: sensor.serveraum_temperatur | ||||
|     id: temp_serverroom | ||||
|  | ||||
|   - platform: homeassistant | ||||
|     entity_id: sensor.line_power_total | ||||
|     id: power_total | ||||
|  | ||||
|   - platform: homeassistant | ||||
|     entity_id: sensor.serverraum_power | ||||
|     id: power_serverroom | ||||
|      | ||||
| text_sensor: | ||||
|   - platform: homeassistant | ||||
| @@ -234,7 +243,9 @@ font: | ||||
|       '', # mdi-gauge (air pressure) | ||||
|       '', # mdi-weather-sunny | ||||
|       '', # mdi-weather-sunset-down | ||||
|       '' # mdi-weather-sunset-up | ||||
|       '', # mdi-weather-sunset-up | ||||
|       '', # mdi-lightning-bolt | ||||
|       '' # mdi-transmission-tower | ||||
|       ] | ||||
|  | ||||
|   - file: 'fonts/materialdesignicons-webfont.ttf' | ||||
| @@ -327,8 +338,8 @@ display: | ||||
|           /* OUTSIDE */ | ||||
|           it.print(10, 10, id(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 [86,21], | ||||
|           a width of 297 and a height of 3 | ||||
|           */ | ||||
|           it.filled_rectangle(86, 21, 297, 3); | ||||
|  | ||||
| @@ -628,7 +639,170 @@ display: | ||||
|                 ESP_LOGI("WiFi", "Unlikely"); | ||||
|             } | ||||
|           } | ||||
|       - id: logo | ||||
|       - id: power | ||||
|         lambda: |- | ||||
|  | ||||
|           it.image(1, 48, id(c1024_logo)); | ||||
|           float total_power = id(power_total).state; | ||||
|           float serverroom_power = id(power_serverroom).state; | ||||
|           int offsetX = 0; | ||||
|           int offsetY = 0; | ||||
|  | ||||
|           /* BASEMENT */ | ||||
|           it.print(10, 10, id(sensor_unit), "Keller"); | ||||
|           /* | ||||
|           Draw the outline of a rectangle with the top left at [86,21], | ||||
|           a width of 297 and a height of 3 | ||||
|           */ | ||||
|           it.filled_rectangle(76, 21, 317, 3); | ||||
|  | ||||
|           /* C1024 logo */ | ||||
|           it.image(10 , 37, id(c1024_logo)); | ||||
|  | ||||
|           /* Livingroom */ | ||||
|           offsetY = 127; | ||||
|           it.print(10, 10 + offsetY, id(sensor_unit), "Wohnzimmer"); | ||||
|           it.filled_rectangle(136, 21 + offsetY, 247, 3); | ||||
|           /* | ||||
|           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, 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); | ||||
|           } | ||||
|           else { | ||||
|             it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); | ||||
|           } | ||||
|  | ||||
|           if(livingroom_humid >=0 && livingroom_humid <= 100) { | ||||
|             it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", livingroom_humid); | ||||
|           } | ||||
|           else { | ||||
|             it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " -  %"); | ||||
|           } | ||||
|  | ||||
|           if(livingroom_co2 >=380 && livingroom_co2 <= 20000) { | ||||
|             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"); | ||||
|           } | ||||
|           else { | ||||
|             it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); | ||||
|             it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³"); | ||||
|           } | ||||
|  | ||||
|           if(livingroom_pm25 < 255 && livingroom_pm25 >=0) { | ||||
|             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³"); | ||||
|           } | ||||
|           else { | ||||
|             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³"); | ||||
|           } | ||||
|           */ | ||||
|  | ||||
|           /* Sleepingroom */ | ||||
|           offsetY = 247; | ||||
|           it.print(10, 10 + offsetY, id(sensor_unit), "Schlafzimmer"); | ||||
|           it.filled_rectangle(144, 21 + offsetY, 239, 3); | ||||
|           /* | ||||
|           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, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, ""); // water percent | ||||
|           it.print(10, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_LEFT, ""); // CO2 | ||||
|  | ||||
|  | ||||
|           if(sleepingroom_temp > -100 && sleepingroom_temp < 100) { | ||||
|             it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1fºC", sleepingroom_temp); | ||||
|           } | ||||
|           else { | ||||
|             it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºC"); | ||||
|           } | ||||
|  | ||||
|           if(sleepingroom_humid >=0 && sleepingroom_humid <= 100) { | ||||
|             it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%3d%%", sleepingroom_humid); | ||||
|           } | ||||
|           else { | ||||
|             it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " -  %"); | ||||
|           } | ||||
|  | ||||
|           if(sleepingroom_co2 >=380 && sleepingroom_co2 <= 20000) { | ||||
|             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"); | ||||
|           } | ||||
|           else { | ||||
|             it.print(150, 75 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "- "); | ||||
|             it.print(150, 50 + offsetY, id(sensor_unit), TextAlign::BASELINE_LEFT, "ppm³"); | ||||
|           } | ||||
|  | ||||
|           if(sleepingroom_pm25 < 255 && sleepingroom_pm25 >=0) { | ||||
|             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³"); | ||||
|           } | ||||
|           else { | ||||
|             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³"); | ||||
|           } | ||||
|           */ | ||||
|  | ||||
|           /* LINEPOWER */ | ||||
|           offsetX = 390; | ||||
|           offsetY = 65; | ||||
|           it.print(10 + offsetX, 10, id(sensor_unit), "Gesamt"); | ||||
|           it.filled_rectangle(90 + offsetX, 21, 155, 3); | ||||
|  | ||||
|           it.print(227 + offsetX, 20 + offsetY,  id(mdi_small), TextAlign::BASELINE_CENTER, ""); // transmission-tower | ||||
|  | ||||
|           if(total_power > 0 && total_power < 19999) { | ||||
|             it.printf(207 + offsetX, 20 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "W"); | ||||
|             it.printf(170 + offsetX, 20 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f", total_power); | ||||
|           } | ||||
|           else { | ||||
|             it.print(207 + offsetX, 20 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W"); | ||||
|           } | ||||
|  | ||||
|           /* Serverroom */ | ||||
|           offsetY = 247; | ||||
|           it.print(10 + offsetX, 10 + offsetY, id(sensor_unit), "Serverraum"); | ||||
|           it.filled_rectangle(125 + offsetX, 21 + offsetY, 110, 3); | ||||
|  | ||||
|           it.print(227 + offsetX, 110 + offsetY,  id(mdi_small), TextAlign::BASELINE_CENTER, ""); // lightning-bolt | ||||
|  | ||||
|           if(serverroom_power > 0 && serverroom_power < 999) { | ||||
|             it.printf(207 + offsetX, 110 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "W"); | ||||
|             it.printf(170 + offsetX, 110 + offsetY, id(big_sensor_font), TextAlign::BASELINE_RIGHT, "%2.1f", serverroom_power); | ||||
|           } | ||||
|           else { | ||||
|             it.print(207 + offsetX, 110 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - W"); | ||||
|           } | ||||
|  | ||||
|           /* FOOTER */ | ||||
|           it.strftime(614, 380, 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()) { | ||||
|             int x = 630; | ||||
|             int y = 384; | ||||
|             if (id(wifisignal).state >= -50) { | ||||
|                 //Excellent | ||||
|                 it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, ""); | ||||
|                 ESP_LOGI("WiFi", "Excellent"); | ||||
|             } else if (id(wifisignal).state  >= -60) { | ||||
|                 //Good | ||||
|                 it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, ""); | ||||
|                 ESP_LOGI("WiFi", "Good"); | ||||
|             } else if (id(wifisignal).state  >= -75) { | ||||
|                 //Fair | ||||
|                 it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, ""); | ||||
|                 ESP_LOGI("WiFi", "Fair"); | ||||
|             } else if (id(wifisignal).state  >= -100) { | ||||
|                 //Weak | ||||
|                 it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, ""); | ||||
|                 ESP_LOGI("WiFi", "Weak"); | ||||
|             } else { | ||||
|                 //Unlikely working signal | ||||
|                 it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, ""); | ||||
|                 ESP_LOGI("WiFi", "Unlikely"); | ||||
|             } | ||||
|           } | ||||
		Reference in New Issue
	
	Block a user