esphome:
name: oled_screen_spi
platform: ESP8266
board: nodemcuv2
wifi:
ssid:
password: "
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Oled Screen Fallback Hotspot"
password:
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
- platform: homeassistant
id: kitchen_temperature
entity_id: sensor.front_door_multisensor_temperature
internal: true
- platform: homeassistant
id: kitchen_humidity
entity_id: sensor.front_door_multisensor_humidity
internal: true
font:
- file: "Comic Sans MS.ttf"
id: my_font
size: 9
time:
- platform: homeassistant
id: esptime
spi:
clk_pin: D0
mosi_pin: D1
display:
- platform: ssd1306_spi
model: "SSD1306 128x64"
cs_pin: D2
dc_pin: D3
reset_pin: D4
lambda: |-
// Print "Mitt Smarta Hus" in top center.
it.printf(64, 0, id(my_font), TextAlign::TOP_CENTER, "WILDING HOME");
// Print time in HH:MM format
it.strftime(0, 60, id(my_font), TextAlign::BASELINE_LEFT, "%H:%M", id(esptime).now());
// Print kitchen_temperature(from homeassistant sensor)
if (id(kitchen_temperature).has_state()) {
it.printf(127, 23, id(my_font), TextAlign::TOP_RIGHT , "%.1f°", id(kitchen_temperature).state);
}
// Print outside temperature (from homeassistant sensor)
if (id(kitchen_humidity).has_state()) {
it.printf(127, 60, id(my_font), TextAlign::BASELINE_RIGHT , "%.1f°", id(kitchen_humidity).state);
}