backup 20240718
This commit is contained in:
@@ -1,45 +1,37 @@
|
||||
# ESPHome code for the LilyGO TTGO Display
|
||||
# Copyright 2023 by Smart Home Junkie
|
||||
#
|
||||
# Visit my website at https://www.smarthomejunkie.net
|
||||
# Watch the tutorial for this display and code at https://youtu.be/LJCeelAzlS0
|
||||
|
||||
substitutions:
|
||||
esp_name: "ttgo-display"
|
||||
device_name: "ttgo-display"
|
||||
friendly_name: "ttgo-display"
|
||||
comment: "esp32, display, distance"
|
||||
api_password: !secret ttgo-t-display_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret ttgo-t-display_ip
|
||||
pin_sda: GPIO21
|
||||
pin_scl: GPIO22
|
||||
pin_but0: GPIO0
|
||||
pin_but1: GPIO35
|
||||
pin_spi_clk: GPIO18
|
||||
pin_spi_mosi: GPIO19
|
||||
pin_lcd_bl: GPIO4
|
||||
pin_lcd_cs: GPIO5
|
||||
pin_lcd_dc: GPIO16
|
||||
pin_lcd_rst: GPIO23
|
||||
|
||||
esphome:
|
||||
name: ${esp_name}
|
||||
comment: ${esp_name}
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret ttgo
|
||||
|
||||
# Define board type
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
ota:
|
||||
password: !secret aqs1_ota_passwoord
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: ${esp_name} fallback
|
||||
password: !secret fallback_password
|
||||
|
||||
captive_portal:
|
||||
packages:
|
||||
board: !include boards/esp32_wroom_arduino.yaml
|
||||
device_base: !include common/common.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
logger: !include templates/logger.yaml
|
||||
time: !include templates/time.yaml
|
||||
|
||||
spi:
|
||||
clk_pin: GPIO18
|
||||
mosi_pin: GPIO19
|
||||
clk_pin: ${pin_spi_clk}
|
||||
mosi_pin: ${pin_spi_mosi}
|
||||
|
||||
# Define the rotate variable. This indicates if the pages should be rotated or not
|
||||
globals:
|
||||
@@ -47,16 +39,12 @@ globals:
|
||||
type: boolean
|
||||
initial_value: "true"
|
||||
|
||||
# Define time sensor
|
||||
time:
|
||||
- platform: homeassistant
|
||||
id: esptime
|
||||
|
||||
# Define binary sensors
|
||||
binary_sensor:
|
||||
- platform: gpio # Short Press button 0
|
||||
pin:
|
||||
number: GPIO0
|
||||
number: ${pin_but0}
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
@@ -69,31 +57,9 @@ binary_sensor:
|
||||
then:
|
||||
- display.page.show_previous: my_display
|
||||
- component.update: my_display
|
||||
- platform: gpio # Long Press button 0
|
||||
pin:
|
||||
number: GPIO0
|
||||
inverted: true
|
||||
id: button_2
|
||||
on_click:
|
||||
min_length: 1001ms
|
||||
max_length: 5000ms
|
||||
then:
|
||||
- switch.toggle: backlight
|
||||
- platform: gpio # Short Press button 1
|
||||
pin:
|
||||
number: GPIO35
|
||||
inverted: true
|
||||
name: "Short Press Button 1"
|
||||
id: short_press_button_1
|
||||
on_click:
|
||||
min_length: 1ms
|
||||
max_length: 1000ms
|
||||
then:
|
||||
- display.page.show_next: my_display
|
||||
- component.update: my_display
|
||||
- platform: gpio # Long Press button 1
|
||||
pin:
|
||||
number: GPIO35
|
||||
number: ${pin_but1}
|
||||
inverted: true
|
||||
name: "Long Press Button 1"
|
||||
id: long_press_button_1
|
||||
@@ -114,28 +80,9 @@ binary_sensor:
|
||||
id: rotate
|
||||
value: "true"
|
||||
|
||||
# Allow dimmable control of the backlight (pin GPIO4) - Currently not working
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: GPIO4
|
||||
id: gpio4
|
||||
|
||||
light:
|
||||
- platform: monochromatic
|
||||
output: gpio4
|
||||
name: "Backlight"
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
pin: GPIO4
|
||||
id: backlight
|
||||
internal: true
|
||||
|
||||
# Define all the numeric sensors used
|
||||
sensor:
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.subscriptions_short
|
||||
id: subscriptions
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.views
|
||||
id: views
|
||||
@@ -144,17 +91,11 @@ sensor:
|
||||
attribute: netto_power
|
||||
id: nettopower
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.Temperatuur_Zolder_Werkkamer
|
||||
entity_id: sensor.esp32_s2_aqs_ikea_temperature
|
||||
id: office_temperature
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.humidity_zolder_werkkamer
|
||||
entity_id: sensor.esp32_s2_aqs_ikea_humidity
|
||||
id: office_humidity
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.office_multi_sensor_pressure
|
||||
id: office_pressure
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.office_light_sensor
|
||||
id: office_light_sensor
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.ttgo_display_data
|
||||
attribute: temperature
|
||||
@@ -164,7 +105,7 @@ sensor:
|
||||
attribute: wind_speed
|
||||
id: wind_speed
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.bitcoin
|
||||
entity_id: sensor.exchange_rate_1_btc
|
||||
id: bitcoin
|
||||
|
||||
# Define all the string sensors used
|
||||
@@ -274,7 +215,7 @@ graph:
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 1min
|
||||
y_grid: 5
|
||||
min_range: 5
|
||||
max_range: 35
|
||||
@@ -286,31 +227,31 @@ graph:
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 1min
|
||||
y_grid: 25
|
||||
min_range: 1
|
||||
max_range: 100
|
||||
min_value: 1
|
||||
max_value: 100
|
||||
color: BLUE
|
||||
- id: office_pressure_graph
|
||||
sensor: office_pressure
|
||||
- id: power_graph
|
||||
sensor: nettopower
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 15min
|
||||
y_grid: 100.0
|
||||
color: YELLOW
|
||||
- id: office_light_sensor_graph
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
traces:
|
||||
- sensor: office_light_sensor
|
||||
color: ORANGE
|
||||
line_type: SOLID
|
||||
line_thickness: 5
|
||||
# - id: office_light_sensor_graph
|
||||
# duration: 4h
|
||||
# width: 220
|
||||
# height: 90
|
||||
# x_grid: 1h
|
||||
# traces:
|
||||
# - sensor: office_light_sensor
|
||||
# color: ORANGE
|
||||
# line_type: SOLID
|
||||
# line_thickness: 5
|
||||
|
||||
# Define qr code locations
|
||||
qr_code:
|
||||
@@ -321,51 +262,28 @@ qr_code:
|
||||
display:
|
||||
- platform: st7789v
|
||||
model: TTGO_TDISPLAY_135x240
|
||||
backlight_pin: GPIO4
|
||||
cs_pin: GPIO5
|
||||
dc_pin: GPIO16
|
||||
reset_pin: GPIO23
|
||||
backlight_pin: ${pin_lcd_bl}
|
||||
cs_pin: ${pin_lcd_cs}
|
||||
dc_pin: ${pin_lcd_dc}
|
||||
reset_pin: ${pin_lcd_rst}
|
||||
rotation: 90°
|
||||
update_interval: 1s
|
||||
id: my_display
|
||||
pages: # Define the pages
|
||||
# - id: showintro
|
||||
# lambda: |-
|
||||
# it.image(0, 10, id(logo));
|
||||
# it.printf(135, 10, id(latoblack), WHITE, "SMART");
|
||||
# it.printf(140, 50, id(latoblack), WHITE, "HOME");
|
||||
# it.printf(130, 90, id(latoblack), WHITE, "JUNKIE");
|
||||
- id: showtime
|
||||
lambda: |-
|
||||
it.strftime(45, 20, id(latoblack), "%d-%m-%Y", id(esptime).now());
|
||||
it.strftime(25, 55, id(latoblackheading1), "%H:%M:%S", id(esptime).now());
|
||||
# - id: showsubscribers
|
||||
# lambda: |-
|
||||
# it.printf(0,0,id(latoblack), WHITE, "SUBSCRIBERS");
|
||||
# it.image(0, 40, id(youtube_image));
|
||||
# if (id(subscriptions).has_state()) {
|
||||
# it.printf(95, 60, id(latoblack), WHITE, "%.1fK", id(subscriptions).state);
|
||||
# } else {
|
||||
# it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
# - id: showviews
|
||||
# lambda: |-
|
||||
# it.printf(0,0,id(latoblack), WHITE, "VIEWS");
|
||||
# it.image(0, 40, id(youtube_image));
|
||||
# if (id(views).has_state()) {
|
||||
# it.printf(95, 60, id(latoblack), WHITE, "%.0f", id(views).state);
|
||||
# } else {
|
||||
# it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
it.strftime(45, 20, id(latoblack), "%d-%m-%Y", id(homeassistant_time).now());
|
||||
it.strftime(25, 55, id(latoblackheading1), "%H:%M:%S", id(homeassistant_time).now());
|
||||
|
||||
- id: shownettopower
|
||||
lambda: |-
|
||||
it.printf(0,0,id(latoblack), WHITE, "NETTO POWER");
|
||||
it.image(0, 40, id(electricity_image));
|
||||
if (id(nettopower).has_state()) {
|
||||
if (id(nettopower).state > -1000) {
|
||||
it.printf(95, 60, id(latoblack), WHITE, "%.0f Watt", id(nettopower).state);
|
||||
it.printf(95, 60, id(latoblack), WHITE, "%.2f kWh", id(nettopower).state);
|
||||
} else {
|
||||
it.printf(95, 60, id(latobold), WHITE, "%.0f Watt", id(nettopower).state);
|
||||
it.printf(95, 60, id(latobold), WHITE, "%.2f kWh", id(nettopower).state);
|
||||
}
|
||||
} else {
|
||||
it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
@@ -397,15 +315,15 @@ display:
|
||||
it.printf(0,0,id(latoblack), WHITE, "HUMIDITY");
|
||||
it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
}
|
||||
# - id: show_office_pressure_graph
|
||||
# lambda: |-
|
||||
# if (id(office_pressure).has_state()) {
|
||||
# it.printf(0,0,id(latoblack), WHITE, "PRS: %.0f hPA", id(office_pressure).state);
|
||||
# it.graph(10, 40, id(office_pressure_graph));
|
||||
# } else {
|
||||
# it.printf(0,0,id(latoblack), WHITE, "PRESSURE");
|
||||
# it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
- id: show_nettopower_graph
|
||||
lambda: |-
|
||||
if (id(nettopower).has_state()) {
|
||||
it.printf(0,0,id(latoblack), WHITE, "power: %.2f Kwh", id(nettopower).state);
|
||||
it.graph(10, 40, id(power_graph));
|
||||
} else {
|
||||
it.printf(0,0,id(latoblack), WHITE, "PRESSURE");
|
||||
it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
}
|
||||
# - id: show_office_light_sensor_graph
|
||||
# lambda: |-
|
||||
# if (id(office_light_sensor).has_state()) {
|
||||
|
||||
Reference in New Issue
Block a user