394 lines
9.8 KiB
YAML
394 lines
9.8 KiB
YAML
substitutions:
|
|
name: sthome-ut2
|
|
friendly_name: "sthome-ut2"
|
|
|
|
esphome:
|
|
name: "${name}"
|
|
friendly_name: "${friendly_name}"
|
|
|
|
# - priority: 200 # Network connections like MQTT/native API are set up at this priority.
|
|
# then:
|
|
# - lambda: |-
|
|
|
|
esp32:
|
|
board: esp32dev
|
|
framework:
|
|
type: arduino
|
|
#type: esp-idf
|
|
|
|
#debug:
|
|
# update_interval: 5s
|
|
|
|
# Enable logging
|
|
logger:
|
|
level: DEBUG
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
encryption:
|
|
key: "o+fgr4qh0rTegCxXE3jbfJ/0si8+W9wxgnnYX9Xucqw="
|
|
|
|
ota:
|
|
- platform: esphome
|
|
password: "cb8a82d04c2f4dcf9bd273f903c7c378"
|
|
|
|
wifi:
|
|
#ssid: !secret wifi_ssid
|
|
#password: !secret wifi_password
|
|
# we will use local dns server for local dns resolution
|
|
power_save_mode: none
|
|
domain: ".sthome.org"
|
|
networks:
|
|
- ssid: !secret wifi_ssid1
|
|
password: !secret wifi_password1
|
|
- ssid: !secret wifi_ssid2
|
|
password: !secret wifi_password2
|
|
- ssid: !secret wifi_ssid3
|
|
password: !secret wifi_password3
|
|
- ssid: !secret wifi_ssid4
|
|
password: !secret wifi_password4
|
|
- ssid: !secret wifi_ssid5
|
|
password: !secret wifi_password5
|
|
manual_ip:
|
|
# For faster connection startup, set a static IP address
|
|
# Set this to the IP of the ESP
|
|
static_ip: 10.0.2.2
|
|
gateway: 10.0.0.2
|
|
subnet: 255.255.240.0
|
|
dns1: 10.0.0.1
|
|
dns2: 1.1.1.1
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
ap:
|
|
ssid: "${name} Fallback Hotspot"
|
|
password: "geuZrJgQo7cg"
|
|
|
|
captive_portal:
|
|
|
|
|
|
one_wire:
|
|
- platform: gpio
|
|
pin: GPIO4
|
|
id: temperature_sensors
|
|
|
|
#i2c:
|
|
# sda: GPIO21
|
|
# scl: GPIO22
|
|
|
|
font:
|
|
- file: "fonts/Windows/comic.ttf"
|
|
id: my_font
|
|
size: 20
|
|
bpp: 2
|
|
|
|
- file: "fonts/misc/tom-thumb.bdf"
|
|
id: tomthumb
|
|
|
|
# gfonts://family[@weight]
|
|
- file: "gfonts://Roboto"
|
|
id: roboto_20
|
|
size: 20
|
|
|
|
- file:
|
|
type: gfonts
|
|
family: Roboto
|
|
weight: 900
|
|
id: roboto_16
|
|
size: 16
|
|
|
|
- file: "fonts/Windows/arial.ttf"
|
|
id: arial_14
|
|
size: 14
|
|
# gfonts://family[@weight]
|
|
- file: "gfonts://Roboto"
|
|
id: roboto
|
|
size: 20
|
|
- file: "gfonts://Carrois Gothic"
|
|
id: Carrois_Gothic
|
|
size: 20
|
|
- file: "gfonts://Kdam Thmor Pro"
|
|
id: Kdam_Thmor_Pro
|
|
size: 40
|
|
- file: "gfonts://Merriweather"
|
|
id: Merriweather
|
|
size: 30
|
|
|
|
- file: "gfonts://Material+Symbols+Outlined"
|
|
id: icons_50
|
|
size: 50
|
|
glyphs: ["\U0000e425"] # mdi-timer
|
|
|
|
- file: "fonts/roboto/Roboto-Condensed.ttf"
|
|
id: roboto_special_28
|
|
size: 28
|
|
bpp: 4
|
|
glyphs: [
|
|
0123456789aAáÁeEéÉ,
|
|
(,),+,-,_,.,°,•,µ,
|
|
"\u0020", # space
|
|
"\u002C", # ,
|
|
"\u0021", # !
|
|
"\u0022", # "
|
|
"\u0027", # '
|
|
"\u003A", # :
|
|
]
|
|
|
|
- file: "fonts/roboto/Roboto-Condensed.ttf"
|
|
id: roboto_special_32
|
|
size: 32
|
|
bpp: 4
|
|
glyphs: [
|
|
0123456789aAáÁeEéÉ,
|
|
(,),+,-,_,.,°,•,µ,
|
|
"\u0020", # space
|
|
"\u002C", # ,
|
|
"\u0021", # !
|
|
"\u0022", # "
|
|
"\u0027", # '
|
|
"\u003A", # :
|
|
]
|
|
|
|
- file: "fonts/roboto/Roboto-Condensed.ttf"
|
|
id: roboto_special_36
|
|
size: 36
|
|
bpp: 4
|
|
glyphs: [
|
|
0123456789aAáÁeEéÉ,
|
|
(,),+,-,_,.,°,•,µ,
|
|
"\u0020", # space
|
|
"\u002C", # ,
|
|
"\u0021", # !
|
|
"\u0022", # "
|
|
"\u0027", # '
|
|
"\u003A", # :
|
|
]
|
|
|
|
# - file: "fonts/RobotoCondensed-Regular.ttf"
|
|
# id: my_font_with_icons
|
|
# size: 20
|
|
# bpp: 4
|
|
# extras:
|
|
# - file: "fonts/misc/materialdesignicons-webfont.ttf"
|
|
# glyphs: [
|
|
# "\U000F02D1", # mdi-heart
|
|
# "\U000F05D4", # mdi-airplane-landing
|
|
# ]
|
|
|
|
- file:
|
|
type: gfonts
|
|
family: Roboto
|
|
id: roboto_european_core
|
|
size: 16
|
|
glyphsets:
|
|
- GF_Latin_Core
|
|
- GF_Greek_Core
|
|
- GF_Cyrillic_Core
|
|
|
|
- file: "https://github.com/IdreesInc/Monocraft/releases/download/v3.0/Monocraft.ttf"
|
|
id: web_font
|
|
size: 20
|
|
- file:
|
|
url: "https://github.com/IdreesInc/Monocraft/releases/download/v3.0/Monocraft.ttf"
|
|
type: web
|
|
id: web_font2
|
|
size: 24
|
|
|
|
|
|
#ads1115:
|
|
# - address: 0x48
|
|
# id: ads1115_48
|
|
# continuous_mode: true
|
|
# - address: 0x49
|
|
# id: ads1115_49
|
|
# continuous_mode: true
|
|
# - address: 0x4A
|
|
# id: ads1115_4A
|
|
# continuous_mode: true
|
|
# # - address: 0x4B
|
|
# # id: ads1115_4B
|
|
|
|
spi:
|
|
- id: spi_bus0
|
|
clk_pin: GPIO18
|
|
mosi_pin: GPIO23
|
|
miso_pin: GPIO19
|
|
interface: any
|
|
psram:
|
|
|
|
sun:
|
|
id: sun_sensor
|
|
latitude: !secret latitude
|
|
longitude: !secret longitude
|
|
|
|
time:
|
|
# - platform: sntp
|
|
# timezone: Africa/Johannesburg
|
|
# servers:
|
|
# - ntp1.meraka.csir.co.za # 146.64.24.58
|
|
# - ntp.as3741.net # 196.4.160.4
|
|
# - ntp1.inx.net.za # 196.10.52.57
|
|
- platform: homeassistant
|
|
id: time_source
|
|
# on_time_sync:
|
|
# - lambda: |-
|
|
# id(time_synched) = true;
|
|
# id(init_holidays).execute(); // we need valid time to calculate holidays
|
|
# - logger.log: "Synchronized system clock"#
|
|
|
|
display:
|
|
- platform: ili9xxx
|
|
model: ili9341
|
|
id: tft_display
|
|
color_palette: 8BIT
|
|
data_rate: 40MHz
|
|
#dc_pin: GPIO02
|
|
#reset_pin: GPIO27
|
|
#cs_pin: GPIO15
|
|
reset_pin: GPIO32
|
|
dc_pin: GPIO27
|
|
invert_colors: false
|
|
show_test_card: true
|
|
dimensions:
|
|
width: 480
|
|
height: 320
|
|
|
|
# - platform: ssd1306_i2c
|
|
# model: "SSD1306 128x64"
|
|
## reset_pin: GPIO32
|
|
# address: 0x3C
|
|
# id: oled_display
|
|
# pages:
|
|
# - id: page1
|
|
# lambda: |-
|
|
# auto time_obj = id(time_source).now();
|
|
# auto date = time_obj.strftime("%Y-%m-%d");
|
|
# auto time = time_obj.strftime("%H:%M:%S");
|
|
# it.print(0, 0, id(roboto_16), date.c_str());
|
|
# it.print(0, 20, id(roboto_special_36), time.c_str());
|
|
# - id: page2
|
|
# lambda: |-
|
|
# // Print WiFi Signal
|
|
# it.printf(0, 26, id(arial_14), "Wi-Fi: %.1fdBm", id(wifi_sig).state);
|
|
# // Print time in HH:MM format
|
|
# it.strftime(0, 0, id(roboto), TextAlign::TOP_LEFT, "%H:%M", id(time_source).now());
|
|
# //// Print Room humidity"(from xiaomi sensor)
|
|
# //if (id(room_humidity).has_state()) {
|
|
# // it.printf(127,62, id(roboto), TextAlign::BOTTOM_RIGHT, "%.1f%%", id(room_humidity).state);
|
|
# //}
|
|
# // Print Study temperature(from dallas sensor)
|
|
# if (id(study_temperature).has_state()) {
|
|
# it.printf(127, 0, id(Carrois_Gothic), TextAlign::TOP_RIGHT, "%.1f°C", id(study_temperature).state);
|
|
# }
|
|
# - id: page3
|
|
# lambda: |-
|
|
# // Print 29Gal temperature(from dallas sensor)
|
|
# if (id(study_temperature).has_state()) {
|
|
# it.printf(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%.1f°C", id(study_temperature).state);
|
|
# }
|
|
# - id: page4
|
|
# lambda: |-
|
|
# // Print time in HH:MM format
|
|
# it.strftime(64, 10, id(Kdam_Thmor_Pro), TextAlign::CENTER_HORIZONTAL, "%H:%M", id(time_source).now());
|
|
|
|
#interval:
|
|
#- interval: 5s
|
|
# then:
|
|
# - display.page.show_next: oled_display
|
|
# - component.update: oled_display
|
|
|
|
switch:
|
|
- platform: restart
|
|
name: "${name} Restart"
|
|
id: "restart_switch"
|
|
|
|
sensor:
|
|
- platform: dallas_temp
|
|
address: 0xfe00000037b3d528
|
|
name: "Study Temperature"
|
|
id: study_temperature
|
|
update_interval: "60s"
|
|
resolution: 12
|
|
one_wire_id: temperature_sensors
|
|
unit_of_measurement: "°C"
|
|
#icon: "mdi:water-thermometer"
|
|
device_class: "temperature"
|
|
state_class: "measurement"
|
|
accuracy_decimals: 1
|
|
filters:
|
|
- filter_out: nan
|
|
# - sliding_window_moving_average:
|
|
# window_size: 120 # averages over 120 update intervals
|
|
# send_every: 60 # reports every 60 update intervals
|
|
|
|
# Report wifi signal strength every 5 min if changed
|
|
- platform: wifi_signal
|
|
name: WiFi Signal
|
|
id: wifi_sig
|
|
update_interval: 300s
|
|
filters:
|
|
- delta: 10%
|
|
# human readable uptime sensor output to the text sensor above
|
|
- platform: uptime
|
|
name: Uptime in Days
|
|
id: uptime_sensor_days
|
|
update_interval: 10s
|
|
on_raw_value:
|
|
then:
|
|
- text_sensor.template.publish:
|
|
id: uptime_human
|
|
state: !lambda |-
|
|
int seconds = round(id(uptime_sensor_days).raw_state);
|
|
int days = seconds / (24 * 3600);
|
|
seconds = seconds % (24 * 3600);
|
|
int hours = seconds / 3600;
|
|
seconds = seconds % 3600;
|
|
int minutes = seconds / 60;
|
|
seconds = seconds % 60;
|
|
auto days_str = std::to_string(days);
|
|
auto hours_str = std::to_string(hours);
|
|
auto minutes_str = std::to_string(minutes);
|
|
auto seconds_str = std::to_string(seconds);
|
|
return (
|
|
(days ? days_str + "d " : "") +
|
|
(hours ? hours_str + "h " : "") +
|
|
(minutes ? minutes_str + "m " : "") +
|
|
(seconds_str + "s")
|
|
).c_str();
|
|
|
|
# number of seconds since midnight
|
|
- platform: template
|
|
id: time_of_day
|
|
name: "Time of day"
|
|
accuracy_decimals: 0
|
|
unit_of_measurement: "s"
|
|
lambda: |-
|
|
auto currenttime = id(time_source).now();
|
|
ESPTime time_obj = currenttime;
|
|
time_obj.second = 0;
|
|
time_obj.minute = 0;
|
|
time_obj.hour = 0;
|
|
time_obj.recalc_timestamp_local();
|
|
return currenttime.timestamp - time_obj.timestamp;
|
|
update_interval: 10s
|
|
|
|
text_sensor:
|
|
- platform: template
|
|
id: module_time
|
|
name: "Module time"
|
|
icon: mdi:clock
|
|
lambda: |-
|
|
auto time_obj = id(time_source).now();
|
|
return time_obj.strftime("%Y-%m-%d %H:%M:%S");
|
|
update_interval: 1s
|
|
|
|
# Expose WiFi information as sensors
|
|
- platform: wifi_info
|
|
ip_address:
|
|
name: IP
|
|
mac_address:
|
|
name: Mac Address
|
|
|
|
# human readable update text sensor from sensor:uptime
|
|
- platform: template
|
|
name: Uptime
|
|
id: uptime_human
|
|
icon: mdi:clock-start |