Building a Multi-Screen ESPHome Telemetry Panel for 10-Inch Racks
Design and build a 2U rackmount faceplate housing five ESPHome displays to monitor server health, RAID status, disk thermals, and backup telemetry via MQTT in a 10-inch rack.

Tested on: Tested on a 10-inch 2U rack panel using ESPHome on ESP32-2432S028 (CYD), ESP32-C3 SuperMini, and ESP8266 D1 Mini/NodeMCU boards reporting from a Linux home server via Mosquitto MQTT.
Before you start
In a compact 10-inch homelab rack, monitoring server health, disk thermals, and container states typically requires loading browser dashboards or attaching a large secondary monitor. When running a dedicated 2U server, having physical telemetry indicators directly on the front panel provides instant, glanceable situational awareness without opening a terminal or browser.
This tutorial walks through building a five-display 2U telemetry faceplate powered by ESPHome and MQTT. You will learn how to mount two 2.8-inch color TFTs, a center 1.69-inch LCD, and two mini OLED screens into a clean, screwless 3D-printed panel, wire lightweight microcontrollers behind the plate, run a root telemetry publisher service on your server, and configure each screen with fail-safe telemetry timeouts.
What you need
- 2× ESP32-2432S028 'Cheap Yellow Display' (CYD) 2.8-inch TFT boards (ST7789V variant)
- 1× Waveshare 1.69-inch SPI LCD module (ST7789V2 controller, 240×280)
- 2× 0.96-inch SSD1306 monochrome OLED displays (7-pin SPI version, 128×64)
- 1× ESP32-C3 SuperMini development board (for the Waveshare center display)
- 2× ESP8266 D1 Mini or NodeMCU boards (for the SPI OLED displays, or a single ESP32-C3)
- 3D printer and filament (PETG or PLA, minimum bed width or diagonal of 254 mm)
- B-7000 electronics adhesive or 0.5 mm thin VHB double-sided acrylic tape
- Short jumper wires (3–5 cm) and USB power/data cables
- Standard rack screws and cage nuts for your 10-inch rack rails
- A host Linux server running Docker, Mosquitto MQTT broker, smartctl, and mdadm
Step 1 · Print Test Coupons and Verify Pocket Tolerances
Before committing filament to a full 254 mm 2U faceplate, print small test coupons for each display type. The mounting design recesses each screen into the rear of the faceplate, leaving a thin front skin (SKIN = 0.8 mm) of plastic so the glass sits nearly flush with the front surface.
The CYD 2.8-inch display requires a 69.6 × 50.0 mm pocket for its outer glass perimeter. However, the active display area is not perfectly centered because of the inactive margin where the touch digitizer flex cable exits. To prevent blank borders on one side or clipped pixels on the other, maintain the 58.8 × 44.4 mm window opening but shift it 3.0 mm outward (CYD_SHIFT_OUT = 3.0). This keeps the inactive border hidden toward the center behind the front panel.
The Waveshare 1.69-inch module requires a 31.8 × 39.3 mm pocket with a 28.8 × 33.4 mm window shifted 1.27 mm above center. The 0.96-inch OLED displays require a 27.8 × 28.1 mm pocket. Test each display in its printed coupon to confirm fitment.
Step 2 · Slice and 3D Print the 2U Rack Faceplate
The front plate measures 254 × 88.9 mm (standard 2U dimensions for a 10-inch rack) with approximately 222 mm of usable width between the mounting ears. The panel includes 8 rack-mounting slots (10 × 7 mm, located at x = ±118.26 mm, and y = ±38.1 mm and ±6.35 mm from the center).
Slice the faceplate face-down directly on the print bed. This orientation eliminates the need for support structures inside the display apertures and creates a smooth or textured front finish. If your faceplate model includes debossed front text, print the corresponding 0.8 mm text inlay piece in a contrasting filament color and press-fit or glue it into the front recess.
Step 3 · Mount the Displays Flush from the Rear
To achieve a clean front panel appearance without visible screw heads, all displays mount from behind using adhesive around the glass perimeter.
Clean the rear recess borders with isopropyl alcohol. Apply a thin 2–3 mm bead of B-7000 electronics adhesive or narrow strips of 0.5 mm VHB double-sided tape along the perimeter shelf of each opening. Never apply adhesive over the active display area.
Insert the two CYD units into their outer positions, ensuring the wider inactive glass borders point inward toward the center of the rack. Seat the Waveshare 1.69-inch LCD in the center pocket and place the two 0.96-inch OLEDs in the upper corners. Allow the adhesive to cure completely before continuing with wiring.
Step 4 · Wire the Waveshare and OLED Microcontrollers
The two CYD units integrate their own ESP32 controllers on-board. For the remaining three screens, wire separate microcontrollers behind the faceplate using short (3–5 cm) jumper leads:
1. Waveshare 1.69-inch SPI LCD to ESP32-C3 SuperMini:
- DIN -> GPIO7
- CLK -> GPIO6
- CS -> GPIO10
- DC -> GPIO4
- RST -> GPIO3
- BL -> GPIO5
- VCC -> 3V3, GND -> GND
2. Left 7-pin SPI OLED to ESP8266 D1 Mini:
- VCC -> 3V3, GND -> G
- D0 (CLK) -> D5
- D1 (MOSI) -> D7
- CS -> D1
- DC -> D2
- RES -> D0
Wire the right 7-pin SPI OLED identically to a second D1 Mini or NodeMCU (or adapt both OLEDs to share CLK/MOSI/DC/RES on a single ESP32-C3 with distinct CS pins).
Waveshare 1.69" -> ESP32-C3 SuperMini:
DIN -> GPIO7
CLK -> GPIO6
CS -> GPIO10
DC -> GPIO4
RST -> GPIO3
BL -> GPIO5
VCC -> 3V3
GND -> GND
0.96" SPI OLED -> ESP8266 D1 Mini:
D0 (CLK) -> D5 (GPIO14)
D1 (MOSI) -> D7 (GPIO13)
CS -> D1 (GPIO5)
DC -> D2 (GPIO4)
RES -> D0 (GPIO16)
VCC -> 3V3
GND -> GStep 5 · Deploy the Host Telemetry Publisher Service
The telemetry displays read retained MQTT messages published under rack/server/*. A lightweight bash script running on the host server gathers metrics every 10 seconds and publishes them using mosquitto_pub.
Querying disk drive thermals via smartctl and RAID array statuses via mdadm requires elevated system privileges. If the script runs without root access, drive temperatures report as 0 °C. Install the publisher script into /usr/local/sbin/rack-telemetry-publisher.sh and run it via a systemd unit under the root account.
The script also publishes a rack/server/vivo heartbeat timestamp each cycle. If the server or publisher halts, the displays detect that the heartbeat has stopped and display a warning.
[Unit]
Description=Rack Telemetry MQTT Publisher
After=network.target mosquitto.service docker.service
[Service]
Type=simple
User=root
ExecStart=/usr/local/sbin/rack-telemetry-publisher.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetStep 6 · Configure and Flash the CYD Panels
The CYD 2.8-inch units use the ST7789V driver over mipi_spi with hardware pins: CLK on GPIO14, MOSI on GPIO13, CS on GPIO15, DC on GPIO2, and backlight control on GPIO21 using LEDC PWM.
Configure ESPHome with LVGL to format the metrics. The left CYD displays storage thermals, pool utilization, and array states. The right CYD displays CPU load, RAM usage, network bandwidth, container counts, and rack wattage. Both firmwares monitor an idle timer: if no MQTT message is received for more than 60,000 ms, the screen switches to displaying SIN DATOS (NO DATA).
Perform the initial flash over USB. When updating configurations over OTA, compile and upload using esphome run --no-logs --device <device_ip> rather than esphome upload.
spi:
id: lcd
clk_pin: GPIO14
mosi_pin: GPIO13
output:
- platform: ledc
pin: GPIO21
id: gpio_backlight_pwm
light:
- platform: monochromatic
output: gpio_backlight_pwm
id: back_light
name: "Backlight"
restore_mode: ALWAYS_ON
default_transition_length: 0s
display:
- platform: mipi_spi
id: pantalla
spi_id: lcd
model: ST7789V
cs_pin: 15
dc_pin: 2
invert_colors: false
update_interval: never
auto_clear_enabled: false
data_rate: 40MHz
dimensions:
width: 240
height: 320Step 7 · Flash the Waveshare LCD and SPI OLEDs
1. Waveshare 1.69-inch Center Display: Flash the ESP32-C3 SuperMini using mipi_spi and model: ST7789V with dimensions 240×280, offset_height: 20, and invert_colors: true. This screen renders maximum storage temperatures with color thresholds. Full redraws take roughly 120–200 ms, so keep animation update intervals at 200 ms or higher to avoid choppy rendering.
2. 0.96-inch SPI OLEDs: Flash the ESP8266 D1 Mini boards using ssd1306_spi. Because the ESP8266 has limited RAM, omit the ESPHome native api: component. The device operates reliably on MQTT subscriptions and OTA alone.
If a D1 Mini fails to enter flashing mode over USB with serial sync errors, connect a temporary jumper wire between pin D3 (GPIO0) and GND before plugging in the cable to force download mode, then remove the jumper once flashing begins.
spi:
clk_pin: D5
mosi_pin: D7
display:
- platform: ssd1306_spi
model: "SSD1306 128x64"
cs_pin: D1
dc_pin: D2
reset_pin: D0
update_interval: 2s
lambda: |-
bool vivo_ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < 60000;
if (!vivo_ok) {
it.print(64, 32, id(f_med), TextAlign::CENTER, "NO DATA");
return;
}
it.print(0, 0, id(f_peq), "BACKUP");
it.print(128, 0, id(f_med), TextAlign::TOP_RIGHT, id(resp_estado).state.c_str());
it.print(0, 14, id(f_gde), id(resp_hora).state.c_str());Step 8 · Mount the Panel and Verify Telemetry Flow
Install the completed 2U panel into your 10-inch rack using standard rack screws into the 8 outer slots. Route USB power cables from a multi-port USB supply to each microcontroller behind the panel.
Verify that all five displays boot, connect to Wi-Fi, sync with the MQTT broker, and populate with live telemetry. To verify failover handling, temporarily stop the publisher service on the server:
sudo systemctl stop rack-telemetry.service
Confirm that after 60 seconds of silence, each display cleanly transitions to showing SIN DATOS or NO DATA. Restart the service and verify that the retained topics instantly restore the readouts.
# Check service logs
sudo journalctl -u rack-telemetry.service -f
# Test watchdog timeout
sudo systemctl stop rack-telemetry.service
# Wait 60 seconds and observe 'NO DATA' on screens
# Restore service
sudo systemctl start rack-telemetry.serviceTroubleshooting
ESPHome OTA upload completes successfully, but screen rotation, layout, or string changes do not appear on the display.
The command esphome upload only uploads the previously compiled binary without rebuilding it. Run esphome run --no-logs --device <device_ip> to force a recompile and flash.
Hard drive temperatures and RAID status always report as 0 or empty.
Querying SMART attributes via smartctl and array health via mdadm requires root access. Ensure rack-telemetry-publisher.sh runs as a systemd service with User=root.
ESP8266 crashes with out-of-memory errors or fails to boot when driving a display.
Color displays using mipi_spi or large framebuffers require more RAM than the ESP8266 provides; use an ESP32 or ESP32-C3 for color screens. For monochrome OLEDs on the ESP8266, remove the api: component to free up heap space.
Compiling ESPHome on Windows fails with path length errors or fails silently in Git Bash.
ESP-IDF breaks when paths exceed 260 characters. Set the environment variable ESPHOME_ESP_IDF_PREFIX=C:\ESPHome\idf and compile from a native PowerShell terminal rather than Git Bash/MSys.
An ESP8266 D1 Mini fails to sync over USB during initial flashing with serial boot errors.
Some clone boards fail to toggle boot pins automatically. Connect a jumper wire between pin D3 (GPIO0) and GND before plugging in USB to force download mode, start the flash, and remove the jumper once data transfer begins.
All panel screens display 'NO DATA' after the main host server restarts.
If Mosquitto runs in Docker with restart: unless-stopped, an abrupt shutdown (SIGKILL 137) may leave it stopped. Update the container policy to restart: always in your Docker Compose file.
What I learned
- Always print small fitment coupons before fabricating a full 254 mm faceplate. Doing so exposed the CYD's 3 mm asymmetric digitizer margin before printing the main plate.
- Do not rely on
esphome uploadto deploy configuration tweaks. It skips compilation and deploys stale binaries. Always useesphome run. - Match microcontroller memory to display requirements: ESP8266 boards are cost-effective for small monochrome OLEDs, but color SPI displays require the larger RAM pool of an ESP32 or ESP32-C3.
- Omitting the native
api:component on resource-constrained ESP8266 microcontrollers provides rock-solid stability for MQTT subscriptions and OTA updates.
Next steps
- Subscribe directly to a Zigbee2MQTT smart plug topic to monitor real-time server wattage on the right-hand CYD or OLED.
- Configure color-shifting logic in ESPHome to dynamically turn thermal readings amber or red when disk temperatures climb.
- Set up automatic nighttime display dimming using the PWM backlight output to reduce ambient light.
Get the code
Example ESPHome configurations, host telemetry publisher script, systemd service, and secrets template for a 5-display 2U rackmount telemetry panel.
Files in the repository (9)
README.md
# Multi-Display 2U Rackmount Telemetry Panel
This repository provides the ESPHome configuration files, host telemetry publishing script, and systemd service definition for a 5-display 2U telemetry faceplate designed for 10-inch homelab racks.
## Hardware Architecture
- **Left CYD (ESP32-2432S028)**: Storage health (SAS/SATA drive temperatures, RAID state, pool usage, and fans).
- **Right CYD (ESP32-2432S028)**: System performance (CPU load, RAM usage, network bandwidth, container counts, and wattage).
- **Center Display (Waveshare 1.69" LCD + ESP32-C3)**: Maximum storage drive thermals with dynamic color thresholds.
- **Left OLED (0.96" SSD1306 SPI + ESP8266 D1 Mini)**: Nightly backup status and timestamp.
- **Right OLED (0.96" SSD1306 SPI + NodeMCU / D1 Mini)**: Total rack power consumption and clock.
## Directory Structure
- `esphome/`: ESPHome YAML configuration files for all five display nodes.
- `scripts/`: Host telemetry publisher script (`rack-telemetry-publisher.sh`).
- `systemd/`: Systemd service unit to run the publisher as root on the server.
- `secrets.yaml.example`: Template for Wi-Fi, MQTT, and OTA credentials.
## Setup Instructions
1. Copy `secrets.yaml.example` to `secrets.yaml` inside your ESPHome configuration directory and fill in your network credentials.
2. Copy `scripts/rack-telemetry-publisher.sh` to `/usr/local/sbin/rack-telemetry-publisher.sh` on your server and make it executable (`chmod +x`).
3. Copy `systemd/rack-telemetry.service` to `/etc/systemd/system/`, reload systemd (`sudo systemctl daemon-reload`), and enable the service (`sudo systemctl enable --now rack-telemetry.service`).
4. Flash the microcontrollers via USB initially, then deploy updates over OTA using `esphome run --no-logs --device <ip>`.secrets.yaml.example
# Network & Broker Secrets for ESPHome Nodes
wifi_ssid: "YOUR_WIFI_SSID"
wifi_password: "YOUR_WIFI_PASSWORD"
wifi_ap_password: "YOUR_FALLBACK_AP_PASSWORD"
ota_password: "YOUR_OTA_PASSWORD"
mqtt_broker_host: "192.168.1.50"
mqtt_broker_user: "telemetry_user"
mqtt_broker_password: "YOUR_MQTT_PASSWORD"
cyd_left_api_key: "OPTIONAL_OR_GENERATE_KEY"
cyd_right_api_key: "OPTIONAL_OR_GENERATE_KEY"scripts/rack-telemetry-publisher.sh
#!/usr/bin/env bash
# Rack Telemetry Publisher Script
# Publishes retained system metrics to MQTT every 10 seconds.
# Must be run as root to access smartctl and mdadm data.
set -u
MQTT_HOST="127.0.0.1"
MQTT_USER="telemetry_user"
MQTT_PASS="YOUR_MQTT_PASSWORD"
TOPIC_PREFIX="rack/server"
INTERVAL=10
publish() {
local subtopic="$1"
local payload="$2"
mosquitto_pub -h "$MQTT_HOST" -u "$MQTT_USER" -P "$MQTT_PASS" \
-r -t "${TOPIC_PREFIX}/${subtopic}" -m "$payload"
}
while true; do
# System vitals
CPU_LOAD=$(awk '{print $1}' /proc/loadavg)
RAM_PCT=$(free | awk '/Mem:/ {printf("%.0f", $3/$2 * 100)}')
UPTIME_DAYS=$(awk '{printf("%.0f", $1/86400)}' /proc/uptime)
publish "cpu/uso_pct" "$CPU_LOAD"
publish "ram/uso_pct" "$RAM_PCT"
publish "uptime_dias" "$UPTIME_DAYS"
# CPU Temperature (adjust thermal zone as appropriate)
if [ -f /sys/class/thermal/thermal_zone0/temp ]; then
CPU_TEMP=$(awk '{printf("%.0f", $1/1000)}' /sys/class/thermal/thermal_zone0/temp)
publish "cpu/temp" "$CPU_TEMP"
fi
# Disk usage
ROOT_USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%')
publish "m2/usado_pct" "$ROOT_USAGE"
# Docker container metrics
if command -v docker >/dev/null 2>&1; then
DOCKER_UP=$(docker ps -q | wc -l)
DOCKER_TOTAL=$(docker ps -a -q | wc -l)
publish "docker/arriba" "$DOCKER_UP"
publish "docker/total" "$DOCKER_TOTAL"
fi
# Network metrics (bytes on primary interface)
NET_IF=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $5; exit}')
if [ -n "$NET_IF" ] && [ -f "/sys/class/net/${NET_IF}/statistics/rx_bytes" ]; then
RX1=$(cat "/sys/class/net/${NET_IF}/statistics/rx_bytes")
TX1=$(cat "/sys/class/net/${NET_IF}/statistics/tx_bytes")
sleep 1
RX2=$(cat "/sys/class/net/${NET_IF}/statistics/rx_bytes")
TX2=$(cat "/sys/class/net/${NET_IF}/statistics/tx_bytes")
RX_MBPS=$(awk -v r1="$RX1" -v r2="$RX2" 'BEGIN {printf("%.1f", (r2-r1)*8/1000000)}')
TX_MBPS=$(awk -v t1="$TX1" -v t2="$TX2" 'BEGIN {printf("%.1f", (t2-t1)*8/1000000)}')
publish "red/rx_mbps" "$RX_MBPS"
publish "red/tx_mbps" "$TX_MBPS"
else
sleep 1
fi
# Storage thermals and health (requires root)
# Example SAS/SATA drives: /dev/sda through /dev/sdd
MAX_TEMP=0
INDEX=1
for DEV in /dev/sd[a-d]; do
if [ -b "$DEV" ]; then
TEMP=$(smartctl -A "$DEV" 2>/dev/null | awk '/Temperature_Celsius|Current Drive Temperature/ {print $NF; exit}')
if [ -n "$TEMP" ] && [ "$TEMP" -gt 0 ] 2>/dev/null; then
publish "sas/${INDEX}" "$TEMP"
[ "$TEMP" -gt "$MAX_TEMP" ] && MAX_TEMP="$TEMP"
fi
INDEX=$((INDEX + 1))
fi
done
publish "sas/max" "$MAX_TEMP"
# RAID status via mdadm
if [ -f /proc/mdstat ]; then
RAID_STATUS="OK"
if grep -q "degraded" /proc/mdstat 2>/dev/null; then
RAID_STATUS="DEGRADADO"
fi
publish "raid/md1" "$RAID_STATUS"
fi
# Backup status
publish "respaldo/estado" "OK"
publish "respaldo/ultimo" "$(date +'%Y-%m-%d %H:%M')"
# Heartbeat
publish "vivo" "$(date +%s)"
sleep "$((INTERVAL - 1))"
donesystemd/rack-telemetry.service
[Unit]
Description=Rack Telemetry MQTT Publisher
After=network.target mosquitto.service docker.service
[Service]
Type=simple
User=root
ExecStart=/usr/local/sbin/rack-telemetry-publisher.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetesphome/cyd-left-storage.yaml
# CYD Left - Storage & Thermals Telemetry
substitutions:
nombre: rack-cyd-izq
rotacion: "90"
brillo: "0.85"
timeout_datos_ms: "60000"
esphome:
name: ${nombre}
friendly_name: "Rack CYD Left"
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret cyd_left_api_key
reboot_timeout: 0s
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ap:
ssid: "Rack-CYD-Left-Fallback"
password: !secret wifi_ap_password
captive_portal:
mqtt:
broker: !secret mqtt_broker_host
username: !secret mqtt_broker_user
password: !secret mqtt_broker_password
discovery: false
time:
- platform: sntp
id: reloj
timezone: UTC
globals:
- id: ultimo_dato_ms
type: uint32_t
initial_value: "0"
spi:
id: lcd
clk_pin: GPIO14
mosi_pin: GPIO13
output:
- platform: ledc
pin: GPIO21
id: gpio_backlight_pwm
light:
- platform: monochromatic
output: gpio_backlight_pwm
id: back_light
name: "Backlight"
restore_mode: ALWAYS_ON
default_transition_length: 0s
on_turn_on:
- light.control: { id: back_light, brightness: !lambda 'return atof("${brillo}");' }
sensor:
- platform: mqtt_subscribe
id: sas1_temp
topic: rack/server/sas/1
internal: true
on_value:
- lambda: 'id(ultimo_dato_ms) = millis();'
- platform: mqtt_subscribe
id: sas2_temp
topic: rack/server/sas/2
internal: true
- platform: mqtt_subscribe
id: sas3_temp
topic: rack/server/sas/3
internal: true
- platform: mqtt_subscribe
id: sas4_temp
topic: rack/server/sas/4
internal: true
- platform: mqtt_subscribe
id: fan_pwm
topic: rack/server/fan/pwm
internal: true
- platform: mqtt_subscribe
id: pool_uso
topic: rack/server/pool/usado_pct
internal: true
text_sensor:
- platform: mqtt_subscribe
id: raid_md1
topic: rack/server/raid/md1
internal: true
- platform: mqtt_subscribe
id: resp_estado
topic: rack/server/respaldo/estado
internal: true
display:
- platform: mipi_spi
id: pantalla
spi_id: lcd
model: ST7789V
cs_pin: 15
dc_pin: 2
invert_colors: false
update_interval: never
auto_clear_enabled: false
data_rate: 40MHz
dimensions:
width: 240
height: 320
lvgl:
displays:
- pantalla
rotation: ${rotacion}
buffer_size: 25%
bg_color: 0x0B0907
style_definitions:
- id: st_p
bg_color: 0x1A140F
bg_opa: COVER
border_color: 0x33271B
border_width: 1
radius: 6
pages:
- id: p_storage
bg_color: 0x0B0907
widgets:
- obj:
x: 0
y: 0
width: 320
height: 26
bg_color: 0x0B0907
border_width: 0
widgets:
- label: { text: "STORAGE & ARRAYS", text_color: 0xF4EAD9, x: 10, y: 4 }
- label: { id: l_status, text: "ONLINE", text_color: 0x55FF55, align: TOP_RIGHT, x: -10, y: 4 }
- obj:
x: 8
y: 34
width: 304
height: 198
styles: st_p
widgets:
- label: { id: l_t1, text: "D1: -- °C", text_color: 0xF4EAD9, x: 14, y: 14 }
- label: { id: l_t2, text: "D2: -- °C", text_color: 0xF4EAD9, x: 14, y: 44 }
- label: { id: l_t3, text: "D3: -- °C", text_color: 0xF4EAD9, x: 14, y: 74 }
- label: { id: l_t4, text: "D4: -- °C", text_color: 0xF4EAD9, x: 14, y: 104 }
- label: { id: l_raid, text: "RAID: --", text_color: 0xFFB05C, x: 160, y: 14 }
- label: { id: l_pool, text: "Pool: -- %", text_color: 0xFFB05C, x: 160, y: 44 }
- label: { id: l_warn, text: "", text_color: 0xFF4444, x: 160, y: 104 }
interval:
- interval: 2s
then:
- lambda: |-
char buf[32];
bool ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < ${timeout_datos_ms};
if (!ok) {
lv_label_set_text(id(l_status), "NO DATA");
lv_label_set_text(id(l_warn), "TIMEOUT >60s");
return;
}
lv_label_set_text(id(l_status), "ONLINE");
lv_label_set_text(id(l_warn), "");
if (!isnan(id(sas1_temp).state)) { snprintf(buf, sizeof(buf), "D1: %.0f °C", id(sas1_temp).state); lv_label_set_text(id(l_t1), buf); }
if (!isnan(id(sas2_temp).state)) { snprintf(buf, sizeof(buf), "D2: %.0f °C", id(sas2_temp).state); lv_label_set_text(id(l_t2), buf); }
if (!isnan(id(sas3_temp).state)) { snprintf(buf, sizeof(buf), "D3: %.0f °C", id(sas3_temp).state); lv_label_set_text(id(l_t3), buf); }
if (!isnan(id(sas4_temp).state)) { snprintf(buf, sizeof(buf), "D4: %.0f °C", id(sas4_temp).state); lv_label_set_text(id(l_t4), buf); }
if (id(raid_md1).has_state()) { snprintf(buf, sizeof(buf), "RAID: %s", id(raid_md1).state.c_str()); lv_label_set_text(id(l_raid), buf); }
if (!isnan(id(pool_uso).state)) { snprintf(buf, sizeof(buf), "Pool: %.0f %%", id(pool_uso).state); lv_label_set_text(id(l_pool), buf); }esphome/cyd-right-server.yaml
# CYD Right - Server Metrics & Power Telemetry
substitutions:
nombre: rack-cyd-der
rotacion: "90"
brillo: "0.85"
fijo_w: "15"
timeout_datos_ms: "60000"
esphome:
name: ${nombre}
friendly_name: "Rack CYD Right"
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret cyd_right_api_key
reboot_timeout: 0s
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ap:
ssid: "Rack-CYD-Right-Fallback"
password: !secret wifi_ap_password
captive_portal:
mqtt:
broker: !secret mqtt_broker_host
username: !secret mqtt_broker_user
password: !secret mqtt_broker_password
discovery: false
time:
- platform: sntp
id: reloj
timezone: UTC
globals:
- id: ultimo_dato_ms
type: uint32_t
initial_value: "0"
spi:
id: lcd
clk_pin: GPIO14
mosi_pin: GPIO13
output:
- platform: ledc
pin: GPIO21
id: gpio_backlight_pwm
light:
- platform: monochromatic
output: gpio_backlight_pwm
id: back_light
name: "Backlight"
restore_mode: ALWAYS_ON
default_transition_length: 0s
on_turn_on:
- light.control: { id: back_light, brightness: !lambda 'return atof("${brillo}");' }
sensor:
- platform: mqtt_subscribe
id: cpu_pct
topic: rack/server/cpu/uso_pct
internal: true
on_value:
- lambda: 'id(ultimo_dato_ms) = millis();'
- platform: mqtt_subscribe
id: ram_pct
topic: rack/server/ram/uso_pct
internal: true
- platform: mqtt_subscribe
id: net_rx
topic: rack/server/red/rx_mbps
internal: true
- platform: mqtt_subscribe
id: net_tx
topic: rack/server/red/tx_mbps
internal: true
- platform: mqtt_subscribe
id: dock_up
topic: rack/server/docker/arriba
internal: true
- platform: mqtt_subscribe
id: dock_tot
topic: rack/server/docker/total
internal: true
- platform: mqtt_subscribe
id: pwr_w
topic: rack/server/power
internal: true
display:
- platform: mipi_spi
id: pantalla
spi_id: lcd
model: ST7789V
cs_pin: 15
dc_pin: 2
invert_colors: false
update_interval: never
auto_clear_enabled: false
data_rate: 40MHz
dimensions:
width: 240
height: 320
lvgl:
displays:
- pantalla
rotation: ${rotacion}
buffer_size: 25%
bg_color: 0x0B0907
style_definitions:
- id: st_p
bg_color: 0x1A140F
bg_opa: COVER
border_color: 0x33271B
border_width: 1
radius: 6
pages:
- id: p_server
bg_color: 0x0B0907
widgets:
- obj:
x: 0
y: 0
width: 320
height: 26
bg_color: 0x0B0907
border_width: 0
widgets:
- label: { text: "SERVER VITALS", text_color: 0xF4EAD9, x: 10, y: 4 }
- label: { id: l_status_r, text: "ONLINE", text_color: 0x55FF55, align: TOP_RIGHT, x: -10, y: 4 }
- obj:
x: 8
y: 34
width: 304
height: 198
styles: st_p
widgets:
- label: { id: l_cpu, text: "CPU: -- %", text_color: 0xF4EAD9, x: 14, y: 14 }
- label: { id: l_ram, text: "RAM: -- %", text_color: 0xF4EAD9, x: 14, y: 44 }
- label: { id: l_net, text: "Net: ↓ -- ↑ -- Mb/s", text_color: 0xFFB05C, x: 14, y: 74 }
- label: { id: l_dock, text: "Docker: --/--", text_color: 0xF4EAD9, x: 14, y: 104 }
- label: { id: l_power, text: "Power: -- W", text_color: 0x55FF55, x: 14, y: 134 }
interval:
- interval: 2s
then:
- lambda: |-
char buf[48];
bool ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < ${timeout_datos_ms};
if (!ok) {
lv_label_set_text(id(l_status_r), "NO DATA");
return;
}
lv_label_set_text(id(l_status_r), "ONLINE");
if (!isnan(id(cpu_pct).state)) { snprintf(buf, sizeof(buf), "CPU: %.1f %%", id(cpu_pct).state); lv_label_set_text(id(l_cpu), buf); }
if (!isnan(id(ram_pct).state)) { snprintf(buf, sizeof(buf), "RAM: %.0f %%", id(ram_pct).state); lv_label_set_text(id(l_ram), buf); }
float rx = isnan(id(net_rx).state) ? 0.0 : id(net_rx).state;
float tx = isnan(id(net_tx).state) ? 0.0 : id(net_tx).state;
snprintf(buf, sizeof(buf), "Net: v %.1f ^ %.1f Mb/s", rx, tx);
lv_label_set_text(id(l_net), buf);
if (!isnan(id(dock_up).state) && !isnan(id(dock_tot).state)) {
snprintf(buf, sizeof(buf), "Docker: %.0f/%.0f", id(dock_up).state, id(dock_tot).state);
lv_label_set_text(id(l_dock), buf);
}
if (!isnan(id(pwr_w).state)) {
float tot = id(pwr_w).state + atof("${fijo_w}");
snprintf(buf, sizeof(buf), "Rack Total: %.0f W", tot);
lv_label_set_text(id(l_power), buf);
}esphome/waveshare-center.yaml
# Waveshare 1.69" Center LCD - ESP32-C3 SuperMini
substitutions:
nombre: rack-wav-centro
timeout_datos_ms: "60000"
esphome:
name: ${nombre}
friendly_name: "Rack Center LCD"
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
logger:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ap:
ssid: "Rack-Wav-Center-Fallback"
password: !secret wifi_ap_password
captive_portal:
mqtt:
broker: !secret mqtt_broker_host
username: !secret mqtt_broker_user
password: !secret mqtt_broker_password
discovery: false
globals:
- id: ultimo_dato_ms
type: uint32_t
initial_value: "0"
spi:
clk_pin: GPIO6
mosi_pin: GPIO7
output:
- platform: ledc
pin: GPIO5
id: gpio_bl
sensor:
- platform: mqtt_subscribe
id: sas_max
topic: rack/server/sas/max
internal: true
on_value:
- lambda: 'id(ultimo_dato_ms) = millis();'
font:
- file: "gfonts://Roboto@700"
id: f_large
size: 48
glyphs: "0123456789°C"
- file: "gfonts://Roboto"
id: f_small
size: 16
glyphs: "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz:0123456789"
display:
- platform: mipi_spi
id: lcd_center
model: ST7789V
cs_pin: GPIO10
dc_pin: GPIO4
reset_pin: GPIO3
invert_colors: true
data_rate: 40MHz
dimensions:
width: 240
height: 280
offset_height: 20
update_interval: 200ms
lambda: |-
bool ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < ${timeout_datos_ms};
if (!ok) {
it.print(120, 140, id(f_small), TextAlign::CENTER, "NO DATA");
return;
}
it.print(120, 40, id(f_small), TextAlign::CENTER, "MAX DRIVE TEMP");
if (!isnan(id(sas_max).state)) {
char b[16];
snprintf(b, sizeof(b), "%.0f°C", id(sas_max).state);
Color c = id(sas_max).state >= 45.0 ? Color(255, 60, 60) : Color(60, 255, 60);
it.print(120, 140, id(f_large), c, TextAlign::CENTER, b);
}esphome/oled-left-backup.yaml
# OLED Left - Backup Status (0.96" SSD1306 SPI on ESP8266 D1 Mini)
# Omits 'api:' to conserve RAM on ESP8266
substitutions:
nombre: rack-oled-izq
timeout_datos_ms: "60000"
esphome:
name: ${nombre}
friendly_name: "Rack OLED Left"
esp8266:
board: d1_mini
logger:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ap:
ssid: "Rack-OLED-Left-Fallback"
password: !secret wifi_ap_password
captive_portal:
mqtt:
broker: !secret mqtt_broker_host
username: !secret mqtt_broker_user
password: !secret mqtt_broker_password
discovery: false
globals:
- id: ultimo_dato_ms
type: uint32_t
initial_value: "0"
font:
- file: "gfonts://Roboto@700"
id: f_med
size: 16
glyphs: " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:-/.%"
- file: "gfonts://Roboto@700"
id: f_gde
size: 28
glyphs: "0123456789:--"
- file: "gfonts://Roboto"
id: f_peq
size: 11
glyphs: " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:-/.%"
spi:
clk_pin: D5
mosi_pin: D7
sensor:
- platform: mqtt_subscribe
id: vivo
topic: rack/server/vivo
internal: true
on_value:
- lambda: 'id(ultimo_dato_ms) = millis();'
text_sensor:
- platform: mqtt_subscribe
id: resp_estado
topic: rack/server/respaldo/estado
internal: true
- platform: mqtt_subscribe
id: resp_ultimo
topic: rack/server/respaldo/ultimo
internal: true
display:
- platform: ssd1306_spi
model: "SSD1306 128x64"
cs_pin: D1
dc_pin: D2
reset_pin: D0
update_interval: 2s
lambda: |-
bool vivo_ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < ${timeout_datos_ms};
if (!vivo_ok) {
it.print(64, 32, id(f_med), TextAlign::CENTER, "NO DATA");
return;
}
std::string ru = id(resp_ultimo).state;
std::string hhmm = ru.size() >= 16 ? ru.substr(11, 5) : std::string("--:--");
std::string dia = ru.size() >= 10 ? ru.substr(8, 2) + "/" + ru.substr(5, 2) : std::string("--/--");
bool ok = id(resp_estado).state == "OK";
it.print(0, 0, id(f_peq), "BACKUP");
it.print(128, 0, id(f_med), TextAlign::TOP_RIGHT, ok ? "OK" : "FAIL");
it.print(0, 14, id(f_gde), hhmm.c_str());
it.printf(0, 50, id(f_peq), "Last: %s", dia.c_str());
if (ok) {
it.filled_rectangle(0, 48, 128, 1);
}esphome/oled-right-power.yaml
# OLED Right - Rack Power & Clock (0.96" SSD1306 SPI on NodeMCU / D1 Mini)
# Omits 'api:' to conserve RAM on ESP8266
substitutions:
nombre: rack-oled-der
fijo_w: "15"
timeout_datos_ms: "60000"
esphome:
name: ${nombre}
friendly_name: "Rack OLED Right"
esp8266:
board: d1_mini
logger:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
ap:
ssid: "Rack-OLED-Right-Fallback"
password: !secret wifi_ap_password
captive_portal:
mqtt:
broker: !secret mqtt_broker_host
username: !secret mqtt_broker_user
password: !secret mqtt_broker_password
discovery: false
globals:
- id: ultimo_dato_ms
type: uint32_t
initial_value: "0"
font:
- file: "gfonts://Roboto@700"
id: f_med
size: 16
glyphs: " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:-/.%Ww"
- file: "gfonts://Roboto@700"
id: f_gde
size: 28
glyphs: "0123456789:--Ww "
- file: "gfonts://Roboto"
id: f_peq
size: 11
glyphs: " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:-/.%Ww"
spi:
clk_pin: D5
mosi_pin: D7
sensor:
- platform: mqtt_subscribe
id: pwr_w
topic: rack/server/power
internal: true
on_value:
- lambda: 'id(ultimo_dato_ms) = millis();'
display:
- platform: ssd1306_spi
model: "SSD1306 128x64"
cs_pin: D1
dc_pin: D2
reset_pin: D0
update_interval: 2s
lambda: |-
bool vivo_ok = id(ultimo_dato_ms) != 0 && (millis() - id(ultimo_dato_ms)) < ${timeout_datos_ms};
if (!vivo_ok) {
it.print(64, 32, id(f_med), TextAlign::CENTER, "NO DATA");
return;
}
it.print(0, 0, id(f_peq), "RACK POWER");
if (!isnan(id(pwr_w).state)) {
float total = id(pwr_w).state + atof("${fijo_w}");
char b[16];
snprintf(b, sizeof(b), "%.0f W", total);
it.print(0, 14, id(f_gde), b);
snprintf(b, sizeof(b), "Server: %.0f W", id(pwr_w).state);
it.print(0, 50, id(f_peq), b);
}