Created
February 21, 2022 19:34
-
-
Save pax0r/76c8582582540ad2ee83ae3c5e3ceee2 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
esphome: | |
name: outlet_display | |
platform: ESP8266 | |
board: esp01_1m | |
logger: | |
baud_rate: 0 | |
packages: | |
wifi: !include common/wifi.yaml | |
common: !include common/common.yaml | |
i2c: | |
sda: GPIO0 | |
scl: TX | |
frequency: 800kHz | |
font: | |
- file: "graphics/arial_narrow.ttf" | |
id: my_font_small | |
size: 16 | |
- file: "graphics/arial_narrow.ttf" | |
id: my_font_big | |
size: 28 | |
image: | |
- file: "graphics/weather-clear-night.png" | |
id: icon_clear_night | |
- file: "graphics/weather-cloudy.png" | |
id: icon_cloudy | |
- file: "graphics/weather-exceptional.png" | |
id: icon_exceptional | |
- file: "graphics/weather-fog.png" | |
id: icon_fog | |
- file: "graphics/weather-hail.png" | |
id: icon_hail | |
- file: "graphics/weather-lightning.png" | |
id: icon_lightning | |
- file: "graphics/weather-lightning-rainy.png" | |
id: icon_lightning_rainy | |
- file: "graphics/weather-partlycloudy.png" | |
id: icon_partlycloudy | |
- file: "graphics/weather-pouring.png" | |
id: icon_pouring | |
- file: "graphics/weather-rainy.png" | |
id: icon_rainy | |
- file: "graphics/weather-snowy.png" | |
id: icon_snowy | |
- file: "graphics/weather-snowy-rainy.png" | |
id: icon_snowy_rainy | |
- file: "graphics/weather-sunny.png" | |
id: icon_sunny | |
- file: "graphics/weather-windy.png" | |
id: icon_windy | |
- file: "graphics/weather-windy-variant.png" | |
id: icon_windy_variant | |
- file: "graphics/weather-unknown.png" | |
id: icon_unknown | |
globals: | |
- id: weather_image | |
type: Image * | |
interval: | |
- interval: 1min | |
then: | |
- display.page.show_next: outlet_oled_display | |
- component.update: outlet_oled_display | |
script: | |
- id: refresh_image | |
then: | |
lambda: |- | |
Image *img; | |
std::string icon = id(weather_icon).state; | |
ESP_LOGD("Display", "Weather icon: %s", icon.c_str()); | |
if (icon == "clear_night") { | |
img = id(icon_clear_night); | |
} | |
else if (icon == "cloudy") { | |
img = id(icon_cloudy); | |
} | |
else if (icon == "exceptional") { | |
img = id(icon_exceptional); | |
} | |
else if (icon == "fog") { | |
img = id(icon_fog); | |
} | |
else if (icon == "hail") { | |
img = id(icon_hail); | |
} | |
else if (icon == "lightning") { | |
img = id(icon_lightning); | |
} | |
else if (icon == "lightning-rainy") { | |
img = id(icon_lightning_rainy); | |
} | |
else if (icon == "partlycloudy") { | |
img = id(icon_partlycloudy); | |
} | |
else if (icon == "pouring") { | |
img = id(icon_pouring); | |
} | |
else if (icon == "rainy") { | |
img = id(icon_rainy); | |
} | |
else if (icon == "snowy") { | |
img = id(icon_snowy); | |
} | |
else if (icon == "snowy-rainy") { | |
img = id(icon_snowy_rainy); | |
} | |
else if (icon == "sunny") { | |
img = id(icon_sunny); | |
} | |
else if (icon == "windy") { | |
img = id(icon_windy); | |
} | |
else if (icon == "windy-variant") { | |
img = id(icon_windy_variant); | |
} | |
else { | |
img = id(icon_unknown); | |
} | |
id(weather_image) = img; | |
text_sensor: | |
- platform: homeassistant | |
id: weather_icon | |
internal: true | |
entity_id: weather.dom | |
sensor: | |
- platform: homeassistant | |
id: weather_temperature | |
internal: true | |
entity_id: sensor.esp_weather_temperature | |
- platform: homeassistant | |
id: weather_humidity | |
internal: true | |
entity_id: sensor.esp_weather_humidity | |
- platform: homeassistant | |
id: weather_pressure | |
internal: true | |
entity_id: sensor.esp_weather_pressure | |
- platform: homeassistant | |
id: caqi | |
internal: true | |
entity_id: sensor.airly_caqi_numeric | |
- platform: homeassistant | |
id: wind_speed | |
internal: true | |
entity_id: sensor.esp_wind_speed | |
display: | |
- platform: ssd1306_i2c | |
id: outlet_oled_display | |
model: "SH1106 128x64" | |
address: 0x3C | |
update_interval: 1h | |
# external_vcc: true | |
pages: | |
- id: page_1 | |
lambda: |- | |
id(refresh_image).execute(); | |
it.image(0, 0, id(weather_image)); | |
it.printf(it.get_width(), 5, id(my_font_big), TextAlign::TOP_RIGHT, "%.1f°C", id(weather_temperature).state); | |
it.printf(5, 48, id(my_font_small), TextAlign::TOP_LEFT, "%.1f%%", id(weather_humidity).state); | |
it.printf(it.get_width(), 48, id(my_font_small), TextAlign::TOP_RIGHT, "%.0f hPa", id(weather_pressure).state); | |
- id: page_2 | |
lambda: |- | |
id(refresh_image).execute(); | |
it.image(0, 0, id(weather_image)); | |
it.printf(it.get_width(), 5, id(my_font_big), TextAlign::TOP_RIGHT, "%.1f°C", id(weather_temperature).state); | |
it.printf(5, 48, id(my_font_small), TextAlign::TOP_LEFT, "%.0f AQI", id(caqi).state); | |
it.printf(it.get_width(), 48, id(my_font_small), TextAlign::TOP_RIGHT, "%.1f kmh", id(wind_speed).state); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment