11 changed files with 96 additions and 865 deletions
+1 -1
View File
@@ -1 +1 @@
2026.9.2 2026.7.2
-648
View File
@@ -1,648 +0,0 @@
substitutions:
name: "energymonitor"
friendly_name: "Energy Monitor"
grid_power_gauge_max_w: "5000.0"
balcony_solar_gauge_max_w: "800.0"
esphome:
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: monitor.energymonitor
version: "1.0"
on_boot:
then:
- light.turn_on: display_backlight
esp32:
board: m5stack-core-esp32
framework:
type: esp-idf
advanced:
minimum_chip_revision: "3.1"
sram1_as_iram: true
network:
enable_ipv6: true
wifi:
networks:
- ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk
priority: 10
- ssid: "Moppelkotze"
password: !secret moppelkotze_psk
priority: 5
- ssid: "TKRZ"
password: !secret tkrz_psk
priority: 4
use_address: 192.168.126.250
on_connect:
- lambda: id(wifi_connected) = true;
on_disconnect:
- lambda: id(wifi_connected) = false;
power_save_mode: high
min_auth_mode: WPA2
ap:
ssid: "Energymonitor Fallback Hotspot"
password: !secret fallback_psk
captive_portal:
time:
- platform: sntp
id: sntp_time
timezone: Europe/Berlin
servers:
- de.pool.ntp.org
# Values are maintained in secrets.yaml.
wireguard:
id: energymonitor_wireguard
address: !secret energymonitor_wireguard_address
netmask: !secret energymonitor_wireguard_netmask
private_key: !secret energymonitor_wireguard_private_key
peer_endpoint: !secret energymonitor_wireguard_peer_endpoint
peer_port: !secret energymonitor_wireguard_peer_port
peer_public_key: !secret energymonitor_wireguard_peer_public_key
peer_allowed_ips:
- !secret energymonitor_wireguard_peer_allowed_ip
peer_persistent_keepalive: 25s
# Avoid rebooting while the placeholder endpoint is intentionally unreachable.
reboot_timeout: 0s
logger:
api:
id: api_server
encryption:
key: !secret apikey
ota:
platform: esphome
password: !secret ota
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
output:
- platform: gpio
pin: GPIO32
id: display_backlight_output
light:
- platform: binary
id: display_backlight
name: "Display Backlight"
output: display_backlight_output
restore_mode: ALWAYS_ON
font:
- file: "fonts/Roboto-Regular.ttf"
id: font_small
size: 18
glyphsets:
- GF_Latin_Kernel
glyphs: ["äöüÄÖÜß"]
- file: "fonts/Roboto-Bold.ttf"
id: font_title
size: 28
glyphsets:
- GF_Latin_Kernel
glyphs: ["äöüÄÖÜß"]
- file: "fonts/Roboto-Bold.ttf"
id: font_value
size: 52
glyphsets:
- GF_Latin_Kernel
glyphs: ["äöüÄÖÜß"]
- file: "fonts/Roboto-Regular.ttf"
id: font_device
size: 13
glyphsets:
- GF_Latin_Kernel
glyphs: ["äöüÄÖÜß"]
- file: "fonts/materialdesignicons-webfont.ttf"
id: font_icon
size: 24
glyphs:
- "\U000F0306" # mdi:key
- "\U000F07D0" # mdi:home-assistant
- "\U000F091F" # mdi:wifi-strength-1
- "\U000F0922" # mdi:wifi-strength-2
- "\U000F0925" # mdi:wifi-strength-3
- "\U000F0928" # mdi:wifi-strength-4
- "\U000F092D" # mdi:wifi-strength-off
globals:
- id: page_index
type: int
restore_value: true
initial_value: '0'
- id: wifi_connected
type: bool
restore_value: false
initial_value: 'false'
- id: page_one_gauge_view
type: bool
restore_value: true
initial_value: 'false'
- id: clock_digital_view
type: bool
restore_value: true
initial_value: 'false'
- id: device_usage_view
type: int
restore_value: true
initial_value: '0'
sensor:
# WiFi signal strength
- platform: wifi_signal
name: "WiFi Signalstärke"
id: wifisignal
update_interval: 10s
- platform: homeassistant
id: grid_power
entity_id: sensor.netzleistung
internal: true
- platform: homeassistant
id: balcony_solar_power
entity_id: sensor.balkonkraftwerk_power
internal: true
- platform: homeassistant
id: solar_energy_daily
entity_id: sensor.energy_solar_daily
internal: true
- platform: homeassistant
id: grid_import_energy_daily
entity_id: sensor.energy_import_daily
internal: true
- platform: homeassistant
id: grid_export_energy_daily
entity_id: sensor.energy_export_daily
internal: true
- platform: homeassistant
id: hallway_fragrance_power
entity_id: sensor.flur_raumduft_power
internal: true
- platform: homeassistant
id: cellar_power
entity_id: sensor.keller_power
internal: true
- platform: homeassistant
id: sideboard_power
entity_id: sensor.kuche_anrichte_power
internal: true
- platform: homeassistant
id: kitchen_music_power
entity_id: sensor.kuche_musik_power
internal: true
- platform: homeassistant
id: bedroom_bed_power
entity_id: sensor.schlafzimmer_bett_power
internal: true
- platform: homeassistant
id: bedroom_cinema_power
entity_id: sensor.schlafzimmer_heimkino_power
internal: true
- platform: homeassistant
id: desk_decoration_power
entity_id: sensor.schreibtisch_deko_power
internal: true
- platform: homeassistant
id: desk_power
entity_id: sensor.schreibtisch_power
internal: true
- platform: homeassistant
id: server_room_power
entity_id: sensor.serverraum_power
internal: true
- platform: homeassistant
id: living_room_cinema_power
entity_id: sensor.wohnzimmer_heimkino_power
internal: true
- platform: homeassistant
id: games_cabinet_power
entity_id: sensor.wohnzimmer_spieleschrank_power
internal: true
- platform: homeassistant
id: refrigerator_power
entity_id: sensor.tz3000_ww6drja5_ts011f_leistung
internal: true
- platform: homeassistant
id: coffee_machine_power
entity_id: sensor.kaffeemaschine_leistung_2
internal: true
- platform: homeassistant
id: dryer_power
entity_id: sensor.ikea_of_sweden_inspelning_smart_plug_leistung
internal: true
- platform: homeassistant
id: washing_machine_power
entity_id: sensor.waschmaschine_leistung
internal: true
- platform: homeassistant
id: arcade_power
entity_id: sensor.arcade_automat_leistung
internal: true
- platform: homeassistant
id: dishwasher_power
entity_id: sensor.spulmaschine_leistung
internal: true
- platform: homeassistant
id: microwave_power
entity_id: sensor.waschetrockner_leistung
internal: true
- platform: wireguard
latest_handshake:
name: 'WireGuard Latest Handshake'
script:
- id: show_previous_page
then:
- lambda: id(page_index) = (id(page_index) + 3 - 1) % 3;
- component.update: tft
- id: toggle_page_mode
then:
- lambda: |-
if (id(page_index) == 0) {
id(page_one_gauge_view) = !id(page_one_gauge_view);
} else if (id(page_index) == 1) {
id(device_usage_view) = (id(device_usage_view) + 1) % 2;
} else {
id(clock_digital_view) = !id(clock_digital_view);
}
- component.update: tft
- id: show_next_page
then:
- lambda: id(page_index) = (id(page_index) + 1) % 3;
- component.update: tft
button:
- platform: template
name: "Zurück"
icon: mdi:arrow-left
on_press:
- script.execute: show_previous_page
- platform: template
name: "Modus"
icon: mdi:view-dashboard-outline
on_press:
- script.execute: toggle_page_mode
- platform: template
name: "Weiter"
icon: mdi:arrow-right
on_press:
- script.execute: show_next_page
binary_sensor:
- platform: wireguard
status:
name: 'WireGuard Status'
- platform: wireguard
enabled:
name: 'WireGuard Enabled'
# M5Stack Core button B (middle) switches the current page's view.
- platform: gpio
pin:
number: GPIO38
mode: INPUT
inverted: true
id: button_middle
on_press:
- script.execute: toggle_page_mode
# M5Stack Core button A (left). GPIO39 is input-only and has an external pull-up.
- platform: gpio
pin:
number: GPIO39
mode: INPUT
inverted: true
id: button_left
on_press:
- script.execute: show_previous_page
# M5Stack Core button C (right). GPIO37 is input-only and has an external pull-up.
- platform: gpio
pin:
number: GPIO37
mode: INPUT
inverted: true
id: button_right
on_press:
- script.execute: show_next_page
text_sensor:
- platform: wireguard
address:
name: 'WireGuard Address'
# M5CORE is the mipi_spi preset for the M5Stack Core's integrated display.
display:
- platform: mipi_spi
id: tft
model: M5CORE
cs_pin: GPIO14
dc_pin: GPIO27
reset_pin: GPIO33
invert_colors: true
update_interval: 1s
lambda: |-
it.fill(Color::BLACK);
if (id(sntp_time).now().is_valid()) {
it.strftime(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT,
"%H:%M", id(sntp_time).now());
} else {
it.printf(234, 10, id(font_small), Color::WHITE, TextAlign::TOP_RIGHT, "--:--");
}
// Native API connectivity; Home Assistant is normally the connected client.
const bool home_assistant_online = id(api_server).is_connected();
const Color home_assistant_color = home_assistant_online ? Color(64, 255, 64) : Color(255, 80, 80);
it.printf(260, 8, id(font_icon), home_assistant_color, TextAlign::TOP_RIGHT, "\U000F07D0");
// Green means the WireGuard peer is online; red means it is offline.
const bool wireguard_online = id(energymonitor_wireguard).is_peer_up();
const Color wireguard_color = wireguard_online ? Color(64, 255, 64) : Color(255, 80, 80);
it.printf(286, 8, id(font_icon), wireguard_color, TextAlign::TOP_RIGHT, "\U000F0306");
// Render the requested MDI Wi-Fi strength glyph in green or red when disconnected.
const bool wifi_online = id(wifi_connected);
const Color wifi_color = wifi_online ? Color(64, 255, 64) : Color(255, 80, 80);
const char *wifi_icon = "\U000F092D"; // mdi:wifi-strength-off
if (wifi_online) {
if (id(wifisignal).has_state()) {
const float rssi = id(wifisignal).state;
wifi_icon = rssi >= -55 ? "\U000F0928" : rssi >= -67 ? "\U000F0925"
: rssi >= -75 ? "\U000F0922" : "\U000F091F";
} else {
wifi_icon = "\U000F091F";
}
}
it.printf(312, 8, id(font_icon), wifi_color, TextAlign::TOP_RIGHT, "%s", wifi_icon);
if (id(page_index) == 0 && !id(page_one_gauge_view)) {
it.printf(12, 12, id(font_small), Color::WHITE, "Netzleistung");
if (id(grid_power).has_state()) {
const Color grid_power_color = id(grid_power).state >= 0
? Color(143, 190, 223) // #8FBEDF: positive grid power
: Color(150, 110, 217); // #966ED9: negative grid power
it.printf(308, 32, id(font_value), grid_power_color, TextAlign::TOP_RIGHT,
"%+.0f W", id(grid_power).state);
} else {
it.printf(308, 42, id(font_value), Color::WHITE, TextAlign::TOP_RIGHT,
"-- W");
}
if (id(grid_import_energy_daily).has_state()) {
it.printf(12, 96, id(font_small), Color::WHITE, "Bezug: %.2f kWh",
id(grid_import_energy_daily).state);
} else {
it.printf(12, 96, id(font_small), Color::WHITE, "Bezug: -- kWh");
}
if (id(grid_export_energy_daily).has_state()) {
it.printf(12, 116, id(font_small), Color::WHITE, "Einspeisung: %.2f kWh",
id(grid_export_energy_daily).state);
} else {
it.printf(12, 116, id(font_small), Color::WHITE, "Einspeisung: -- kWh");
}
it.printf(12, 138, id(font_small), Color::WHITE, "Balkonkraftwerk");
// Daily solar energy is aligned to the left of the current solar-power reading.
if (id(solar_energy_daily).has_state()) {
it.printf(12, 180, id(font_small), Color(255, 170, 40), "Solar: %.2f kWh",
id(solar_energy_daily).state);
} else {
it.printf(12, 180, id(font_small), Color(255, 170, 40), "Solar: -- kWh");
}
if (id(balcony_solar_power).has_state()) {
it.printf(308, 158, id(font_value), Color(255, 170, 40), TextAlign::TOP_RIGHT,
"%.0f W", id(balcony_solar_power).state);
} else {
it.printf(308, 168, id(font_value), Color(255, 170, 40), TextAlign::TOP_RIGHT,
"-- W");
}
} else if (id(page_index) == 0) {
// One shared gauge with two parallel curved bars: grid on the outside, solar inside.
const Color gauge_background = Color(42, 42, 42);
const int gauge_center_x = 160;
const int gauge_center_y = 188;
// The outer band represents the absolute grid-power value with its signed color.
float grid_power_value = id(grid_power).has_state() ? id(grid_power).state : 0.0f;
float grid_power_magnitude = grid_power_value < 0.0f ? -grid_power_value : grid_power_value;
int grid_gauge_percent = static_cast<int>(grid_power_magnitude * 100.0f / ${grid_power_gauge_max_w});
if (grid_gauge_percent > 100) grid_gauge_percent = 100;
const Color grid_gauge_color = grid_power_value >= 0.0f
? Color(143, 190, 223) // #8FBEDF
: Color(150, 110, 217); // #966ED9
it.filled_gauge(gauge_center_x, gauge_center_y, 140, 122, 100, gauge_background);
it.filled_gauge(gauge_center_x, gauge_center_y, 140, 122, grid_gauge_percent, grid_gauge_color);
// The inner band is solar power, normalized against the 800 W inverter maximum.
float solar_power_value = id(balcony_solar_power).has_state() ? id(balcony_solar_power).state : 0.0f;
int solar_gauge_percent = static_cast<int>(solar_power_value * 100.0f / ${balcony_solar_gauge_max_w});
if (solar_gauge_percent < 0) solar_gauge_percent = 0;
if (solar_gauge_percent > 100) solar_gauge_percent = 100;
const Color solar_gauge_color = Color(255, 170, 40); // #FFAA28
it.filled_gauge(gauge_center_x, gauge_center_y, 116, 98, 100, gauge_background);
it.filled_gauge(gauge_center_x, gauge_center_y, 116, 98, solar_gauge_percent, solar_gauge_color);
it.printf(gauge_center_x, 102, id(font_small), Color::WHITE, TextAlign::TOP_CENTER,
"Netzleistung");
if (id(grid_power).has_state()) {
it.printf(gauge_center_x, 120, id(font_title), grid_gauge_color, TextAlign::TOP_CENTER,
"%+.0f W", grid_power_value);
} else {
it.printf(gauge_center_x, 120, id(font_title), Color::WHITE, TextAlign::TOP_CENTER, "-- W");
}
it.printf(gauge_center_x, 151, id(font_small), Color::WHITE, TextAlign::TOP_CENTER,
"Balkonkraftwerk");
if (id(balcony_solar_power).has_state()) {
it.printf(gauge_center_x, 169, id(font_title), solar_gauge_color, TextAlign::TOP_CENTER,
"%.0f W", solar_power_value);
} else {
it.printf(gauge_center_x, 169, id(font_title), solar_gauge_color, TextAlign::TOP_CENTER, "-- W");
}
} else if (id(page_index) == 1) {
// Page 2 lists nine consumers at once in two columns; button B changes group.
const int device_count = 18;
const int usage_group = id(device_usage_view);
const int page_start = usage_group * 9;
const char *device_names[device_count] = {
"Raumduft", "Keller", "Anrichte", "Musik", "Bett", "HK Schlafzimmer",
"Deko", "Schreibtisch", "Serverraum", "HK Wohnzimmer", "Spieleschrank",
"Kühlschrank", "Kaffeemaschine", "Wäschetrockner", "Waschmaschine", "Arcade",
"Spülmaschine", "Mikrowelle"};
float device_values[device_count] = {
id(hallway_fragrance_power).state, id(cellar_power).state, id(sideboard_power).state,
id(kitchen_music_power).state, id(bedroom_bed_power).state, id(bedroom_cinema_power).state,
id(desk_decoration_power).state, id(desk_power).state, id(server_room_power).state,
id(living_room_cinema_power).state, id(games_cabinet_power).state, id(refrigerator_power).state,
id(coffee_machine_power).state, id(dryer_power).state, id(washing_machine_power).state,
id(arcade_power).state, id(dishwasher_power).state, id(microwave_power).state};
bool device_has_state[device_count] = {
id(hallway_fragrance_power).has_state(), id(cellar_power).has_state(), id(sideboard_power).has_state(),
id(kitchen_music_power).has_state(), id(bedroom_bed_power).has_state(), id(bedroom_cinema_power).has_state(),
id(desk_decoration_power).has_state(), id(desk_power).has_state(), id(server_room_power).has_state(),
id(living_room_cinema_power).has_state(), id(games_cabinet_power).has_state(), id(refrigerator_power).has_state(),
id(coffee_machine_power).has_state(), id(dryer_power).has_state(), id(washing_machine_power).has_state(),
id(arcade_power).has_state(), id(dishwasher_power).has_state(), id(microwave_power).has_state()};
Color device_colors[device_count] = {
Color(255, 170, 40), Color(69, 189, 255), Color(170, 116, 217), Color(93, 207, 140),
Color(238, 112, 112), Color(107, 139, 255), Color(255, 130, 180), Color(122, 204, 174),
Color(240, 195, 90), Color(151, 120, 220), Color(91, 189, 193), Color(212, 132, 82),
Color(143, 190, 223), Color(233, 106, 142), Color(132, 205, 92), Color(255, 181, 80),
Color(111, 167, 229), Color(190, 137, 226)};
// The title uses the free area to the left of the status indicators.
it.printf(12, 10, id(font_device), Color::WHITE, "Geräteverbrauch");
for (int display_index = 0; display_index < 9; display_index++) {
const int index = page_start + display_index;
const int column = display_index % 2;
const int row = display_index / 2;
const int x = column == 0 ? 12 : 166;
const int y = 43 + row * 25;
if (device_has_state[index]) {
it.printf(x, y, id(font_device), device_colors[index], "%s: %.0f W",
device_names[index], device_values[index]);
} else {
it.printf(x, y, id(font_device), device_colors[index], "%s: -- W", device_names[index]);
}
}
// The stacked bar always represents all 18 consumer devices, not only this view's rows.
const int bar_x = 12;
const int bar_y = 180;
const int bar_width = 296;
const int bar_height = 18;
float usage_sum = 0.0f;
int last_active = -1;
for (int index = 0; index < device_count; index++) {
if (device_has_state[index] && device_values[index] > 0.0f) {
usage_sum += device_values[index];
last_active = index;
}
}
it.filled_rectangle(bar_x, bar_y, bar_width, bar_height, Color(42, 42, 42));
if (usage_sum > 0.0f) {
int cursor_x = bar_x;
for (int index = 0; index < device_count; index++) {
if (!device_has_state[index] || device_values[index] <= 0.0f) continue;
const int segment_width = index == last_active
? bar_x + bar_width - cursor_x
: static_cast<int>(device_values[index] * bar_width / usage_sum);
if (segment_width > 0) {
it.filled_rectangle(cursor_x, bar_y, segment_width, bar_height, device_colors[index]);
cursor_x += segment_width;
}
}
}
}
if (id(page_index) == 2) {
const auto now = id(sntp_time).now();
const Color accent(143, 190, 223);
const Color gold(255, 170, 40);
const Color muted(55, 65, 80);
it.print(12, 10, id(font_device), accent, "Uhr · Berlin");
if (!now.is_valid()) {
it.print(160, 100, id(font_title), accent, TextAlign::TOP_CENTER, "--:--:--");
it.print(160, 190, id(font_small), Color::WHITE, TextAlign::TOP_CENTER,
"Warte auf Zeitsynchronisation");
} else {
if (!id(clock_digital_view)) {
const int cx = 160, cy = 111, radius = 74;
const float tau = 6.28318530718f;
it.filled_circle(cx, cy, radius, Color(12, 18, 28));
it.circle(cx, cy, radius, accent);
it.circle(cx, cy, radius - 3, muted);
for (int tick = 0; tick < 60; tick++) {
const float angle = tick * tau / 60.0f;
const int inner = tick % 5 == 0 ? radius - 13 : radius - 8;
it.line(cx + lroundf(sinf(angle) * inner), cy - lroundf(cosf(angle) * inner),
cx + lroundf(sinf(angle) * (radius - 5)),
cy - lroundf(cosf(angle) * (radius - 5)),
tick % 5 == 0 ? accent : muted);
}
it.print(cx, cy - 49, id(font_device), Color::WHITE, TextAlign::CENTER, "12");
it.print(cx + 50, cy, id(font_device), Color::WHITE, TextAlign::CENTER, "3");
it.print(cx, cy + 49, id(font_device), Color::WHITE, TextAlign::CENTER, "6");
it.print(cx - 50, cy, id(font_device), Color::WHITE, TextAlign::CENTER, "9");
// Round-ended hands; minutes and hours advance with the seconds.
auto hand = [&](float turns, int length, int thickness, Color color) {
const float angle = turns * tau;
for (int r = 0; r <= length; r++) {
it.filled_circle(cx + lroundf(sinf(angle) * r),
cy - lroundf(cosf(angle) * r), thickness, color);
}
};
hand((now.hour % 12 + now.minute / 60.0f + now.second / 3600.0f) / 12.0f,
34, 3, Color::WHITE);
hand((now.minute + now.second / 60.0f) / 60.0f, 51, 2, accent);
const float second_angle = now.second * tau / 60.0f;
it.line(cx - lroundf(sinf(second_angle) * 12), cy + lroundf(cosf(second_angle) * 12),
cx + lroundf(sinf(second_angle) * 60), cy - lroundf(cosf(second_angle) * 60), gold);
it.filled_circle(cx, cy, 4, gold);
it.filled_circle(cx, cy, 1, Color::BLACK);
} else {
// Draw seven-segment digits directly, avoiding an extra font dependency.
const uint8_t masks[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66,
0x6D, 0x7D, 0x07, 0x7F, 0x6F};
const int digits[6] = {now.hour / 10, now.hour % 10, now.minute / 10,
now.minute % 10, now.second / 10, now.second % 10};
const int positions[6] = {17, 61, 121, 165, 225, 269};
const int y = 77;
for (int digit = 0; digit < 6; digit++) {
const int x = positions[digit];
const Color lit = digit < 4 ? accent : gold;
for (int segment = 0; segment < 7; segment++) {
const Color color = (masks[digits[digit]] & (1 << segment))
? lit : Color(20, 27, 36);
const bool horizontal = segment == 0 || segment == 3 || segment == 6;
const int sx = horizontal ? x + 6 : x + ((segment == 1 || segment == 2) ? 30 : 0);
const int sy = y + (segment == 0 ? 0 : segment == 3 ? 72 : segment == 6 ? 36
: (segment == 1 || segment == 5) ? 6 : 42);
// Taper each segment's ends for the classic LED clock shape.
for (int stripe = 0; stripe < 6; stripe++) {
const int inset = stripe < 3 ? 2 - stripe : stripe - 3;
if (horizontal)
it.line(sx + inset, sy + stripe, sx + 23 - inset, sy + stripe, color);
else
it.line(sx + stripe, sy + inset, sx + stripe, sy + 29 - inset, color);
}
}
}
for (int x : {109, 213}) {
it.filled_circle(x, y + 24, 3, accent);
it.filled_circle(x, y + 54, 3, accent);
}
it.line(40, 172, 280, 172, muted);
}
const char *weekdays[] = {"Sonntag", "Montag", "Dienstag", "Mittwoch",
"Donnerstag", "Freitag", "Samstag"};
it.printf(160, 190, id(font_small), Color::WHITE, TextAlign::TOP_CENTER,
"%s, %02d.%02d.%04d", weekdays[now.day_of_week - 1],
now.day_of_month, now.month, now.year);
}
}
// Labels correspond to the left (A) and right (C) hardware buttons.
it.printf(8, 239, id(font_small), Color::WHITE, TextAlign::BOTTOM_LEFT,
"< Zurück");
it.printf(312, 239, id(font_small), Color::WHITE, TextAlign::BOTTOM_RIGHT,
"Weiter >");
if (id(page_index) == 0) {
it.printf(160, 239, id(font_small), Color::WHITE, TextAlign::BOTTOM_CENTER,
"Ansicht · 1 / 3");
} else if (id(page_index) == 1) {
it.printf(160, 239, id(font_small), Color::WHITE, TextAlign::BOTTOM_CENTER,
"Geräte %d / 2", id(device_usage_view) + 1);
} else {
it.printf(160, 239, id(font_small), Color::WHITE, TextAlign::BOTTOM_CENTER,
"%s · 3 / 3", id(clock_digital_view) ? "Analog" : "Digital");
}
+7 -47
View File
@@ -1,10 +1,7 @@
# Device identity shared by ESPHome and Home Assistant.
substitutions: substitutions:
name: epaperframe name: epaperframe
friendly_name: "Info-Dashboard" friendly_name: "Info-Dashboard"
# Startup selects the default page only after Home Assistant has had time to
# provide the sensor states needed by its display lambda.
esphome: esphome:
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
@@ -21,7 +18,6 @@ esphome:
- display.page.show: calendar # temporary for power page dev - display.page.show: calendar # temporary for power page dev
- component.update: epaper - component.update: epaper
# ESP32 target and ESP-IDF build settings for the hardware revision in use.
esp32: esp32:
board: nodemcu-32s board: nodemcu-32s
framework: framework:
@@ -29,7 +25,6 @@ esp32:
advanced: advanced:
minimum_chip_revision: "3.0" minimum_chip_revision: "3.0"
# Network access is required for Home Assistant state delivery and OTA updates.
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk password: !secret voltage_legacy_psk
@@ -56,7 +51,7 @@ api:
# Include ArduinoJson support for the compact calendar event feed. # Include ArduinoJson support for the compact calendar event feed.
json: json:
# Prevent refreshes when Home Assistant republishes unchanged calendar data. # Avoid refreshing the panel when Home Assistant republishes unchanged calendar data.
globals: globals:
- id: last_rendered_calendar_entries - id: last_rendered_calendar_entries
type: std::string type: std::string
@@ -129,7 +124,6 @@ button:
- display.page.show_next: epaper - display.page.show_next: epaper
- component.update: epaper - component.update: epaper
# Numeric telemetry received from Home Assistant for the environment dashboard.
sensor: sensor:
# WiFi signal strength # WiFi signal strength
- platform: wifi_signal - platform: wifi_signal
@@ -207,7 +201,6 @@ sensor:
entity_id: sensor.radioaktive_strahlungsleistung entity_id: sensor.radioaktive_strahlungsleistung
id: radiation id: radiation
# Textual Home Assistant state, including the compact calendar payload and quote.
text_sensor: text_sensor:
- platform: homeassistant - platform: homeassistant
name: "Sun Rising ESP" name: "Sun Rising ESP"
@@ -236,8 +229,6 @@ text_sensor:
entity_id: sensor.epaper_kalenderdaten entity_id: sensor.epaper_kalenderdaten
attribute: entries attribute: entries
id: calendar_entries id: calendar_entries
# Refresh the e-paper only for changed agenda data while the calendar page
# is visible; Home Assistant may otherwise republish identical JSON.
on_value: on_value:
then: then:
- if: - if:
@@ -257,8 +248,6 @@ text_sensor:
# Time drives panel power maintenance, the environment refresh cadence, and the
# midnight redraw that advances the calendar and daily quote.
time: time:
- platform: homeassistant - platform: homeassistant
id: homeassistant_time id: homeassistant_time
@@ -272,8 +261,8 @@ time:
- output.turn_on: power_key - output.turn_on: power_key
- delay: 0.5s - delay: 0.5s
- output.turn_off: power_key - output.turn_off: power_key
# Environmental readings need their regular refresh. Calendar updates are # Refresh environmental readings every 10 minutes. The calendar page is
# instead triggered by changed event data while that page is active. # redrawn only when its event feed actually changes.
- seconds: 0 - seconds: 0
minutes: /10 minutes: /10
then: then:
@@ -285,16 +274,7 @@ time:
level: INFO level: INFO
format: "Timer based environment screen refresh" format: "Timer based environment screen refresh"
- component.update: epaper - component.update: epaper
- seconds: 10
minutes: 0
hours: 0
then:
- logger.log:
level: INFO
format: "Update screen on new day"
- component.update: epaper
# Visual assets used by both 1-bit e-paper pages.
# Font definitions # Font definitions
font: font:
- file: "fonts/Roboto-Medium.ttf" - file: "fonts/Roboto-Medium.ttf"
@@ -755,21 +735,17 @@ font:
"󰀦", # mdi-alert "󰀦", # mdi-alert
] ]
# Binary logo stored in firmware for rendering without network access.
image: image:
- platform: file - file: "epaperframe/C1024_logo_flat_bw.png"
file: "epaperframe/C1024_logo_flat_bw.png"
id: c1024_logo id: c1024_logo
type: binary type: binary
resize: 77x40 resize: 77x40
invert_alpha: true invert_alpha: True
# Shared SPI bus for the Waveshare e-paper panel.
spi: spi:
clk_pin: 23 clk_pin: 23
mosi_pin: 22 mosi_pin: 22
# The two pages draw directly onto the 640x384 1-bit Waveshare e-paper panel.
display: display:
- platform: waveshare_epaper - platform: waveshare_epaper
id: epaper id: epaper
@@ -781,11 +757,8 @@ display:
# full_update_every: 30 # not supported on this display # full_update_every: 30 # not supported on this display
update_interval: never update_interval: never
pages: pages:
# Environmental telemetry dashboard, refreshed on the 10-minute timer.
- id: environment - id: environment
lambda: |- lambda: |-
// Snapshot all Home Assistant values once per render so each panel uses
// a consistent set of readings throughout this e-paper refresh.
/* Outdoor */ /* Outdoor */
float outdoor_temp = id(temp_outdoor).state; float outdoor_temp = id(temp_outdoor).state;
int outdoor_humid = int(id(humid_outdoor).state); int outdoor_humid = int(id(humid_outdoor).state);
@@ -809,11 +782,10 @@ display:
float childrensroom_co2 = id(co2_childrensroom).state; float childrensroom_co2 = id(co2_childrensroom).state;
int childrensroom_pm25 = int(id(pm25_childrensroom).state); int childrensroom_pm25 = int(id(pm25_childrensroom).state);
// Reuse one room widget layout by moving its origin across the two-column grid.
int offsetX = 0; int offsetX = 0;
int offsetY = 0; int offsetY = 0;
/* OUTSIDE: logo, headline, and outdoor sensor summary */ /* OUTSIDE */
it.print(10, 10, id(sensor_unit), "Umwelt"); it.print(10, 10, id(sensor_unit), "Umwelt");
/* /*
Draw the outline of a rectangle with the top left at [86,21], Draw the outline of a rectangle with the top left at [86,21],
@@ -1157,11 +1129,8 @@ display:
} }
} }
# Calendar agenda, month grid, and daily quote; redraws when event JSON changes.
- id: calendar - id: calendar
lambda: |- lambda: |-
// Use Home Assistant time for all date labels, month calculations, and
// the footer, avoiding locale-dependent formatting on the ESP32.
auto now = id(homeassistant_time).now(); auto now = id(homeassistant_time).now();
const char *months[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", const char *months[] = {"Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember"}; "Juli", "August", "September", "Oktober", "November", "Dezember"};
@@ -1171,8 +1140,6 @@ display:
const int month = now.month; const int month = now.month;
const int today = now.day_of_month; const int today = now.day_of_month;
// Date helpers build a Monday-first month grid and ISO-8601 week numbers
// without relying on platform-specific C library time functions.
auto days_in_month = [](int calendar_year, int calendar_month) { auto days_in_month = [](int calendar_year, int calendar_month) {
const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (calendar_month == 2) { if (calendar_month == 2) {
@@ -1212,8 +1179,6 @@ display:
it.line(10, 55, 355, 55); it.line(10, 55, 355, 55);
it.line(365, 10, 365, 352); it.line(365, 10, 365, 352);
// Parse the compact JSON attribute produced by Home Assistant. The empty
// and error states below ensure a useful screen while data is unavailable.
JsonDocument calendar_doc; JsonDocument calendar_doc;
const DeserializationError calendar_error = deserializeJson(calendar_doc, id(calendar_entries).state.c_str()); const DeserializationError calendar_error = deserializeJson(calendar_doc, id(calendar_entries).state.c_str());
JsonArray calendar_days = calendar_doc.as<JsonArray>(); JsonArray calendar_days = calendar_doc.as<JsonArray>();
@@ -1235,8 +1200,6 @@ display:
break; break;
} }
// A date rail occupies the left edge; event rows start alongside it
// and stop before the footer rather than overflowing the panel.
const int group_y = agenda_y; const int group_y = agenda_y;
int event_y = group_y; int event_y = group_y;
const int day_number = day["day"] | 0; const int day_number = day["day"] | 0;
@@ -1278,8 +1241,6 @@ display:
/* RIGHT TOP: month view, Monday-first with ISO week numbers */ /* RIGHT TOP: month view, Monday-first with ISO week numbers */
// Draw only the five or six rows this month actually needs so no orphan
// week number is rendered beneath shorter months.
char month_title[24]; char month_title[24];
snprintf(month_title, sizeof(month_title), "%s %d", months[month - 1], year); snprintf(month_title, sizeof(month_title), "%s %d", months[month - 1], year);
it.printf(502, 18, id(sensor_unit), TextAlign::TOP_CENTER, "%s", month_title); it.printf(502, 18, id(sensor_unit), TextAlign::TOP_CENTER, "%s", month_title);
@@ -1328,7 +1289,6 @@ display:
} }
/* RIGHT BOTTOM: daily quote selected by Home Assistant */ /* RIGHT BOTTOM: daily quote selected by Home Assistant */
// Wrap on word boundaries into the fixed four-line, inverted quote panel.
it.filled_rectangle(375, 220, 255, 130, COLOR_ON); it.filled_rectangle(375, 220, 255, 130, COLOR_ON);
std::string quote = "Zitat wird geladen."; std::string quote = "Zitat wird geladen.";
if (id(demotivational_quote).has_state() && !id(demotivational_quote).state.empty()) { if (id(demotivational_quote).has_state() && !id(demotivational_quote).state.empty()) {
@@ -1350,7 +1310,7 @@ display:
while (quote_start < quote.length() && quote[quote_start] == ' ') quote_start++; while (quote_start < quote.length() && quote[quote_start] == ' ') quote_start++;
} }
/* FOOTER: Footer is shared visual status: render timestamp plus a Wi-Fi-strength glyph. */ /* FOOTER */
it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT, it.strftime(614, 380, id(footer_font), TextAlign::BASELINE_RIGHT,
"Aktualisiert um %d.%m.%Y %H:%M", now); "Aktualisiert um %d.%m.%Y %H:%M", now);
-2
View File
@@ -31,5 +31,3 @@ ota:
password: !secret ota password: !secret ota
http_request: http_request:
captive_portal:
-2
View File
@@ -31,5 +31,3 @@ ota:
password: !secret ota password: !secret ota
http_request: http_request:
captive_portal:
+1 -7
View File
@@ -27,16 +27,10 @@ esphome:
includes: includes:
- lab-ble-proxy.h - lab-ble-proxy.h
on_boot: on_boot:
- priority: 850 priority: 850
then: then:
- lambda: |- - lambda: |-
owon_b35t::core2_axp192_init(id(core2_i2c)); owon_b35t::core2_axp192_init(id(core2_i2c));
# Start the normal dimming/off cycle after a cold boot as well. The
# light component is initialized by this priority, while BLE callbacks
# and touch events can still restart the script through wake_backlight.
- priority: 600
then:
- script.execute: backlight_idle
project: project:
name: "custom.lab-ble-proxy-m5stack-core2" name: "custom.lab-ble-proxy-m5stack-core2"
version: "1.0" version: "1.0"
+43 -81
View File
@@ -3,20 +3,18 @@
substitutions: substitutions:
name: m5stack-atom-echo name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo friendly_name: M5Stack Atom Echo
micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported
esphome: esphome:
name: ${name} name: ${name}
name_add_mac_suffix: false name_add_mac_suffix: False
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
min_version: 2025.5.0 min_version: 2025.2.0
esp32: esp32:
board: m5stack-atom board: m5stack-atom
cpu_frequency: 240MHz
framework: framework:
type: esp-idf type: esp-idf
advanced:
sram1_as_iram: true
# Enable Home Assistant API # Enable Home Assistant API
api: api:
@@ -65,17 +63,14 @@ microphone:
i2s_din_pin: GPIO23 i2s_din_pin: GPIO23
adc_type: external adc_type: external
pdm: true pdm: true
sample_rate: 16000
correct_dc_offset: true
speaker: speaker:
- platform: i2s_audio - platform: i2s_audio
id: echo_speaker id: echo_speaker
i2s_dout_pin: GPIO22 i2s_dout_pin: GPIO22
dac_type: external dac_type: external
bits_per_sample: 16bit bits_per_sample: 32bit
sample_rate: 16000 channel: right
channel: stereo # The Echo has poor playback audio quality when using mon audio
buffer_duration: 60ms buffer_duration: 60ms
media_player: media_player:
@@ -85,6 +80,7 @@ media_player:
announcement_pipeline: announcement_pipeline:
speaker: echo_speaker speaker: echo_speaker
format: WAV format: WAV
codec_support_enabled: false
buffer_size: 6000 buffer_size: 6000
volume_min: 0.4 volume_min: 0.4
files: files:
@@ -95,7 +91,14 @@ media_player:
condition: condition:
- microphone.is_capturing: - microphone.is_capturing:
then: then:
- script.execute: stop_wake_word - if:
condition:
lambda: return id(wake_word_engine_location).state == "On device";
then:
- micro_wake_word.stop:
else:
- voice_assistant.stop:
- script.execute: reset_led
- light.turn_on: - light.turn_on:
id: led id: led
blue: 100% blue: 100%
@@ -105,18 +108,14 @@ media_player:
effect: none effect: none
on_idle: on_idle:
- script.execute: start_wake_word - script.execute: start_wake_word
- script.execute: reset_led
voice_assistant: voice_assistant:
id: va id: va
micro_wake_word:
microphone:
microphone: echo_microphone microphone: echo_microphone
channels: 0
gain_factor: 4
media_player: echo_media_player media_player: echo_media_player
noise_suppression_level: 2 noise_suppression_level: 2
auto_gain: 31dBFS auto_gain: 31dBFS
volume_multiplier: 2.0
on_listening: on_listening:
- light.turn_on: - light.turn_on:
id: led id: led
@@ -140,26 +139,8 @@ voice_assistant:
brightness: 100% brightness: 100%
effect: none effect: none
on_end: on_end:
# Handle the "nevermind" case where there is no announcement - delay: 100ms
- wait_until: - script.execute: start_wake_word
condition:
- media_player.is_announcing:
timeout: 0.5s
# Restart only mWW if enabled; streaming wake words automatically restart
- if:
condition:
- lambda: |-
return id(wake_word_engine_location).current_option() == "On device";
then:
- wait_until:
- and:
- not:
voice_assistant.is_running:
- not:
speaker.is_playing:
- lambda: id(va).set_use_wake_word(false);
- micro_wake_word.start:
- script.execute: reset_led
on_error: on_error:
- light.turn_on: - light.turn_on:
id: led id: led
@@ -174,9 +155,11 @@ voice_assistant:
- delay: 2s # Give the api server time to settle - delay: 2s # Give the api server time to settle
- script.execute: start_wake_word - script.execute: start_wake_word
on_client_disconnected: on_client_disconnected:
- script.execute: stop_wake_word - voice_assistant.stop:
- micro_wake_word.stop:
on_timer_finished: on_timer_finished:
- script.execute: stop_wake_word - voice_assistant.stop:
- micro_wake_word.stop:
- wait_until: - wait_until:
not: not:
microphone.is_capturing: microphone.is_capturing:
@@ -252,8 +235,7 @@ script:
then: then:
- if: - if:
condition: condition:
- lambda: |- - lambda: return id(wake_word_engine_location).state == "On device";
return id(wake_word_engine_location).current_option() == "On device";
- switch.is_on: use_listen_light - switch.is_on: use_listen_light
then: then:
- light.turn_on: - light.turn_on:
@@ -266,8 +248,7 @@ script:
else: else:
- if: - if:
condition: condition:
- lambda: |- - lambda: return id(wake_word_engine_location).state != "On device";
return id(wake_word_engine_location).current_option() == "On device";
- switch.is_on: use_listen_light - switch.is_on: use_listen_light
then: then:
- light.turn_on: - light.turn_on:
@@ -281,41 +262,27 @@ script:
- light.turn_off: led - light.turn_off: led
- id: start_wake_word - id: start_wake_word
then: then:
- if: - wait_until:
condition:
and: and:
- not: - media_player.is_idle:
- voice_assistant.is_running: - speaker.is_stopped:
- lambda: |-
return id(wake_word_engine_location).current_option() == "On device";
then:
- lambda: id(va).set_use_wake_word(false);
- micro_wake_word.start:
- if: - if:
condition: condition:
and: lambda: return id(wake_word_engine_location).state == "On device";
- not:
- voice_assistant.is_running:
- lambda: |-
return id(wake_word_engine_location).current_option() == "In Home Assistant";
then:
- lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous:
- id: stop_wake_word
then:
- if:
condition:
lambda: |-
return id(wake_word_engine_location).current_option() == "In Home Assistant";
then:
- lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop:
- if:
condition:
lambda: |-
return id(wake_word_engine_location).current_option() == "On device";
then: then:
- voice_assistant.stop
- micro_wake_word.stop: - micro_wake_word.stop:
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- micro_wake_word.start:
else:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
- voice_assistant.start_continuous:
switch: switch:
- platform: template - platform: template
@@ -375,7 +342,7 @@ select:
condition: condition:
lambda: return x == "In Home Assistant"; lambda: return x == "In Home Assistant";
then: then:
- micro_wake_word.stop: - micro_wake_word.stop
- delay: 500ms - delay: 500ms
- lambda: id(va).set_use_wake_word(true); - lambda: id(va).set_use_wake_word(true);
- voice_assistant.start_continuous: - voice_assistant.start_continuous:
@@ -384,9 +351,9 @@ select:
lambda: return x == "On device"; lambda: return x == "On device";
then: then:
- lambda: id(va).set_use_wake_word(false); - lambda: id(va).set_use_wake_word(false);
- voice_assistant.stop: - voice_assistant.stop
- delay: 500ms - delay: 500ms
- micro_wake_word.start: - micro_wake_word.start
micro_wake_word: micro_wake_word:
on_wake_word_detected: on_wake_word_detected:
@@ -394,9 +361,4 @@ micro_wake_word:
wake_word: !lambda return wake_word; wake_word: !lambda return wake_word;
vad: vad:
models: models:
- model: okay_nabu - model: ${micro_wake_word_model}
id: okay_nabu
- model: hey_mycroft
id: hey_mycroft
- model: hey_jarvis
id: hey_jarvis
+10 -21
View File
@@ -1,5 +1,3 @@
# Source: https://github.com/wildekek/rdtech-esphome
substitutions: substitutions:
name: "riden-labornetzteil-18a" name: "riden-labornetzteil-18a"
friendly_name: "Riden Labornetzteil 18A" friendly_name: "Riden Labornetzteil 18A"
@@ -18,8 +16,6 @@ substitutions:
RD6006_current_maximum: "6" RD6006_current_maximum: "6"
RD6006_current_accuracy: "3" RD6006_current_accuracy: "3"
RD6006_current_multiplier: "0.001" RD6006_current_multiplier: "0.001"
RD6006_power_accuracy: "2"
RD6006_power_multiplier: "0.01"
RD6006P_voltage_maximum: "60" RD6006P_voltage_maximum: "60"
RD6006P_voltage_accuracy: "3" RD6006P_voltage_accuracy: "3"
@@ -27,8 +23,6 @@ substitutions:
RD6006P_current_maximum: "6" RD6006P_current_maximum: "6"
RD6006P_current_accuracy: "4" RD6006P_current_accuracy: "4"
RD6006P_current_multiplier: "0.0001" RD6006P_current_multiplier: "0.0001"
RD6006P_power_accuracy: "3"
RD6006P_power_multiplier: "0.001"
RD6012_voltage_maximum: "60" RD6012_voltage_maximum: "60"
RD6012_voltage_accuracy: "2" RD6012_voltage_accuracy: "2"
@@ -36,8 +30,6 @@ substitutions:
RD6012_current_maximum: "12" RD6012_current_maximum: "12"
RD6012_current_accuracy: "2" RD6012_current_accuracy: "2"
RD6012_current_multiplier: "0.01" RD6012_current_multiplier: "0.01"
RD6012_power_accuracy: "2"
RD6012_power_multiplier: "0.01"
RD6018_voltage_maximum: "60" RD6018_voltage_maximum: "60"
RD6018_voltage_accuracy: "2" RD6018_voltage_accuracy: "2"
@@ -45,8 +37,6 @@ substitutions:
RD6018_current_maximum: "18" RD6018_current_maximum: "18"
RD6018_current_accuracy: "2" RD6018_current_accuracy: "2"
RD6018_current_multiplier: "0.01" RD6018_current_multiplier: "0.01"
RD6018_power_accuracy: "2"
RD6018_power_multiplier: "0.01"
esphome: esphome:
name: $device_name name: $device_name
@@ -55,7 +45,7 @@ esphome:
name_add_mac_suffix: false name_add_mac_suffix: false
project: project:
name: "wildekek.rd6006-controller" name: "wildekek.rd6006-controller"
version: "1.5" version: "1.4.1"
esp8266: esp8266:
board: esp12e board: esp12e
@@ -66,7 +56,7 @@ network:
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk password: !secret voltage_legacy_psk
use_address: riden-labornetzteil-18a.home #use_address: riden-labornetzteil-18a.home
power_save_mode: high power_save_mode: high
fast_connect: on fast_connect: on
min_auth_mode: WPA2 min_auth_mode: WPA2
@@ -162,9 +152,7 @@ sensor:
on_value: on_value:
then: then:
- lambda: |- - lambda: |-
id(model_name).publish_state( id(model_name).publish_state(value_accuracy_to_string(x, 0));
std::to_string(static_cast<uint16_t>(x))
);
- platform: modbus_controller - platform: modbus_controller
name: "Serial Number" name: "Serial Number"
@@ -225,9 +213,9 @@ sensor:
unit_of_measurement: "W" unit_of_measurement: "W"
register_type: holding register_type: holding
value_type: U_DWORD value_type: U_DWORD
accuracy_decimals: ${${model}_power_accuracy} accuracy_decimals: 2
filters: filters:
- multiply: ${${model}_power_multiplier} - multiply: 0.01
- platform: modbus_controller - platform: modbus_controller
modbus_controller_id: powersupply modbus_controller_id: powersupply
@@ -238,9 +226,9 @@ sensor:
unit_of_measurement: "V" unit_of_measurement: "V"
register_type: holding register_type: holding
value_type: U_WORD value_type: U_WORD
accuracy_decimals: 2 accuracy_decimals: ${${model}_voltage_accuracy}
filters: filters:
- multiply: 0.01 - multiply: ${${model}_voltage_multiplier}
- platform: modbus_controller - platform: modbus_controller
modbus_controller_id: powersupply modbus_controller_id: powersupply
@@ -278,9 +266,9 @@ sensor:
unit_of_measurement: "V" unit_of_measurement: "V"
register_type: holding register_type: holding
value_type: U_WORD value_type: U_WORD
accuracy_decimals: 2 accuracy_decimals: ${${model}_voltage_accuracy}
filters: filters:
- multiply: 0.01 - multiply: ${${model}_voltage_multiplier}
- platform: modbus_controller - platform: modbus_controller
name: "Temperature" name: "Temperature"
@@ -449,6 +437,7 @@ number:
lambda: !lambda return x * ${${model}_voltage_multiplier}; lambda: !lambda return x * ${${model}_voltage_multiplier};
write_lambda: !lambda return x * (1/${${model}_voltage_multiplier}); write_lambda: !lambda return x * (1/${${model}_voltage_multiplier});
- platform: modbus_controller - platform: modbus_controller
modbus_controller_id: powersupply modbus_controller_id: powersupply
name: "Over Current Protection" name: "Over Current Protection"
+9 -21
View File
@@ -1,5 +1,3 @@
# Source: https://github.com/wildekek/rdtech-esphome
substitutions: substitutions:
name: "riden-labornetzteil-6a" name: "riden-labornetzteil-6a"
friendly_name: "Riden Labornetzteil 6A" friendly_name: "Riden Labornetzteil 6A"
@@ -18,8 +16,6 @@ substitutions:
RD6006_current_maximum: "6" RD6006_current_maximum: "6"
RD6006_current_accuracy: "3" RD6006_current_accuracy: "3"
RD6006_current_multiplier: "0.001" RD6006_current_multiplier: "0.001"
RD6006_power_accuracy: "2"
RD6006_power_multiplier: "0.01"
RD6006P_voltage_maximum: "60" RD6006P_voltage_maximum: "60"
RD6006P_voltage_accuracy: "3" RD6006P_voltage_accuracy: "3"
@@ -27,8 +23,6 @@ substitutions:
RD6006P_current_maximum: "6" RD6006P_current_maximum: "6"
RD6006P_current_accuracy: "4" RD6006P_current_accuracy: "4"
RD6006P_current_multiplier: "0.0001" RD6006P_current_multiplier: "0.0001"
RD6006P_power_accuracy: "3"
RD6006P_power_multiplier: "0.001"
RD6012_voltage_maximum: "60" RD6012_voltage_maximum: "60"
RD6012_voltage_accuracy: "2" RD6012_voltage_accuracy: "2"
@@ -36,8 +30,6 @@ substitutions:
RD6012_current_maximum: "12" RD6012_current_maximum: "12"
RD6012_current_accuracy: "2" RD6012_current_accuracy: "2"
RD6012_current_multiplier: "0.01" RD6012_current_multiplier: "0.01"
RD6012_power_accuracy: "2"
RD6012_power_multiplier: "0.01"
RD6018_voltage_maximum: "60" RD6018_voltage_maximum: "60"
RD6018_voltage_accuracy: "2" RD6018_voltage_accuracy: "2"
@@ -45,8 +37,6 @@ substitutions:
RD6018_current_maximum: "18" RD6018_current_maximum: "18"
RD6018_current_accuracy: "2" RD6018_current_accuracy: "2"
RD6018_current_multiplier: "0.01" RD6018_current_multiplier: "0.01"
RD6018_power_accuracy: "2"
RD6018_power_multiplier: "0.01"
esphome: esphome:
name: $device_name name: $device_name
@@ -55,7 +45,7 @@ esphome:
name_add_mac_suffix: false name_add_mac_suffix: false
project: project:
name: "wildekek.rd6006-controller" name: "wildekek.rd6006-controller"
version: "1.5" version: "1.4.1"
esp8266: esp8266:
board: esp12e board: esp12e
@@ -66,7 +56,7 @@ network:
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk password: !secret voltage_legacy_psk
use_address: riden-labornetzteil-6a.home #use_address: riden-labornetzteil-6a.home
power_save_mode: high power_save_mode: high
fast_connect: on fast_connect: on
min_auth_mode: WPA2 min_auth_mode: WPA2
@@ -162,9 +152,7 @@ sensor:
on_value: on_value:
then: then:
- lambda: |- - lambda: |-
id(model_name).publish_state( id(model_name).publish_state(value_accuracy_to_string(x, 0));
std::to_string(static_cast<uint16_t>(x))
);
- platform: modbus_controller - platform: modbus_controller
name: "Serial Number" name: "Serial Number"
@@ -225,9 +213,9 @@ sensor:
unit_of_measurement: "W" unit_of_measurement: "W"
register_type: holding register_type: holding
value_type: U_DWORD value_type: U_DWORD
accuracy_decimals: ${${model}_power_accuracy} accuracy_decimals: 2
filters: filters:
- multiply: ${${model}_power_multiplier} - multiply: 0.01
- platform: modbus_controller - platform: modbus_controller
modbus_controller_id: powersupply modbus_controller_id: powersupply
@@ -238,9 +226,9 @@ sensor:
unit_of_measurement: "V" unit_of_measurement: "V"
register_type: holding register_type: holding
value_type: U_WORD value_type: U_WORD
accuracy_decimals: 2 accuracy_decimals: ${${model}_voltage_accuracy}
filters: filters:
- multiply: 0.01 - multiply: ${${model}_voltage_multiplier}
- platform: modbus_controller - platform: modbus_controller
modbus_controller_id: powersupply modbus_controller_id: powersupply
@@ -278,9 +266,9 @@ sensor:
unit_of_measurement: "V" unit_of_measurement: "V"
register_type: holding register_type: holding
value_type: U_WORD value_type: U_WORD
accuracy_decimals: 2 accuracy_decimals: ${${model}_voltage_accuracy}
filters: filters:
- multiply: 0.01 - multiply: ${${model}_voltage_multiplier}
- platform: modbus_controller - platform: modbus_controller
name: "Temperature" name: "Temperature"
+1 -11
View File
@@ -1,5 +1,3 @@
# Display contract shared with the ESPHome calendar page: compact German labels,
# a bounded number of events, and strings sized for the e-paper layout.
CALENDAR_NAMES = { CALENDAR_NAMES = {
"calendar.tkrz_kalender": "Arbeit", "calendar.tkrz_kalender": "Arbeit",
"calendar.privat": "Privat", "calendar.privat": "Privat",
@@ -11,7 +9,6 @@ MAX_TITLE_LENGTH = 22
MAX_META_LENGTH = 35 MAX_META_LENGTH = 35
# Keep variable event text within the fixed-width e-paper agenda columns.
def shorten(value, maximum): def shorten(value, maximum):
value = (value or "").strip() value = (value or "").strip()
if len(value) <= maximum: if len(value) <= maximum:
@@ -19,13 +16,11 @@ def shorten(value, maximum):
return value[: maximum - 3].rstrip() + "..." return value[: maximum - 3].rstrip() + "..."
# Convert one Home Assistant calendar event into the small JSON shape consumed
# by ESPHome, separating all-day, start-time, end-time, and metadata display data.
def compact_event(event, calendar_name): def compact_event(event, calendar_name):
start = event.get("start", "") start = event.get("start", "")
all_day = "T" not in start all_day = "T" not in start
end = event.get("end", "") end = event.get("end", "")
time = "ganzt." if all_day else start[11:16] time = "ganztägig" if all_day else start[11:16]
end_time = "" if all_day or "T" not in end else end[11:16] end_time = "" if all_day or "T" not in end else end[11:16]
location = (event.get("location") or "").split("\n")[0].strip() location = (event.get("location") or "").split("\n")[0].strip()
@@ -42,8 +37,6 @@ def compact_event(event, calendar_name):
} }
# Read the calendar.get_events response supplied by the calling template sensor
# and collect events under the date on which they should appear in the agenda.
calendar_data = data.get("calendar", {}) calendar_data = data.get("calendar", {})
today = str(data.get("now", ""))[:10] today = str(data.get("now", ""))[:10]
events_by_date = {} events_by_date = {}
@@ -69,8 +62,6 @@ for calendar_id, calendar in calendar_data.items():
compact_event(event, calendar_name) compact_event(event, calendar_name)
) )
# Sort day groups and events, put all-day entries first, and cap the payload so
# deserializing it stays safe on the ESP32 without PSRAM.
entries = [] entries = []
entry_count = 0 entry_count = 0
for date in sorted(events_by_date): for date in sorted(events_by_date):
@@ -93,5 +84,4 @@ for date in sorted(events_by_date):
} }
) )
# Return only the normalized agenda payload to the Home Assistant template sensor.
output["entries"] = entries output["entries"] = entries
+2 -2
View File
@@ -11,7 +11,7 @@
host: !secret router_ip host: !secret router_ip
community: !secret router_community community: !secret router_community
# baseoid: .1.3.6.1.2.1.31.1.1.1.6.511 # baseoid: .1.3.6.1.2.1.31.1.1.1.6.511
baseoid: .1.3.6.1.2.1.2.2.1.10.12 baseoid: .1.3.6.1.2.1.2.2.1.10.25
version: 2c version: 2c
unit_of_measurement: "Octets" unit_of_measurement: "Octets"
- platform: snmp - platform: snmp
@@ -20,7 +20,7 @@
host: !secret router_ip host: !secret router_ip
community: !secret router_community community: !secret router_community
# baseoid: .1.3.6.1.2.1.31.1.1.1.10.511 # baseoid: .1.3.6.1.2.1.31.1.1.1.10.511
baseoid: .1.3.6.1.2.1.2.2.1.16.12 baseoid: .1.3.6.1.2.1.2.2.1.16.25
version: 2c version: 2c
unit_of_measurement: "Octets" unit_of_measurement: "Octets"