of course:
esphome:
name: 8ch-din-relay
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "abcd1234"
ota:
password: "abcd1234"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "8Ch-Din-Relay"
password: "abcd1234"
captive_portal:
switch:
- platform: gpio
pin: GPIO32
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-1"
id: ch_1
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO33
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-2"
id: ch_2
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO25
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-3"
id: ch_3
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO26
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-4"
id: ch_4
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO27
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-5"
id: ch_5
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO14
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-6"
id: ch_6
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO13
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-7"
id: ch_7
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
- platform: gpio
pin: GPIO22
inverted: yes
restore_mode: RESTORE_DEFAULT_OFF
name: "CH-8"
id: ch_8
on_turn_on:
- component.update: my_display
on_turn_off:
- component.update: my_display
# text_sensor:
# - platform: wifi_info
# ip_address:
# id: ip_addr
# ssid:
# id: ssid
# bssid:
# id: bssid
# mac_address:
# id: mac_address
# scan_results:
# id: scan_res
sensor:
- platform: uptime
name: Uptime Sensor
id: uptimes
# - platform: wifi_signal
# id: signyal
# update_interval: 5s
i2c:
sda: GPIO4
scl: GPIO5
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
id: my_display
address: 0x3C
update_interval: 1s
pages:
- id: page1
lambda: |-
it.rectangle(0, 0, 128, 64);
it.printf(30, 0, id(roboto), "Relay status:");
it.line(0, 15, 128, 15);
it.line(0, 28, 128, 28);
it.line(0, 40, 128, 40);
it.line(0, 52, 128, 52);
it.line(64, 15, 64, 64);
it.printf(3, 16, id(roboto), "CH1:%s", id(ch_1).state ? "ON" : "OFF");
it.printf(3, 28, id(roboto), "CH2:%s", id(ch_2).state ? "ON" : "OFF");
it.printf(3, 40, id(roboto), "CH3:%s", id(ch_3).state ? "ON" : "OFF");
it.printf(3, 51, id(roboto), "CH4:%s", id(ch_4).state ? "ON" : "OFF");
it.printf(66, 16, id(roboto), "CH5:%s", id(ch_5).state ? "ON" : "OFF");
it.printf(66, 28, id(roboto), "CH6:%s", id(ch_6).state ? "ON" : "OFF");
it.printf(66, 40, id(roboto), "CH7:%s", id(ch_7).state ? "ON" : "OFF");
it.printf(66, 51, id(roboto), "CH8:%s", id(ch_8).state ? "ON" : "OFF");
- id: page2
lambda: |-
it.printf(2, 0, id(roboto),"Controller info:");
it.printf(2, 10, id(roboto), "Uptime: %i", id(uptimes));
- id: page3
lambda: |-
it.printf(2, 15, id(roboto), "Dashboard");
it.printf(20, 25, id(roboto), "Link");
it.qr_code(65, 5, id(dashboard), Color(255,255,255), 2);
interval:
- interval: 10s
then:
- display.page.show_next: my_display
- component.update: my_display
font:
- file: "gfonts://Roboto"
id: roboto
size: 11
web_server:
js_include: "./v2/www.js"
js_url: ""
version: 2
qr_code:
- id: dashboard
value: "something_not_interest"
# - id: page2
# lambda: |-
# it.printf(2, 10, id(roboto), id(ip_addr->toString()));
# it.printf(2, 20, id(roboto), id(ssid->toString()));
# it.printf(2, 30, id(roboto), id(mac_address->toString()));
# it.printf(2, 40, id(roboto), "Signal DB", id(signyal->toString()));
The Wifi sensors are commented because the value displaying faulty as well