Hier meine Version:
####################################################################################################
# #
# ██████╗██╗ ██╗██████╗ ██╗ ██╗ ██████╗ ██╗ ██╗███╗ ██╗███████╗███╗ ██╗ #
# ██╔════╝╚██╗ ██╔╝██╔══██╗ ██║ ██║██╔═══██╗██║ ██║████╗ ██║██╔════╝████╗ ██║ #
# ██║ ╚████╔╝ ██║ ██║ █████╗ ██║ █╗ ██║██║ ██║███████║██╔██╗ ██║█████╗ ██╔██╗ ██║ #
# ██║ ╚██╔╝ ██║ ██║ ╚════╝ ██║███╗██║██║ ██║██╔══██║██║╚██╗██║██╔══╝ ██║╚██╗██║ #
# ╚██████╗ ██║ ██████╔╝ ╚███╔███╔╝╚██████╔╝██║ ██║██║ ╚████║███████╗██║ ╚████║ #
# ╚═════╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ #
# #
####################################################################################################
esphome:
name: cyd
friendly_name: CYD - Wohnzimmer
##################################################################################
# Which board to configure?
##################################################################################
esp32:
board: esp32dev
framework:
type: arduino
##################################################################################
# Enable logging
##################################################################################
logger:
##################################################################################
# Enable Home Assistant API
##################################################################################
api:
encryption:
key: "3OXaIsGaIieqcCZCTJ2n........"
##################################################################################
# OTA-Update - Password
##################################################################################
ota:
- platform: esphome
password: "5d7b8255feeac6b........"
##################################################################################
# WIFI - Password
##################################################################################
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
##################################################################################
# Enable fallback hotspot (captive portal) in case wifi connection fails
##################################################################################
ap:
ssid: "Cyd-I Fallback Hotspot"
password: "F44HHlZfMxyi"
captive_portal:
globals:
- id: show_return_page
type: bool
restore_value: yes
initial_value: "false"
##################################################################################
# Setup a pin to control the backlight and the LED
##################################################################################
output:
- platform: ledc
pin: GPIO21
id: backlight_pwm
- platform: ledc
id: output_red
pin: GPIO4
inverted: true
- platform: ledc
id: output_green
pin: GPIO16
inverted: true
- platform: ledc
id: output_blue
pin: GPIO17
inverted: true
light:
- platform: monochromatic
output: backlight_pwm
name: Display Backlight
id: backlight
restore_mode: ALWAYS_ON
- platform: rgb
name: LED
red: output_red
id: led
green: output_green
blue: output_blue
restore_mode: ALWAYS_OFF
##################################################################################
# Setup SPI for the display.
# The ESP32-2432S028R uses separate SPI buses for display and touch
##################################################################################
spi:
- id: tft
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
- id: touch
clk_pin: GPIO25
mosi_pin: GPIO32
miso_pin: GPIO39
touchscreen:
platform: xpt2046
spi_id: touch
cs_pin: GPIO33
interrupt_pin: GPIO36
update_interval: 50ms
threshold: 400
calibration:
x_min: 280
x_max: 3860
y_min: 340
y_max: 3860
transform:
swap_xy: false
##################################################################################
# Create a font to use, add and remove glyphs as needed
##################################################################################
font:
- file: 'fonts/RobotoSlab-Medium.ttf'
id: font_CRAVALLO_Buttontext
size: 12
glyphs:
['&', '@', '!', ',', '.', '?', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', '/']
- file: 'fonts/RobotoSlab-Medium.ttf'
id: font_CRAVALLO_Datumtext
size: 16
glyphs:
['&', '@', '!', ',', '.', '?', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', '/']
- file: "fonts/RobotoSlab-Medium.ttf"
id: font_CRAVALLO_Infotext
size: 22
glyphs:
['&', '@', '!', ',', '.', '?', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z','å', 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', '/']
- file: 'fonts/LCDAT&TPhoneTimeDate.ttf'
id: font_CRAVALLO_Zeit
size: 66
##################################################################################
# Create the colors you want to use
##################################################################################
color:
- id: cravallo_grey
hex: '464646'
- id: cravallo_green
hex: '148e23'
- id: cravallo_black
hex: '000000'
- id: cravallo_orange
hex: 'b27300'
- id: cravallo_blue
hex: '0000b2'
- id: cravallo_light
hex: '6b6b6b'
- id: cravallo_solar
hex: 'b2b200'
- id: cravallo_verbrauch
hex: 'b20000'
##################################################################################
# Create the icons as needed
##################################################################################
image:
##################################################################################
# RINGLICHT
##################################################################################
- file: mdi:brightness-7
id: mdi_ringlicht_ON
resize: 40x40
type: binary
- file: mdi:brightness-5
id: mdi_ringlicht_OFF
resize: 40x40
type: binary
##################################################################################
# STEHLAMPE
##################################################################################
- file: mdi:floor-lamp
id: mdi_stehlampe_ON
resize: 40x40
type: binary
- file: mdi:floor-lamp-outline
id: mdi_stehlampe_OFF
resize: 40x40
type: binary
##################################################################################
# PANEEL
##################################################################################
- file: mdi:television-ambient-light
id: mdi_paneel_ON
resize: 40x40
type: binary
- file: mdi:television
id: mdi_paneel_OFF
resize: 40x40
type: binary
##################################################################################
# KÜCHE
##################################################################################
- file: mdi:power-plug-outline
id: mdi_kueche_ON
resize: 40x40
type: binary
- file: mdi:power-plug-off-outline
id: mdi_kueche_OFF
resize: 40x40
type: binary
##################################################################################
# GÄSTE WC
##################################################################################
- file: mdi:lightbulb-on
id: mdi_gastWC_ON
resize: 40x40
type: binary
- file: mdi:lightbulb-outline
id: mdi_gastWC_OFF
resize: 40x40
type: binary
##################################################################################
# TERRASSE
##################################################################################
- file: mdi:string-lights
id: mdi_terrasse_ON
resize: 40x40
type: binary
- file: mdi:string-lights-off
id: mdi_terrasse_OFF
resize: 40x40
type: binary
##################################################################################
# MAN-CAVE
##################################################################################
- file: mdi:lightbulb-fluorescent-tube
id: mdi_manCave_ON
resize: 40x40
type: binary
- file: mdi:lightbulb-fluorescent-tube-outline
id: mdi_manCave_OFF
resize: 40x40
type: binary
##################################################################################
# THERMOMETER
##################################################################################
- file: mdi:home-thermometer-outline
id: mdi_home_thermometer
resize: 32x32
type: binary
##################################################################################
# SOLAR
##################################################################################
- file: mdi:solar-power-variant-outline
id: mdi_solar_power_variant_outline
resize: 32x32
type: binary
##################################################################################
# VERBRAUCH
##################################################################################
- file: mdi:transmission-tower-import
id: mdi_transmission_tower_import
resize: 32x32
type: binary
##################################################################################
# ZONE
##################################################################################
- file: mdi:crosshairs-question
id: mdi_crosshairs_question
resize: 32x32
type: binary
##################################################################################
# GREEN DOOR
##################################################################################
- file: mdi:page-previous
id: mdi_back
resize: 40x40
type: binary
##################################################################################
# Replace the home gif as you want
##################################################################################
#animation:
# - file: "habbit.gif"
# id: ha
# resize: 70x70
# type: TRANSPARENT_BINARY
##################################################################################
# Die Zeit aus HA importieren
##################################################################################
time:
- platform: homeassistant
id: esptime
##################################################################################
# VARIABLEN MIT SENSORWERT (Numerische Werte!!!)
##################################################################################
sensor:
- platform: homeassistant
id: bt_terrasse_temperature
entity_id: sensor.bt_terrasse_temperature
internal: true
- platform: homeassistant
id: bt_terrasse_humidity
entity_id: sensor.bt_terrasse_humidity
internal: true
- platform: homeassistant
id: cravallo_grid_power
entity_id: sensor.cravallo_grid_power
internal: true
- platform: homeassistant
id: cravallo_current_consumption
entity_id: sensor.cravallo_current_consumption
internal: true
- platform: homeassistant
id: cravallo_power_supplied
entity_id: sensor.cravallo_power_supplied
internal: true
- platform: homeassistant
id: cravallo_autarkie_prozent
entity_id: sensor.cravallo_autarkie_prozent
internal: true
- platform: homeassistant
id: cravallo_power_absorbed
entity_id: sensor.cravallo_power_absorbed
internal: true
- platform: homeassistant
id: cravallo_eigenverbrauch_prozent
entity_id: sensor.cravallo_eigenverbrauch_prozent
internal: true
##################################################################################
# VARIABLEN MIT TEXTINHALT (z.B. "on", "off", etc.)
##################################################################################
text_sensor:
- platform: homeassistant
id: wz_RingLicht
entity_id: switch.zb_steckdose_ring
internal: true
- platform: homeassistant
id: person_roberto_cravallo
entity_id: sensor.zone_robert
internal: true
- platform: homeassistant
id: person_sylvia
entity_id: sensor.zone_sylvia
internal: true
- platform: homeassistant
id: wz_Stehlampe
entity_id: light.zb_licht_wohnzimmer
internal: true
- platform: homeassistant
id: wz_Paneel
entity_id: switch.zb_steckdose_paneel
internal: true
- platform: homeassistant
id: kueche_licht
entity_id: switch.zb_steckdose_kuche_i
internal: true
- platform: homeassistant
id: gastWC_licht
entity_id: switch.wifi_schalter_gast_wc
internal: true
- platform: homeassistant
id: terrasse_licht
entity_id: switch.lichterkette_terrasse
internal: true
- platform: homeassistant
id: manCave_licht
entity_id: switch.zb_unterputz_cave
internal: true
- platform: homeassistant
id: DatumAnzeige
entity_id: sensor.datum_zeit
internal: true
##################################################################################
#
# Assigns a function to each button, by calling the corresponding service in HA
#
##################################################################################
##################################################################################
# KNOPF - Steckdose Ring
##################################################################################
binary_sensor:
- platform: touchscreen
name: Button 1
x_min: 0
x_max: 140
y_min: 0
y_max: 65
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.zb_steckdose_ring
##################################################################################
# KNOPF - WZ-Stehlampe
##################################################################################
- platform: touchscreen
name: Button 2
x_min: 140
x_max: 280
y_min: 0
y_max: 65
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.zb_licht_wohnzimmer
##################################################################################
# KNOPF - Küche-Licht
##################################################################################
- platform: touchscreen
name: Button 3
x_min: 0
x_max: 140
y_min: 65
y_max: 130
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.zb_steckdose_kuche_i
##################################################################################
# KNOPF - WZ-Paneel
##################################################################################
- platform: touchscreen
name: Button 4
x_min: 140
x_max: 280
y_min: 65
y_max: 130
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.zb_steckdose_paneel
##################################################################################
# KNOPF - Terrasse-Licht
##################################################################################
- platform: touchscreen
name: Button 5
x_min: 0
x_max: 140
y_min: 130
y_max: 195
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.lichterkette_terrasse
##################################################################################
# KNOPF - Gast WC-Licht
##################################################################################
- platform: touchscreen
name: Button 6
x_min: 140
x_max: 280
y_min: 130
y_max: 195
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.wifi_schalter_gast_wc
- platform: touchscreen
name: Button 7
x_min: 0
x_max: 140
y_min: 195
y_max: 260
on_press:
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
##################################################################################
# KNOPF - Man Cave-Licht
##################################################################################
- platform: touchscreen
name: Button 8
x_min: 140
x_max: 280
y_min: 195
y_max: 260
on_press:
then:
- if:
condition:
lambda: 'return !id(show_return_page);'
then:
- globals.set:
id: show_return_page
value: !lambda "return !id(show_return_page);"
else:
- homeassistant.service:
service: switch.toggle
data:
entity_id: switch.zb_unterputz_cave
##################################################################################
# Setup the ili9xxx platform
##################################################################################
display:
- platform: ili9xxx
id: esp_display
spi_id: tft
model: ili9341
cs_pin: GPIO15
dc_pin: GPIO2
auto_clear_enabled: true
update_interval: 1s
invert_colors: false
dimensions:
height: 320
width: 240
rotation: 0°
color_palette: 8BIT
lambda: |-
if (id(show_return_page)) {
int button_width = 100;
int button_height = 65;
int x_start = 15;
int y_start = 15;
int x_padding = 10;
int y_padding = 10;
// Define los textos para los botones
const char* button_texts[] = {
"Stehlampe",
"Ring Licht",
"Paneel",
"Küche",
"Gäste WC",
"Terrasse",
"Man Cave",
"Start"
};
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 2; col++) {
int button_index = row * 2 + col;
int x = x_start + col * (button_width + x_padding);
int y = y_start + row * (button_height + y_padding);
it.rectangle(x, y, button_width, button_height, id(cravallo_grey));
int text_width = strlen(button_texts[button_index]) * 5.5;
int text_height = 16;
it.print(x + (button_width - text_width) / 2, y + (button_height - text_height) / 2 + 20, id(font_CRAVALLO_Buttontext), button_texts[button_index]);
}
}
if (id(wz_RingLicht).state == "on") {
it.image(155, 20, id(mdi_ringlicht_ON), id(cravallo_orange));
} else {
it.image(155, 20, id(mdi_ringlicht_OFF), id(cravallo_grey));
}
if (id(wz_Stehlampe).state == "on") {
it.image(45, 20, id(mdi_stehlampe_ON), id(cravallo_orange));
} else {
it.image(45, 20, id(mdi_stehlampe_OFF), id(cravallo_grey));
}
if (id(wz_Paneel).state == "on") {
it.image(45, 95, id(mdi_paneel_ON), id(cravallo_orange));
} else {
it.image(45, 95, id(mdi_paneel_OFF), id(cravallo_grey));
}
if (id(kueche_licht).state == "on") {
it.image(155, 95, id( mdi_kueche_ON), id(cravallo_orange));
} else {
it.image(155, 95, id( mdi_kueche_OFF), id(cravallo_grey));
}
if (id(gastWC_licht).state == "on") {
it.image(45, 170, id(mdi_gastWC_ON), id(cravallo_orange));
} else {
it.image(45, 170, id(mdi_gastWC_OFF), id(cravallo_grey));
}
if (id(terrasse_licht).state == "on") {
it.image(155, 170, id(mdi_terrasse_ON), id(cravallo_orange));
} else {
it.image(155, 170, id(mdi_terrasse_OFF), id(cravallo_grey));
}
if (id(manCave_licht).state == "on") {
it.image(45, 245, id(mdi_manCave_ON), id(cravallo_orange));
} else {
it.image(45, 245, id( mdi_manCave_OFF), id(cravallo_grey));
}
it.image(155, 245, id(mdi_back), id(cravallo_green));
} else {
static int y = 182;
static int y_direction = 4; // Velocidad del movimiento
const int y_min = 180;
const int y_max = 187;
it.fill(id(cravallo_black));
it.printf(120, 35, id(font_CRAVALLO_Datumtext), Color(cravallo_light), TextAlign::CENTER, id( DatumAnzeige).state.c_str());
it.strftime(07, 62, id(font_CRAVALLO_Zeit), "%H:%M:%S", id(esptime).now());
it.printf(120, 145, id(font_CRAVALLO_Infotext), id(cravallo_solar), TextAlign::CENTER, "Solar: %.0fW", id(cravallo_grid_power).state);
it.line(20, 160, 220, 160, Color(cravallo_light));
it.printf(120, 173, id(font_CRAVALLO_Infotext), id(cravallo_verbrauch), TextAlign::CENTER, "Verbrauch: %.0fW", id(cravallo_current_consumption).state);
static int current_text_index = 0;
static float text_timer = 0;
const float text_interval = 4.0; // Intervalo para cambiar el texto en segundos
text_timer += 1.0;
if (text_timer >= text_interval) {
text_timer = 0;
current_text_index = (current_text_index + 1) % 4; // Alternar entre cuatro textos
}
if (current_text_index == 0) {
it.image(104, 220, id(mdi_home_thermometer), id(cravallo_orange));
it.printf(120, 270, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Terrasse: %.1f°", id(bt_terrasse_temperature).state);
it.printf(120, 300, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Luftfeuchte: %.1f%%", id(bt_terrasse_humidity).state);
} else if (current_text_index == 1) {
it.image(104, 220, id(mdi_solar_power_variant_outline), id(cravallo_solar));
it.printf(120, 270, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Abgabe: %.0fW", id(cravallo_power_supplied).state);
it.printf(120, 300, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Autarkie: %.0f%%", id(cravallo_autarkie_prozent).state);
} else if (current_text_index == 2) {
it.image(104, 220, id(mdi_transmission_tower_import), id(cravallo_verbrauch));
it.printf(120, 270, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Bezug: %.0fW", id(cravallo_power_absorbed).state);
it.printf(120, 300, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "Solarbezug: %.0f%%", id(cravallo_eigenverbrauch_prozent).state);
} else if (current_text_index == 3) {
it.image(104, 220, id(mdi_crosshairs_question), id(cravallo_blue));
it.printf(120, 270, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "R.: %s", id(person_roberto_cravallo).state.c_str());
it.printf(120, 300, id(font_CRAVALLO_Infotext), Color(cravallo_light), TextAlign::CENTER, "S.: %s", id(person_sylvia).state.c_str());
}
}
Das Wetterdisplay hat mit HA nichts zu tun.
Foto wenn es läuft wäre klasse!!! 