Рет қаралды 19,157
This is a tutorial on how to get started with using ESPHome with Home Assistant. We will cover how to set up an ESP8266 board, connect an OLED screen, measure temperature, display images and even create animations.
esphome:
name: d1-mini-temp
esp8266:
board: d1_mini
Enable logging
logger:
Enable Home Assistant API
api:
encryption:
key: "S3gVtKEEdQWu/5ZMAbDesKPK8Jm9qOjvKUCYxk0Rjxo="
ota:
password: "71911a7597da612ebb2089ea2022d0ad"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "D1-Mini-Temp Fallback Hotspot"
password: "0M16lTUlhf8i"
dallas:
- pin: D4
update_interval: 5s
sensor:
- platform: dallas
address: 0x8f3cb60457362d28
id: WZ
name: "WZ"
- platform: dallas
address: 0xe53c7604577dcf28
id: WP
name: "WP"
font:
- file: "arial.ttf"
id: font1
size: 12
- file: "lcdmn.ttf"
id: font2
size: 20
time:
- platform: homeassistant
id: esptime
text_sensor:
- platform: template
name: "TCP/IP Address"
lambda: 'return {WiFi.localIP().toString().c_str()};'
id: tcp_ip_address
animation:
- file: "ludzik.gif"
id: my_animation
resize: 64x64
i2c:
sda: D2
scl: D1
scan: false
display:
- platform: ssd1306_i2c
model: SSD1306_128X64
address: 0x3C
id: my_display
pages:
- id: page1
lambda: |-
it.print(40, 0, id(font1), "JKproj");
it.printf(0, 25, id(font1), TextAlign::BASELINE_LEFT, "WP: %.1f°C", id(WP).state);
it.printf(0, 38, id(font1), TextAlign::BASELINE_LEFT, "WZ: %.1f°C", id(WZ).state);
it.strftime(65, 38, id(font2), TextAlign::BASELINE_LEFT, "%H:%M",id(esptime).now());
it.printf(15, 50, id(font1), "%s", id(tcp_ip_address).state.c_str());
- id: page2
lambda: |-
it.print(40, 0, id(font1), "JKproj");
it.circle(64, 40, 23);
it.circle(55, 30, 2);
it.circle(74, 30, 2);
it.print(61, 45, id(font1), "O");
- id: page3
lambda: |-
id(my_animation).next_frame();
it.image(32, 0, id(my_animation), COLOR_ON, COLOR_OFF);
interval:
- interval: 5s
then:
- display.page.show_next: my_display
- component.update: my_display
captive_portal: