Petter Holt Juliussen • Mail | Mastodon | GitHub | Letterboxd

for later reference.

ESPHome

2022-01-17

CLI

https://esphome.io/guides/cli.html

docker exec -it esphome /usr/local/bin/esphome run controller.yaml

ESP32

ESP32

esphome:
  name: controller

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: !secret controller_ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Controller Fallback Hotspot"
    password: !secret controller_fallback_hotspot_password

captive_portal:

Displays

font:
  - file: "fonts/robotobold.ttf"
    id: futur
    size: 14
    glyphs: |   # Specify glyphs to include (optional)
      !"%()+=,-_.:°/0123456789ABCDEF... abcdef...
  - file: "fonts/material.ttf"
    id: material
    size: 40
    glyphs:
      - "\U000F0599" # mdi-weather-sunny
      - "\U000F0594" # mdi-weather-night

ILI9341/ILI9340C TFT LCD (SPI)

spi: 
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

display:
  - platform: ili9341
    model: TFT_2.4
    cs_pin: GPIO27
    dc_pin: GPIO25
    led_pin: GPIO32
    reset_pin: GPIO33

    lambda: |-
      it.fill(COLOR_BLACK);
      it.print(0, 0, id(font1), "Hello World!");

SSD1306 (I²C)

i2c:
  sda: GPIO2
  scl: GPIO4
sensor:
  - platform: homeassistant
    id: current_temperature
    entity_id: climate.living_room
    attribute: current_temperature

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x32"
    address: 0x3C
    lambda: |-
      std::string val = to_string((float)(id(current_temperature).state));
      it.print(0, 0, id(font1), val.c_str());
text_sensor:
  - platform: homeassistant
    id: power_consumption
    entity_id: sensor.power_consumption

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x32"
    address: 0x3C
    lambda: |-
      it.print(0, 0, id(font1), id(power_consumption).state.c_str());

Graph

sensor:
  - platform: homeassistant
    id: power_consumption
    entity_id: sensor.power_hauchs_gate_2a

graph:
  - id: power_consumption_graph
    width: 128
    height: 20
    border: false
    duration: 10min
    x_grid: 1min
    y_grid: 1000
    min_value: 0
    max_value: 3000
    traces:
      - sensor: power_consumption
        line_thickness: 1

display:
  - platform: ssd1306_i2c
    model: "SSD1306 128x32"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(font1), "%.1f W", id(power_consumption).state);
      it.graph(0, 10, id(power_consumption_graph));