Skip to content

Image Configuration in ESPHome

The image system in ESPHome allows using graphical elements to create a rich user interface. Let's examine the structure and application of different image types.

This project uses a separate image.yaml file, which is included in main.yaml

Image Configuration Structure

Basic Format

yaml
- file: 'img/weather/sunny.png'
  id: sunny_img
  type: rgb565
  resize: 100x100
  transparency: alpha_channel

Configuration Parameters

file

Purpose: Path to image file

  • Supported formats: .png, .jpg, .bmp
  • Path relative to ESPHome project root
  • PNG recommended for images with transparency

id

Purpose: Unique image identifier

  • Used for referencing in LVGL widgets
  • Format: category_name_img
  • Example: sunny_img, battery_high_img

type

Purpose: Image storage format in memory

  • rgb565 — 16-bit color (recommended)
  • rgb — 24-bit color (not supported by device)
  • grayscale — full grayscale
  • binary — monochrome images

resize

Purpose: Image resizing

  • Format: width x height
  • Performed at compile time
  • Saves memory and processing time

transparency

Purpose: Transparency handling

  • alpha_channel — use PNG alpha channel
  • Omit parameter — no transparency

Image Categories

1. Logos and Branding

yaml
#############################
########### LOGO ############
#############################

- file: 'img/loading/homeassistant.png'
  id: ha_img
  type: rgb565
  resize: 400x82
  transparency: alpha_channel

- file: 'img/loading/esphome.png'
  id: esphome_img
  type: rgb565
  resize: 320x95
  transparency: alpha_channel

Application: Loading screens, splash screens, branding

  • Home Assistant: 400×82 pixels
  • ESPHome: 320×95 pixels
  • Used during system startup

2. Lighting

yaml
#############################
########## LIGHT ############
#############################

- file: 'img/light/lightbulb.png'
  id: lightbulb_image
  type: rgb565
  transparency: alpha_channel

- file: 'img/light/rgb_ring.png'
  id: rgb_img
  type: rgb565
  transparency: alpha_channel

Application: Lighting control interface

  • Lightbulb: Main lighting icon
  • RGB ring: Color selector for RGB lamps
  • No resizing (original size)

3. Robot Vacuum

yaml
#############################
########## VACUUM ###########
#############################

Animation frame set: 17 images for vacuum animation

  • Size: 200×200 pixels (standardized)
  • Rotation angles: 0°, 5°, 10°, 15°, 20°, 340°, 345°, 350°, 355°
  • Additional tilted positions: 0_10, 0_20, 0_30, 20_10, 20_20, 20_30, 340_10, 340_20, 340_30

Animation Logic

ImageAngleDescription
vacuum_imgBaseStatic position
vacuum_0_imgForward movement
vacuum_5_img5° turn
vacuum_10_img10°10° turn
vacuum_15_img15°15° turn
vacuum_20_img20°20° turn
vacuum_340_img340°20° backward turn
vacuum_345_img345°15° backward turn
vacuum_350_img350°10° backward turn
vacuum_355_img355°5° backward turn

Application: Creating smooth vacuum movement animation

4. Weather

yaml
#############################
########## WEATHER ##########
#############################

Complete weather conditions set: 15 images

  • Size: 100×100 pixels (optimal for widgets)
  • Covers all major weather conditions

Daytime Conditions

IDFileDescription
sunny_imgsunny.pngClear, sunny
partlycloudy_sun_imgpartlycloudy_sun.pngPartly cloudy (day)
cloudy_imgcloudy.pngCloudy

Nighttime Conditions

IDFileDescription
clear_night_imgclear_night.pngClear night
partlycloudy_moon_imgpartlycloudy_moon.pngPartly cloudy (night)

Precipitation

IDFileDescription
rainy_imgrainy.pngRain
pouring_imgpouring.pngHeavy rain
snowy_imgsnowy.pngSnow
snowy_rainy_imgsnowy_rainy.pngRain with snow
hail_imghail.pngHail

Special Conditions

IDFileDescription
fog_imgfog.pngFog
lightning_imglightning.pngThunderstorm
lightning_rainy_imglightning_rainy.pngThunderstorm with rain
windy_imgwindy.pngWindy
windy_variant_imgwindy_variant.pngStrong wind

5. Country Flags

yaml
#############################
########## FLAGS ############
#############################

Interface localization: 18 country flags

  • Size: 60×80 pixels (3:4 ratio)
  • Standardized size for language selector

Supported Countries

CodeCountryID
deGermanyflags_de_img
esSpainflags_es_img
frFranceflags_fr_img
gbUnited Kingdomflags_gb_img
itItalyflags_it_img
krSouth Koreaflags_kr_img
ptPortugalflags_pt_img
ruRussiaflags_ru_img
usUnited Statesflags_us_img
plPolandflags_pl_img
trTurkeyflags_tr_img
svSwedenflags_sv_img
idIndonesiaflags_id_img
viVietnamflags_vi_img
roRomaniaflags_ro_img
nlNetherlandsflags_nl_img
huHungaryflags_hu_img
csCzech Republicflags_cs_img
fiFinlandflags_fi_img

6. Battery Indicators

yaml
#############################
########## BATTERY ##########
#############################

Two indicator sets:

For Battery Charge Status

IDLevelDescription
battery_very_high_img90-100%Very high
battery_high_img70-89%High
battery_middle_img40-69%Medium
battery_low_img20-39%Low
battery_very_low_img5-19%Very low
battery_empty_img0-4%Empty

For Battery Charging Animation

IDLevelApplication
battery_80_img80%Almost full
battery_60_img60%More than half
battery_40_img40%Less than half
battery_20_img20%Needs charging
battery_0_img0%Empty

Memory Optimization

Image Sizes

CategorySizeMemory (approx.)Application
Flags60×809.6 KBLanguage selector
Weather100×10020 KBWeather widgets
Vacuum200×20080 KBAnimation
Logos400×8265.6 KBSplash screens

Practical Usage

In LVGL Widgets

yaml
# Static image
- img:
    src: sunny_img
    align: center

# Animation
- animimg:
    src: [ 
      battery_0_img,
      battery_20_img,
      battery_40_img,
      battery_60_img,
      battery_80_img,
      battery_very_high_img,
    ]

Conclusion

A properly organized image system provides:

  • Visual appeal — beautiful and modern interface
  • Intuitiveness — user-friendly visual elements
  • Performance — optimized memory usage
  • Scalability — easy addition of new elements

Use the proposed structure as a foundation and adapt it to your needs while maintaining organization and optimization principles.