Forked from tubalainen/gist:19103e725c1d7331bc16eae130a6757d
Created
July 1, 2022 04:44
-
-
Save lasitha-sparrow/e3abdbae7b9b76b4aa0edd95a7b4b2b5 to your computer and use it in GitHub Desktop.
ESPHome - SSD1306 display example
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: display_hall | |
platform: ESP8266 | |
board: nodemcuv2 | |
wifi: | |
manual_ip: | |
static_ip: 192.168.XX.XX | |
gateway: 192.168.XX.1 | |
subnet: 255.255.255.0 | |
# use_address: 192.168.XX.XX | |
networks: | |
# AP04 Garaget | |
- ssid: !secret ssid | |
password: !secret wifipwd | |
bssid: FC:EC:DA:81:XX:XX | |
priority: 4 | |
# AP03 Baksidan | |
- ssid: !secret ssid | |
password: !secret wifipwd | |
bssid: F4:92:Bf:2D:XX:XX | |
priority: 3 | |
# AP02 finentren | |
- ssid: !secret ssid | |
password: !secret wifipwd | |
bssid: F0:9F:C2:34:XX:XX | |
priority: 2 | |
# AP01 Hall OV | |
- ssid: !secret ssid | |
password: !secret wifipwd | |
bssid: 80:2A:A8:D4:XX:XX | |
priority: 1 | |
ap: | |
ssid: "Disphall Fallback Hotspot" | |
captive_portal: | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
ota: | |
web_server: | |
port: 80 | |
time: | |
# - platform: homeassistant | |
# id: time | |
- platform: sntp | |
id: time_ntp | |
timezone: Europe/Stockholm | |
servers: 192.168.21.10 | |
light: | |
- platform: monochromatic | |
name: "Hall LED" | |
output: output_component1 | |
output: | |
- platform: esp8266_pwm | |
id: output_component1 | |
pin: D6 | |
binary_sensor: | |
- platform: status | |
name: "Display Hall Status" | |
- platform: gpio | |
pin: | |
number: D1 | |
mode: INPUT_PULLUP | |
name: "Hallknapp 1" | |
- platform: gpio | |
pin: | |
number: D2 | |
mode: INPUT_PULLUP | |
name: "Hallknapp 2" | |
- platform: gpio | |
pin: D5 | |
name: "Rörelsesensor (ESP) Groventre" | |
device_class: motion | |
filters: | |
- delayed_off: 30s | |
on_press: | |
then: | |
- lambda: id(my_display).set_brightness(1.0); | |
on_release: | |
then: | |
- lambda: id(my_display).set_brightness(0.1); | |
sensor: | |
- platform: wifi_signal | |
name: "Display Hall wifi signal" | |
update_interval: 60s | |
- platform: bme280 | |
temperature: | |
name: "Groventre (ESP) Temperature" | |
oversampling: 16x | |
pressure: | |
name: "Groventre (ESP) Pressure" | |
humidity: | |
name: "Groventre (ESP) Humidity" | |
address: 0x76 | |
update_interval: 10s | |
- platform: homeassistant | |
id: inside_temperature | |
entity_id: sensor.hall_ov_esp_temperature | |
internal: true | |
- platform: homeassistant | |
id: outside_temperature | |
entity_id: sensor.snitttemp_ute_min_max | |
internal: true | |
- platform: homeassistant | |
id: inside_hum | |
entity_id: sensor.luftfuktighet_avr_inne | |
internal: true | |
- platform: homeassistant | |
id: forrad_temperature | |
entity_id: sensor.forrad_temperature | |
internal: true | |
- platform: homeassistant | |
id: forrad_hum | |
entity_id: sensor.forrad_humidity | |
internal: true | |
- platform: homeassistant | |
id: gte_batt_level | |
entity_id: sensor.my_passat_gte_battery_level | |
internal: true | |
- platform: homeassistant | |
id: gte_fuel_level | |
entity_id: sensor.my_passat_gte_fuel_level | |
internal: true | |
- platform: homeassistant | |
id: gte_comb_range | |
entity_id: sensor.my_passat_gte_combined_range | |
internal: true | |
text_sensor: | |
- platform: homeassistant | |
entity_id: alarm_control_panel.my_alarm | |
name: "Alarm State" | |
id: alarm_state | |
internal: true | |
- platform: homeassistant | |
entity_id: device_tracker.life360_torbjorn | |
name: "Where is Pappan" | |
id: pappan | |
internal: true | |
- platform: homeassistant | |
entity_id: device_tracker.life360_helena | |
name: "Where is Mamman" | |
id: mamman | |
internal: true | |
font: | |
- file: 'slkscr.ttf' | |
id: font1 | |
size: 8 | |
- file: 'bebas-neue-regular.ttf' | |
id: font2 | |
size: 48 | |
- file: 'arial.ttf' | |
id: font3 | |
size: 14 | |
- file: 'bebas-neue-regular.ttf' | |
id: font4 | |
size: 32 | |
i2c: | |
sda: D3 | |
scl: D4 | |
scan: True | |
display: | |
- platform: ssd1306_i2c | |
model: "SH1106 128x64" | |
id: "my_display" | |
reset_pin: D0 | |
address: 0x3C | |
pages: | |
- id: page1 | |
lambda: |- | |
// Print "Sikvägen 11" in top center. | |
// it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Alarmsystem"); | |
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(inside_temperature).has_state()) { | |
it.printf(127, 44, id(font3), TextAlign::BASELINE_RIGHT , "In %.1f°", id(inside_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(inside_hum).has_state()) { | |
it.printf(127, 64, id(font3), TextAlign::BASELINE_RIGHT , "H In %.1f%%", id(inside_hum).state); | |
} | |
- id: page2 | |
lambda: |- | |
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Alarm State: %s", id(alarm_state).state.c_str()); | |
//it.strftime(0, 40, id(font4), TextAlign::BASELINE_LEFT, "%H:%M", id(time_ntp).now()); | |
if (id(forrad_temperature).has_state()) { | |
it.printf(127, 43, id(font3), TextAlign::BASELINE_RIGHT , "Forrad temp %.1f°", id(forrad_temperature).state); | |
} | |
if (id(forrad_hum).has_state()) { | |
it.printf(127, 10, id(font3), TextAlign::TOP_RIGHT , "Forrad hum %.1f°", id(forrad_hum).state); | |
} | |
if (id(outside_temperature).has_state()) { | |
it.printf(127, 63, id(font3), TextAlign::BASELINE_RIGHT , "Outdoor temp %.1f°", id(outside_temperature).state); | |
} | |
- id: page3 | |
lambda: |- | |
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Alarm State: %s", id(alarm_state).state.c_str()); | |
if (id(gte_batt_level).has_state()) { | |
it.printf(127, 43, id(font3), TextAlign::BASELINE_RIGHT , "GTE Batt %.1f%%", id(gte_batt_level).state); | |
} | |
if (id(gte_fuel_level).has_state()) { | |
it.printf(127, 10, id(font3), TextAlign::TOP_RIGHT , "GTE Fuel %.1f%%", id(gte_fuel_level).state); | |
} | |
if (id(gte_comb_range).has_state()) { | |
it.printf(127, 63, id(font3), TextAlign::BASELINE_RIGHT , "GTE Rng %.1f KM", id(gte_comb_range).state); | |
} | |
- id: page4 | |
lambda: |- | |
it.print(64, 0, id(font1), TextAlign::TOP_CENTER, "Where is the family"); | |
if (id(pappan).has_state()) { | |
it.printf(127, 62, id(font3), TextAlign::BASELINE_RIGHT, "T: %s", id(pappan).state.c_str()); | |
} | |
if (id(mamman).has_state()) { | |
it.printf(127, 42, id(font3), TextAlign::BASELINE_RIGHT, "H: %s", id(mamman).state.c_str()); | |
} | |
interval: | |
- interval: 5s | |
then: | |
- display.page.show_next: my_display | |
- component.update: my_display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment