Last active
July 9, 2023 16:39
-
-
Save tubalainen/04ff58e58e8394fb6bf061226503abf3 to your computer and use it in GitHub Desktop.
ESPHome with display SSD1306 OLED display
This file contains hidden or 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: displaylabb | |
platform: ESP8266 | |
board: d1_mini | |
wifi: | |
ssid: 'meh' | |
password: 'bbeeeh' | |
ap: | |
ssid: "DisplabbFallback Hotspot" | |
# password: "rCdopOHEnjsj" | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
ota: | |
web_server: | |
port: 80 | |
time: | |
- platform: sntp | |
id: time_ntp | |
timezone: Europe/Stockholm | |
servers: 192.168.21.10 | |
binary_sensor: | |
- platform: homeassistant | |
name: "PIR Framtisdan" | |
internal: True | |
entity_id: binary_sensor.shelly_19_switch | |
id: pir_framsidan | |
on_press: | |
then: | |
- display.page.show: rorelse | |
- component.update: my_display | |
- delay: 5s | |
- display.page.show_next: my_display | |
- component.update: my_display | |
- platform: status | |
name: "Displaylabb Status" | |
- platform: gpio | |
pin: | |
number: D3 | |
inverted: True | |
name: "Displaylabb knapp 1" | |
filters: | |
- delayed_on: 10ms | |
- delayed_off: 10ms | |
on_press: | |
then: | |
- homeassistant.service: | |
service: input_boolean.turn_on | |
data: | |
entity_id: input_boolean.enable_rpisurv | |
- homeassistant.service: | |
service: light.turn_on | |
data: | |
entity_id: light.lampa_ikea_rgb | |
color_name: 'goldenrod' | |
on_release: | |
then: | |
- homeassistant.service: | |
service: input_boolean.turn_off | |
data: | |
entity_id: input_boolean.enable_rpisurv | |
- homeassistant.service: | |
service: light.turn_on | |
data: | |
entity_id: light.lampa_ikea_rgb | |
color_name: 'navajowhite' | |
- homeassistant.service: | |
service: automation.trigger | |
data: | |
entity_id: automation.rpisurv_overview | |
sensor: | |
- platform: wifi_signal | |
name: "Displaylabb wifi signal" | |
update_interval: 60s | |
- platform: homeassistant | |
id: office_temperature | |
entity_id: sensor.kontoret_temperature | |
internal: true | |
- platform: homeassistant | |
id: outside_temperature | |
entity_id: sensor.auriolv2_4101_temp | |
internal: true | |
- platform: homeassistant | |
id: rain | |
entity_id: sensor.netatmo_regnmatare_sum_rain_24 | |
internal: true | |
- platform: homeassistant | |
id: octoprint_pct | |
entity_id: sensor.octoprint_job_percentage | |
internal: true | |
text_sensor: | |
- platform: homeassistant | |
entity_id: alarm_control_panel.verisure_alarm | |
name: "Alarm State" | |
id: alarm_state | |
internal: true | |
- platform: homeassistant | |
entity_id: device_tracker.life360_helena | |
name: "Where is Mamman" | |
id: mamman | |
internal: true | |
- platform: homeassistant | |
entity_id: variable.last_motion | |
name: "Last motion indoor" | |
id: last_motion_indoor | |
internal: true | |
- platform: homeassistant | |
entity_id: variable.last_motion_outdoor | |
name: "Last motion outdoor" | |
id: last_motion_outdoor | |
internal: true | |
- platform: homeassistant | |
entity_id: sensor.verisure_larmstatus | |
name: "Verisure Larmstatus" | |
id: verisure_larmstatus | |
internal: true | |
on_value: | |
then: | |
- lambda: |- | |
if (id(verisure_larmstatus).state == "Armed Home On") { | |
id(my_display).set_contrast(0.1); } | |
else { | |
id(my_display).set_contrast(1.0); } | |
font: | |
- file: 'slkscr.ttf' | |
id: font1 | |
size: 8 | |
glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäöé' | |
- file: 'bebas-neue-regular.ttf' | |
id: font2 | |
size: 48 | |
- file: 'arial.ttf' | |
id: font3 | |
size: 14 | |
glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäöé' | |
- file: 'bebas-neue-regular.ttf' | |
id: font4 | |
size: 32 | |
- file: 'arial.ttf' | |
id: font5 | |
size: 12 | |
glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäöé' | |
- file: "arial.ttf" | |
id: tnr2 | |
size: 40 | |
glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäöé' | |
- file: 'materialdesignicons-webfont.ttf' | |
id: icon_font | |
size: 65 | |
glyphs: | |
- "\U000F0594" # mdi-weather-night | |
- "\U000F0599" # mdi-weather-sunny | |
- "\U000F009E" # mdi-bell-ring-bell | |
- "\U000F0D91" # mdi-motion | |
i2c: | |
sda: D6 | |
scl: D7 | |
scan: True | |
display: | |
- platform: ssd1306_i2c | |
model: "SSD1306 128x64" | |
id: "my_display" | |
contrast: 80% | |
address: 0x3C | |
pages: | |
- id: page1 | |
lambda: |- | |
// Print "Sikvägen 11" in top center. | |
// it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Sikvagen 11"); | |
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Alarm State: %s", id(alarm_state).state.c_str()); | |
// printf("%s\n", someString.c_str()); | |
// Print time in HH:MM format | |
it.strftime(0, 40, id(font4), TextAlign::BASELINE_LEFT, "%H:%M", id(time_ntp).now()); | |
// Print inside temperature (from homeassistant sensor) | |
if (id(office_temperature).has_state()) { | |
it.printf(127, 41, id(font3), TextAlign::BASELINE_RIGHT , "Kont %.1f°", id(office_temperature).state); | |
} | |
// Print outside temperature (from homeassistant sensor) | |
if (id(outside_temperature).has_state()) { | |
it.printf(127, 10, id(font3), TextAlign::TOP_RIGHT , "Out %.1f°", id(outside_temperature).state); | |
} | |
if (id(rain).has_state()) { | |
it.printf(127, 60, id(font3), TextAlign::BASELINE_RIGHT, "Regn %.1fmm", id(rain).state); | |
} | |
- id: page2 | |
lambda: |- | |
//it.strftime(0, 40, id(font4), TextAlign::BASELINE_LEFT, "%H:%M", id(time_ntp).now()); | |
if (id(last_motion_indoor).has_state()) { | |
it.printf(0, 10, id(font5), TextAlign::BASELINE_LEFT , "I: %s", id(last_motion_indoor).state.c_str()); | |
} | |
if (id(last_motion_outdoor).has_state()) { | |
it.printf(0, 25, id(font5), TextAlign::BASELINE_LEFT , "O: %s", id(last_motion_outdoor).state.c_str()); | |
} | |
if (id(octoprint_pct).has_state()) { | |
it.printf(0, 40, id(font5), TextAlign::BASELINE_LEFT , "3D-printer: %.1f%%", id(octoprint_pct).state); | |
} | |
if (id(mamman).has_state()) { | |
it.printf(0, 60, id(font3), TextAlign::BASELINE_LEFT, "H: %s", id(mamman).state.c_str()); | |
} | |
- id: rorelse | |
lambda: |- | |
it.print(64, 0, id(icon_font), TextAlign::TOP_CENTER, "\U000F0D91"); | |
interval: | |
- interval: 11s | |
then: | |
- display.page.show: page1 | |
- component.update: my_display | |
- delay: 5s | |
- display.page.show: page2 | |
- component.update: my_display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment