I am trying to display the weather icon from Accuweather/OpenWeather/PirateWeather whichever is the simplest on a 7.5 e-paper display. I want to simulate something similar to what madelena is doing. However this requires modifying the configurations.yaml, which I would like to prevent, to improve the simplicity of integrations. Is this possible, if yes, can someone please help me to achieve this using the following yaml code?
esphome:
name: "ink-display-01"
friendly_name: Ink Display 1
on_boot:
priority: 200.0
then:
- component.update: eink_display
- delay: 10s
- logger.log: "Initial sensor data received: Refreshing display..."
- lambda: 'id(initial_data_received) = true;'
- script.execute: update_screen
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "abc"
ota:
# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!)
globals:
- id: data_updated
type: bool
restore_value: no
initial_value: 'false'
- id: initial_data_received
type: bool
restore_value: no
initial_value: 'false'
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
# Script for updating screen - Refresh display and publish refresh count and time. (Thanks @paviro!)
script:
- id: update_screen
then:
- component.update: eink_display
# Check whether the display needs to be refreshed every minute,
# based on whether new data is received or motion is detected. (Thanks @paviro!)
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Amsterdam
on_time:
- seconds: 0
minutes: /1
then:
- if:
condition:
binary_sensor.is_on: motion_detected
then:
- script.execute: update_screen
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-E1E44C"
password: "SomeRandomPasswordThatShouldBeLong&Secure"
reboot_timeout: 300s
#Include sun
sun:
latitude: 52.0116
longitude: 4.3571
# Include custom fonts
font:
- file: 'fonts/GothamRnd-Book.ttf'
id: font_small_book
size: 18
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_large_bold
size: 108
glyphs: [' ', '°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C','.']
- file: 'fonts/GothamRnd-Book.ttf'
id: font_weekday
size: 45
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_small_bold
size: 25
#glyphs: [' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'M', 'I', 'N']
- file: 'fonts/GothamRnd-Bold.ttf'
id: header_small_bold
size: 18
# glyphs: ['°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C', 'M', 'I', 'N']
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_large
size: 96
glyphs: &mdi-glyphs
- "\U000F0590" # mdi-weather-cloudy
- "\U000F0F2F" # mdi-weather-cloudy-alert
- "\U000F0E6E" # mdi-weather-cloudy-arrow-right
- "\U000F0591" # mdi-weather-fog
- "\U000F0592" # mdi-weather-hail
- "\U000F0F30" # mdi-weather-hazy
- "\U000F0898" # mdi-weather-hurricane
- "\U000F0593" # mdi-weather-lightning
- "\U000F067E" # mdi-weather-lightning-rainy
- "\U000F0594" # mdi-weather-night
- "\U000F0F31" # mdi-weather-night-partly-cloudy
- "\U000F0595" # mdi-weather-partly-cloudy
- "\U000F0F32" # mdi-weather-partly-lightning
- "\U000F0F33" # mdi-weather-partly-rainy
- "\U000F0F34" # mdi-weather-partly-snowy
- "\U000F0F35" # mdi-weather-partly-snowy-rainy
- "\U000F0596" # mdi-weather-pouring
- "\U000F0597" # mdi-weather-rainy
- "\U000F0598" # mdi-weather-snowy
- "\U000F0F36" # mdi-weather-snowy-heavy
- "\U000F067F" # mdi-weather-snowy-rainy
- "\U000F0599" # mdi-weather-sunny
- "\U000F0F37" # mdi-weather-sunny-alert
- "\U000F14E4" # mdi-weather-sunny-off
- "\U000F059A" # mdi-weather-sunset
- "\U000F059B" # mdi-weather-sunset-down
- "\U000F059C" # mdi-weather-sunset-up
- "\U000F0F38" # mdi-weather-tornado
- "\U000F059D" # mdi-weather-windy
- "\U000F059E" # mdi-weather-windy-variant
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_sun
size: 70
glyphs: *mdi-glyphs
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_medium
size: 36
glyphs: *mdi-glyphs
- file: 'fonts/materialdesignicons-webfont.ttf'
id: mdi_custom_medium
size: 30
glyphs: *mdi-glyphs
# Check if motion is detected in the Kitchen via Home Assistant.
binary_sensor:
- platform: homeassistant
entity_id: binary_sensor.kitchen_sensor_motion
id: motion_detected
# Storage Sensors
sensor:
- platform: template
name: "Display Last Update"
device_class: timestamp
entity_category: "diagnostic"
id: display_last_update
- platform: template
name: "Recorded Display Refresh"
accuracy_decimals: 0
unit_of_measurement: "Refreshes"
state_class: "total_increasing"
entity_category: "diagnostic"
lambda: 'return id(recorded_display_refresh);'
# Home Assistant Weather
# Air temperature - AccuWeather
- platform: homeassistant
entity_id: weather.home
attribute: temperature
id: weather_temperature
# Air pressure - AccuWeather
- platform: homeassistant
entity_id: weather.home
attribute: pressure
id: weather_pressure
text_sensor:
# Weather State
- platform: homeassistant
entity_id: weather.forecast_home
id: condition
# Sunrise
- platform: sun
type: sunrise
id: sun_next_rising
format: "%H:%M"
# Sunset
- platform: sun
type: sunset
id: sun_next_setting
format: "%H:%M"
# Define colors
color:
- id: color_black
red: 0%
green: 0%
blue: 0%
white: 50%
- id: color_white
red: 0%
green: 0%
blue: 0%
white: 0%
# Pins for Waveshare ePaper ESP Board
spi:
clk_pin: GPIO13
mosi_pin: GPIO14
# Now render everything on the ePaper screen.
display:
- platform: waveshare_epaper
id: eink_display
cs_pin: 15
busy_pin:
number: 25
inverted: true
reset_pin: 26
dc_pin: 27
model: 7.50inV2alt
update_interval: never
rotation: 90°
auto_clear_enabled: false
reset_duration: 2ms
lambda: |-
// Map weather states to MDI characters.
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
// Fill background in white.
it.fill(color_white);
// ---- PRINT DAY + WEEK + MONTH ----------------------------------------------------
it.strftime(25, 50, id(font_weekday), TextAlign::TOP_LEFT, "%A", id(homeassistant_time).now());
it.strftime(333, 50, id(font_weekday), TextAlign::TOP_CENTER, "%d", id(homeassistant_time).now());
it.strftime(465, 50, id(font_weekday), TextAlign::TOP_RIGHT, "%b", id(homeassistant_time).now());
// --HORIZONTAL LINE-----------------------------------------------------------------
it.rectangle(20, 110, 700, 1); //TOP
// --- TEMPERATURE --------------------------------------------------------------------
if(id(weather_temperature).has_state ()) {
it.printf(25, 130, id(font_large_bold), color_black, TextAlign::TOP_LEFT, "%2.1f°C", id(weather_temperature).state);
}
// --HORIZONTAL LINE-----------------------------------------------------------------
it.rectangle(20, 675, 710, 1); //ABOVE FOOTER
// ----SUNRISE & SUNSET----------------------------------------------------------------------
it.printf(100, 698, id(header_small_bold), color_black, TextAlign::CENTER, "SUNRISE");
if(id(sun_next_rising).has_state ()) {
it.printf(45, 725, id(font_mdi_medium), color_black, TextAlign::CENTER_LEFT, "\U000F059C");
it.printf(85, 725, id(font_small_bold), color_black, TextAlign::CENTER_LEFT, "%s", id(sun_next_rising).state.c_str());
}
it.printf(410, 698, id(header_small_bold), color_black, TextAlign::CENTER, "SUNSET");
if(id(sun_next_setting).has_state ()) {
it.printf(465, 725, id(font_mdi_medium), color_black, TextAlign::CENTER_RIGHT, "\U000F059B");
it.printf(425, 725, id(font_small_bold), color_black, TextAlign::CENTER_RIGHT, "%s", id(sun_next_setting).state.c_str());
}
// ----Print update timestamp-----------------------------------------------------------------
// Code by EnsconcE from https://community.home-assistant.io/t/esphome-show-time/348903
char str[17];
time_t currTime = id(homeassistant_time).now().timestamp;
strftime(str, sizeof(str), "%H:%M", localtime(&currTime));
it.printf(255, 790, id(font_small_book), TextAlign::BOTTOM_CENTER, "UPDATED %s", str);
captive_portal: