-
-
Save Plawasan/4ae826b05aaa7812f3a191714ca47a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
esp_name: ESP Display #Device Name | |
esp_hostname: esp-display | |
ip_address: 192.168.1.107 | |
ip_gw: 192.168.1.1 | |
ip_netmask: 255.255.255.0 | |
run_time: 5min #can be as long as needed to get data | |
sleep_time: 20min # normal sleep time | |
night_sleep_time: 6h # 1st sleep time after midnight | |
esphome: | |
name: ${esp_hostname} | |
platform: ESP32 | |
board: esp32dev | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
manual_ip: | |
static_ip: ${ip_address} | |
gateway: ${ip_gw} | |
subnet: ${ip_netmask} | |
ap: | |
ssid: "${esp_name} Fallback Hotspot" | |
password: !secret ap_password | |
deep_sleep: | |
run_duration: ${run_time} | |
sleep_duration: ${sleep_time} | |
id: deep_sleep_1 | |
esp32_ext1_wakeup: | |
pins: GPIO39 | |
mode: ALL_LOW | |
captive_portal: | |
web_server: | |
port: 80 | |
include_internal: true | |
ota: | |
password: !secret ota_password | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
password: !secret ota_password | |
time: | |
- platform: homeassistant | |
id: ntp | |
spi: | |
clk_pin: 18 | |
mosi_pin: 23 | |
font: | |
- file: "Google_Sans_Bold.ttf" | |
id: font_name | |
size: 38 | |
- file: "Google_Sans_Medium.ttf" | |
id: font_value | |
size: 56 | |
- file: "Google_Sans_Medium.ttf" | |
id: font_footer | |
size: 28 | |
# https://pictogrammers.github.io/@mdi/font/5.3.45/ | |
- file: 'materialdesignicons-webfont.ttf' | |
id: font_icons | |
size: 160 | |
glyphs: | |
- "\U000F0594" # clear-night | |
- "\U000F0590" # cloudy | |
- "\U000F0595" # partlycloudy | |
- "\U000F0591" # fog | |
- "\U000F0592" # hail | |
- "\U000F0593" # lightning | |
- "\U000F067E" # lightning-rainy | |
- "\U000F0596" # pouring | |
- "\U000F0597" # rainy | |
- "\U000F0F36" # snowy | |
- "\U000F067F" # snowy-rainy | |
- "\U000F0599" # sunny | |
- "\U000F059D" # windy | |
- "\U000F059E" # windy-variant | |
- "\U000F0F38" # exceptional | |
- file: 'materialdesignicons-webfont.ttf' | |
id: font_icons_small | |
size: 56 | |
glyphs: | |
- "\U000F10C2" # Temperature High | |
- "\U000F10C3" # Temperature Low | |
- "\U000F07E4" # CO2 | |
- "\U000F054B" # umbrella | |
- "\U000F0592" # hail | |
- "\U000F0593" # lightning | |
- "\U000F067E" # lightning-rainy | |
- "\U000F0597" # rainy | |
- "\U000F0F36" # snowy | |
- "\U000F0594" # clear-night | |
- "\U000F0599" # sunny | |
- "\U000F07CA" # fuel | |
- "\U000F024A" # flower | |
- "\U000F051F" # time-remaining | |
- "\U000F140B" # Energy | |
button: | |
- platform: restart | |
name: "${esp_name} Restart" | |
- platform: template | |
name: "${esp_name} Refresh" | |
icon: "mdi:update" | |
on_press: | |
then: | |
- component.update: t5_display | |
binary_sensor: | |
- platform: gpio | |
pin: | |
number: GPIO39 | |
inverted: true | |
name: "${esp_name} Button 1" | |
on_press: | |
then: | |
- component.update: t5_display | |
- platform: gpio | |
pin: | |
number: GPIO34 | |
inverted: true | |
name: "${esp_name} Button 2" | |
- platform: gpio | |
pin: | |
number: GPIO35 | |
inverted: true | |
name: "${esp_name} Button 3" | |
sensor: | |
- platform: homeassistant | |
entity_id: sensor.external_temperature | |
id: ext_temp | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.openweathermap_forecast_precipitation_probability | |
id: prec_perc | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.openweathermap_forecast_temperature_low | |
id: fc_low | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.openweathermap_forecast_temperature | |
id: fc_high | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.livingroom_temperature | |
id: lr_temp | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.livingroom_co2 | |
id: lr_co2 | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.bedroom_temperature | |
id: br_temp | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.bedroom_co2 | |
id: br_co2 | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.passat_fuel_level | |
id: fuel_level | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.kwh_daily | |
id: kwh_daily | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.power_meter_battery_life_remaining | |
id: batt_remaining | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.aloe_vera_moisture | |
id: aloe_vera | |
internal: true | |
- platform: adc | |
pin: GPIO36 | |
name: "${esp_name} Battery Voltage" | |
id: batt_volt | |
attenuation: 11db | |
update_interval: never | |
filters: | |
- multiply: 2 | |
- platform: template | |
name: "${esp_name} Battery" | |
id: batt | |
unit_of_measurement: "%" | |
accuracy_decimals: 0 | |
device_class: battery | |
lambda: |- | |
int y = (1-(4.1-id(batt_volt).state)/(4.1-3.3))*100; | |
if (y < 100) {return y;} else {return 100;}; | |
update_interval: never | |
text_sensor: | |
- platform: homeassistant | |
entity_id: sensor.openweathermap_precipitation_kind | |
id: fc_prec | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.openweathermap_forecast_condition | |
id: fc_weather | |
internal: true | |
on_value: # Actions to perform once data for the last sensor has been received | |
then: | |
- script.execute: all_data_received | |
script: | |
- id: all_data_received | |
then: | |
- component.update: batt_volt | |
- component.update: batt | |
- component.update: t5_display | |
- script.execute: enter_sleep | |
- id: enter_sleep | |
then: | |
- if: | |
condition: | |
lambda: |- | |
auto time = id(ntp).now(); | |
if (!time.is_valid()) { | |
return false; | |
} | |
return (time.hour < 6); | |
then: | |
- logger.log: "It's nighttime, entering long sleep for ${night_sleep_time}" | |
- deep_sleep.enter: | |
id: deep_sleep_1 | |
sleep_duration: ${night_sleep_time} | |
else: | |
- logger.log: "It's daytime, entering short sleep for ${sleep_time}" | |
- deep_sleep.enter: | |
id: deep_sleep_1 | |
sleep_duration: ${sleep_time} | |
display: | |
- platform: t547 | |
id: t5_display | |
rotation: 270 | |
update_interval: never | |
lambda: |- | |
#define xres 540 | |
#define yres 960 | |
#define x_pad 10 // border padding | |
#define y_pad 10 // border padding | |
#define cat_pad 85 // padding before category | |
#define val_pad 70 // padding before value | |
#define icon_pad 35 //padding after icons | |
#define x1n 20 //x position 1st column name | |
#define x1v 25 //x position 1st column value | |
#define x1i 50 //x position 1st column icon | |
#define x2n xres/2 //x position 2nd column name | |
#define x2v xres/2 //x position 2nd column value | |
#define x2i xres/2 //x position 1st column icon | |
int y = 0; | |
// Date | |
it.strftime(xres/2, y+y_pad, id(font_name), TextAlign::TOP_CENTER, "%A %d/%b/%Y", id(ntp).now()); | |
y+=val_pad+cat_pad+10; | |
#define weather_icon_x xres/4-x_pad | |
#define gauge_radius 85 | |
#define gauge_thickness 5 | |
//it.filled_circle(weather_icon_x, y, gauge_radius, COLOR_ON); | |
//it.filled_circle(weather_icon_x, y, gauge_radius-gauge_thickness, COLOR_OFF); | |
//Weather forecast Icon | |
if (id(fc_weather).state == "clear-night") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0594");} | |
if (id(fc_weather).state == "cloudy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0590");} | |
if (id(fc_weather).state == "partlycloudy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0595");} | |
if (id(fc_weather).state == "fog") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0591");} | |
if (id(fc_weather).state == "hail") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0592");} | |
if (id(fc_weather).state == "lightning") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0593");} | |
if (id(fc_weather).state == "lightning-rainy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F067E");} | |
if (id(fc_weather).state == "pouring") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0596");} | |
if (id(fc_weather).state == "rainy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0597");} | |
if (id(fc_weather).state == "snowy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0F36");} | |
if (id(fc_weather).state == "snowy-rainy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F067F");} | |
if (id(fc_weather).state == "sunny") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0599");} | |
if (id(fc_weather).state == "windy") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F059D");} | |
if (id(fc_weather).state == "windy-variant") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F059E");} | |
if (id(fc_weather).state == "exceptional") { | |
it.printf(weather_icon_x, y, id(font_icons), TextAlign::CENTER, "\U000F0F38");} | |
// High/Low Temperature | |
it.printf(x2i+30, y-15, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F10C2"); // temp high | |
it.printf(x2i+30+icon_pad, y-10, id(font_value), TextAlign::BASELINE_LEFT, "%.1f °C", id(fc_high).state); | |
it.printf(x2i+30, y+15, id(font_icons_small), TextAlign::TOP_CENTER, "\U000F10C3"); // temp low | |
it.printf(x2i+30+icon_pad, y+10, id(font_value), TextAlign::TOP_LEFT, "%.1f °C", id(fc_low).state); | |
y+=cat_pad+50; | |
// Outside Temp + Precipitation | |
it.print(x1n, y, id(font_name), TextAlign::BASELINE_LEFT, "Outside"); | |
it.print(x2n, y, id(font_name), TextAlign::BASELINE_LEFT, "Precipitation"); | |
y+=val_pad; | |
it.printf(x1v, y, id(font_value), TextAlign::BASELINE_LEFT, "%.1f °C", id(ext_temp).state); | |
#define temp_icon_x x2i+30 | |
if (id(fc_prec).state == "None") { | |
it.printf(temp_icon_x, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F054B");} | |
if (id(fc_prec).state == "Hail") { | |
it.printf(temp_icon_x, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F0592");} | |
if (id(fc_prec).state == "Rain") { | |
it.printf(temp_icon_x, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F0597");} | |
if (id(fc_prec).state == "Snow") { | |
it.printf(temp_icon_x, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F0F36");} | |
it.printf(temp_icon_x+icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%3.0f %%", id(prec_perc).state); | |
y +=cat_pad; | |
//Living Room | |
it.print(x1n, y, id(font_name), TextAlign::BASELINE_LEFT, "Living Room"); | |
it.print(x2n, y+10, id(font_icons_small), TextAlign::BASELINE_LEFT, "\U000F07E4"); //CO2 | |
y+= val_pad; | |
it.printf(x1v, y, id(font_value), TextAlign::BASELINE_LEFT, "%.1f °C", id(lr_temp).state); | |
it.printf(x2v, y, id(font_value), TextAlign::BASELINE_LEFT, "%.0f ppm", id(lr_co2).state); | |
y += cat_pad; | |
//Bedroom | |
it.print(x1n, y, id(font_name), TextAlign::BASELINE_LEFT, "Bedroom"); | |
it.print(x2n, y+10, id(font_icons_small), TextAlign::BASELINE_LEFT, "\U000F07E4"); //CO2 | |
y+= val_pad; | |
it.printf(x1v, y, id(font_value), TextAlign::BASELINE_LEFT, "%.1f °C", id(br_temp).state); | |
it.printf(x2v, y, id(font_value), TextAlign::BASELINE_LEFT, "%.0f ppm", id(br_co2).state); | |
//Divider | |
#define div_pad 40 | |
#define div_thickness 4 | |
it.filled_rectangle(x_pad, y+div_pad, xres-2*x_pad, div_thickness); | |
y+=div_pad*3+div_thickness; | |
// Fuel and Energy | |
it.printf(x1i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F07CA"); //fuel | |
it.printf(x1i+icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.0f %%", id(fuel_level).state); | |
it.printf(x2i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F140B"); // power | |
it.printf(x2i+icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.1f kWh", id(kwh_daily).state); | |
y+=cat_pad; | |
// Plants and Battery time remaining | |
it.printf(x1i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F024A"); //flower | |
it.printf(x1i+icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.0f %%", id(aloe_vera).state); | |
it.printf(x2i, y, id(font_icons_small), TextAlign::BASELINE_CENTER, "\U000F051F"); // time remaining | |
it.printf(x2i+icon_pad, y, id(font_value), TextAlign::BASELINE_LEFT, "%.0f h", id(batt_remaining).state); | |
// Footer | |
it.strftime(x_pad, yres-y_pad/2, id(font_footer), TextAlign::BASELINE_LEFT, "Updated: %H:%M", id(ntp).now()); | |
it.printf(xres-x_pad, yres-y_pad/2, id(font_footer), TextAlign::BASELINE_RIGHT, "%.2fV/%.0f%%", id(batt_volt).state, id(batt).state); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment