24 Commits

Author SHA1 Message Date
Commander1024 df047f61fb Calendar data retrieval via "get calendar events" in automation and
text_helpers.
2026-07-10 13:33:34 +02:00
Commander1024 67a0a03093 Add template sensors for calendar events - somewhat working 2026-07-10 12:24:01 +02:00
Commander1024 8f90ef1cb4 Revert template sensors 2026-07-10 01:11:01 +02:00
Commander1024 7c3186563a Handle missing sensors with default float value 2026-07-10 00:58:50 +02:00
Commander1024 4f6ea199d4 Display today's and tomorrow's calendar events. And template sensor
logic.
2026-07-10 00:33:09 +02:00
Commander1024 f57a7f94fd Set calendar page as default for development. 2026-07-09 23:14:23 +02:00
Commander1024 c2060b6495 Enable IPv6 2026-07-09 09:04:45 +02:00
Commander1024 987bb977ce Untested, bare, dummy calendar page 2026-07-09 08:59:09 +02:00
Commander1024 83450c11c2 Remove unused air quality text sensors 2026-06-27 11:46:44 +02:00
Commander1024 af8f74dfb7 Adjust sun times display position 2026-06-26 23:04:09 +02:00
Commander1024 d609d780e8 Expand and realign e-paper dashboard layout. Add children's rooms
values.
2026-06-26 22:56:12 +02:00
Commander1024 e7466ccc6a Refactor YAML file and update sensor IDs 2026-06-23 13:43:50 +02:00
Commander1024 b22c86e95b Document Core2 BLE proxy power and UI logic 2026-06-23 10:06:08 +02:00
Commander1024 cecec14be1 Added usage info. 2026-05-30 19:12:03 +02:00
Commander1024 4e5df1ad0c Updated file comments 2026-05-30 19:00:18 +02:00
Commander1024 2c16ba1679 Separated long-press buttons into own HA entityies to make them usable 2026-05-30 18:49:16 +02:00
Commander1024 c21f2a5c7b Display aestethics: taller 7-segments, repositioned minus, mode and
icons
2026-05-30 17:49:56 +02:00
Commander1024 2a1902ccf1 Add reset all / reset energy function to also clear the local meter 2026-05-30 17:06:31 +02:00
Commander1024 31848bf26c Add energy monitor using riemann sum algorithm. 2026-05-30 16:49:57 +02:00
Commander1024 d7337fd634 Set (somewhat) appropiate mdi icons for OWON HA sensors. 2026-05-30 08:22:32 +02:00
Commander1024 5b287303f1 Add backlight idle script 2026-05-28 22:58:15 +02:00
Commander1024 816cc35861 Implement dc-load inactivity display 2026-05-28 22:49:32 +02:00
Commander1024 058c186d63 Remove dead values from HA and rendering code. Also increase font size. 2026-05-28 22:24:46 +02:00
Commander1024 22e5f9d767 Implemented rough 1st iteration of dc-load value screen. 2026-05-28 22:09:54 +02:00
7 changed files with 1371 additions and 268 deletions
+110
View File
@@ -1393,3 +1393,113 @@
device_id: 6d1be741876624a70ab5b01b54c6fd6f device_id: 6d1be741876624a70ab5b01b54c6fd6f
entity_id: 621e4377a089b7f5d92c7c9f2cc171a1 entity_id: 621e4377a089b7f5d92c7c9f2cc171a1
domain: switch domain: switch
- id: '1773000000001'
alias: epaperframe - Kalender Events laden
description: Ruft alle Events von calendar.privat und calendar.tkrz_kalender für heute und morgen ab und schreibt sie in input_text-Helfer.
triggers:
# Täglich um 00:01 neu holen
- trigger: time
at: '00:01:00'
id: daily
actions:
# ── Events für heute (00:00 bis 23:59) holen ──
- action: calendar.get_events
target:
entity_id:
- calendar.privat
- calendar.tkrz_kalender
data:
start_date_time: "{{ now().replace(hour=0, minute=0, second=0) }}"
end_date_time: "{{ (now().replace(hour=0, minute=0, second=0) + timedelta(days=1)) }}"
response_variable: today_evts
# ── Events für morgen (00:00 bis 23:59) holen ──
- action: calendar.get_events
target:
entity_id:
- calendar.privat
- calendar.tkrz_kalender
data:
start_date_time: "{{ (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0) }}"
end_date_time: "{{ (now() + timedelta(days=1)).replace(hour=0, minute=0, second=0) + timedelta(days=1) }}"
response_variable: tomorrow_evts
# ── Helper: Events als kompakte Liste formatieren ──
# Privat heute
- set_var:
name: fmt_today_privat
value: >-
{%- set evts = today_evts['calendar.privat']['events'] if 'calendar.privat' in today_evts else [] %}
{%- set items = [] %}
{%- for e in evts[:5] %}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' %}
{%- set st = e['start'] if e is mapping and 'start' in e else '' %}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' %}
{%- set items = items + [hhmm ~ ' - ' ~ s] %}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
# Arbeit heute
- set_var:
name: fmt_today_arbeit
value: >-
{%- set evts = today_evts['calendar.tkrz_kalender']['events'] if 'calendar.tkrz_kalender' in today_evts else [] %}
{%- set items = [] %}
{%- for e in evts[:5] %}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' %}
{%- set st = e['start'] if e is mapping and 'start' in e else '' %}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' %}
{%- set items = items + [hhmm ~ ' - ' ~ s] %}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
# Privat morgen
- set_var:
name: fmt_tomorrow_privat
value: >-
{%- set evts = tomorrow_evts['calendar.privat']['events'] if 'calendar.privat' in tomorrow_evts else [] %}
{%- set items = [] %}
{%- for e in evts[:5] %}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' %}
{%- set st = e['start'] if e is mapping and 'start' in e else '' %}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' %}
{%- set items = items + [hhmm ~ ' - ' ~ s] %}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
# Arbeit morgen
- set_var:
name: fmt_tomorrow_arbeit
value: >-
{%- set evts = tomorrow_evts['calendar.tkrz_kalender']['events'] if 'calendar.tkrz_kalender' in tomorrow_evts else [] %}
{%- set items = [] %}
{%- for e in evts[:5] %}
{%- set s = (e['summary'] | default('', true) | string)[:40] if e is mapping and 'summary' in e else '-' %}
{%- set st = e['start'] if e is mapping and 'start' in e else '' %}
{%- set hhmm = st[11:16] if st|length >= 16 else '??' %}
{%- set items = items + [hhmm ~ ' - ' ~ s] %}
{%- endfor -%}
{{ items | join('│') if items else '-' }}
# ── input_text Helfer schreiben ──
- action: input_text.set_value
target:
entity_id: input_text.kalender_heute_privat
data:
value: "{{ fmt_today_privat }}"
- action: input_text.set_value
target:
entity_id: input_text.kalender_heute_arbeit
data:
value: "{{ fmt_today_arbeit }}"
- action: input_text.set_value
target:
entity_id: input_text.kalender_morgen_privat
data:
value: "{{ fmt_tomorrow_privat }}"
- action: input_text.set_value
target:
entity_id: input_text.kalender_morgen_arbeit
data:
value: "{{ fmt_tomorrow_arbeit }}"
+3
View File
@@ -49,6 +49,9 @@ sql:
# calendar integration # calendar integration
calendar: !include calendars.yaml calendar: !include calendars.yaml
# Helpers for epaperframe calendar display
input_text: !include text_helpers.yaml
# DB-recorder configuration # DB-recorder configuration
recorder: !include recorder.yaml recorder: !include recorder.yaml
+685 -174
View File
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,11 @@
/* /*
* ESPHome helper for OWON B35T/B35T+ BLE meter on M5Stack Core 1. * ESPHome helper for OWON B35T/B35T+ BLE meter on M5Stack Core 2.
* Parser is based on the standalone Arduino sketch by Reaper7 * Parser is based on the standalone Arduino sketch by Reaper7
* (Beerware license, Revision 42) and Dean Cording's owonb35 notes. * (Beerware license, Revision 42) and Dean Cording's owonb35 notes.
* Rendering code and some functionality modified to suppport the
* Atorch DL24 dc load.
*/ */
#pragma once #pragma once
#include <cmath> #include <cmath>
@@ -22,12 +25,16 @@ namespace owon_b35t {
using esphome::Color; using esphome::Color;
using esphome::display::Display; using esphome::display::Display;
// Log tags used by ESPHome for BLE meter parsing and Core2 power-management messages.
static const char *const TAG = "owon_b35t"; static const char *const TAG = "owon_b35t";
static const char *const POWER_TAG = "core2_power"; static const char *const POWER_TAG = "core2_power";
// The M5Stack Core2 routes LCD/backlight power through an AXP192 PMIC on I2C.
static constexpr uint8_t AXP192_ADDR = 0x34; static constexpr uint8_t AXP192_ADDR = 0x34;
static esphome::i2c::I2CDevice axp192; static esphome::i2c::I2CDevice axp192;
static bool axp192_ready = false; static bool axp192_ready = false; // Guard PMIC accesses until the I2C bus/address has been configured.
// Write one byte to an AXP192 register and log failures instead of silently losing power changes.
static bool axp_write(uint8_t reg, uint8_t value) { static bool axp_write(uint8_t reg, uint8_t value) {
if (!axp192_ready) return false; if (!axp192_ready) return false;
bool ok = axp192.write_byte(reg, value); bool ok = axp192.write_byte(reg, value);
@@ -35,6 +42,7 @@ static bool axp_write(uint8_t reg, uint8_t value) {
return ok; return ok;
} }
// Read one byte from an AXP192 register; callers use this before read/modify/write updates.
static bool axp_read(uint8_t reg, uint8_t *value) { static bool axp_read(uint8_t reg, uint8_t *value) {
if (!axp192_ready) return false; if (!axp192_ready) return false;
bool ok = axp192.read_byte(reg, value); bool ok = axp192.read_byte(reg, value);
@@ -42,6 +50,7 @@ static bool axp_read(uint8_t reg, uint8_t *value) {
return ok; return ok;
} }
// Clear and set selected bits in an AXP192 register while preserving all other bits.
static void axp_update(uint8_t reg, uint8_t clear_mask, uint8_t set_mask) { static void axp_update(uint8_t reg, uint8_t clear_mask, uint8_t set_mask) {
uint8_t value = 0; uint8_t value = 0;
if (!axp_read(reg, &value)) return; if (!axp_read(reg, &value)) return;
@@ -49,24 +58,28 @@ static void axp_update(uint8_t reg, uint8_t clear_mask, uint8_t set_mask) {
axp_write(reg, value); axp_write(reg, value);
} }
// Convert a desired DCDC output voltage to the 25 mV-step register encoding used by AXP192.
static uint8_t axp_dc_voltage_data(uint16_t millivolts) { static uint8_t axp_dc_voltage_data(uint16_t millivolts) {
if (millivolts < 700) millivolts = 700; if (millivolts < 700) millivolts = 700;
if (millivolts > 3500) millivolts = 3500; if (millivolts > 3500) millivolts = 3500;
return static_cast<uint8_t>((millivolts - 700) / 25) & 0x7F; return static_cast<uint8_t>((millivolts - 700) / 25) & 0x7F;
} }
// Convert a desired LDO voltage to the 100 mV-step register encoding used by AXP192.
static uint8_t axp_ldo_voltage_data(uint16_t millivolts) { static uint8_t axp_ldo_voltage_data(uint16_t millivolts) {
if (millivolts < 1800) millivolts = 1800; if (millivolts < 1800) millivolts = 1800;
if (millivolts > 3300) millivolts = 3300; if (millivolts > 3300) millivolts = 3300;
return static_cast<uint8_t>((millivolts - 1800) / 100) & 0x0F; return static_cast<uint8_t>((millivolts - 1800) / 100) & 0x0F;
} }
// Set the LCD backlight rail (DCDC3) voltage; brightness is controlled by this rail voltage.
static void core2_axp192_set_lcd_voltage(uint16_t millivolts) { static void core2_axp192_set_lcd_voltage(uint16_t millivolts) {
uint8_t value = 0; uint8_t value = 0;
axp_read(0x27, &value); axp_read(0x27, &value);
axp_write(0x27, (value & 0x80) | axp_dc_voltage_data(millivolts)); // DCDC3, LCD backlight axp_write(0x27, (value & 0x80) | axp_dc_voltage_data(millivolts)); // DCDC3, LCD backlight
} }
// Map a 0.0-1.0 brightness value to the Core2 LCD backlight voltage and enable/disable DCDC3.
static void core2_axp192_set_backlight(float brightness) { static void core2_axp192_set_backlight(float brightness) {
if (brightness <= 0.0f) { if (brightness <= 0.0f) {
axp_update(0x12, 0x02, 0x00); // DCDC3 off axp_update(0x12, 0x02, 0x00); // DCDC3 off
@@ -78,6 +91,7 @@ static void core2_axp192_set_backlight(float brightness) {
axp_update(0x12, 0x00, 0x02); // DCDC3 on axp_update(0x12, 0x00, 0x02); // DCDC3 on
} }
// Initialize the Core2 PMIC rails needed by ESP32, LCD logic, LCD backlight, and the display reset line.
static void core2_axp192_init(esphome::i2c::I2CBus *bus) { static void core2_axp192_init(esphome::i2c::I2CBus *bus) {
axp192.set_i2c_bus(bus); axp192.set_i2c_bus(bus);
axp192.set_i2c_address(AXP192_ADDR); axp192.set_i2c_address(AXP192_ADDR);
@@ -110,6 +124,7 @@ static void core2_axp192_init(esphome::i2c::I2CBus *bus) {
core2_axp192_set_backlight(1.0f); core2_axp192_set_backlight(1.0f);
} }
// 16x16 monochrome status icons drawn manually into the ESPHome display framebuffer.
static const uint8_t ACCU_BMP[32] = { static const uint8_t ACCU_BMP[32] = {
0b00000000, 0b00000000, 0b00000000, 0b00000000,
0b00000000, 0b00000000, 0b00000000, 0b00000000,
@@ -148,6 +163,44 @@ static const uint8_t BLE_BMP[32] = {
0b00000001, 0b10000000, 0b00000001, 0b10000000,
}; };
static const uint8_t HOLD_BMP[32] = {
0b01111111, 0b11111110,
0b11111111, 0b11111111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100000, 0b00000111,
0b11100000, 0b00000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11100011, 0b11000111,
0b11111111, 0b11111111,
0b01111111, 0b11111110,
};
static const uint8_t REL_BMP[32] = {
0b00000001, 0b00000000,
0b00000001, 0b00000000,
0b00000011, 0b10000000,
0b00000011, 0b10000000,
0b00000110, 0b11000000,
0b00000110, 0b11000000,
0b00001100, 0b01100000,
0b00001100, 0b01100000,
0b00011000, 0b00110000,
0b00011000, 0b00110000,
0b00110000, 0b00011000,
0b00110000, 0b00011000,
0b01100000, 0b00001100,
0b01100000, 0b00001100,
0b11111111, 0b11111110,
0b11111111, 0b11111110,
};
static const uint8_t DIODE_BMP[32] = { static const uint8_t DIODE_BMP[32] = {
0b00001000, 0b00011000, 0b00001000, 0b00011000,
0b00001100, 0b00011000, 0b00001100, 0b00011000,
@@ -188,6 +241,8 @@ static const uint8_t BUZZ_BMP[32] = {
class Meter { class Meter {
public: public:
// Offsets and bit masks for the 14-byte "classic" OWON frame layout. B35T+ frames are
// normalized into this same buffer so the rest of the code can use one representation.
static constexpr uint8_t REGPLUSMINUS = 0x00; static constexpr uint8_t REGPLUSMINUS = 0x00;
static constexpr uint8_t FLAGPLUS = 0b00101011; static constexpr uint8_t FLAGPLUS = 0b00101011;
static constexpr uint8_t FLAGMINUS = 0b00101101; static constexpr uint8_t FLAGMINUS = 0b00101101;
@@ -227,24 +282,29 @@ class Meter {
static constexpr uint8_t FLAGUNITAMP = 0b01000000; static constexpr uint8_t FLAGUNITAMP = 0b01000000;
static constexpr uint8_t FLAGUNITVOLT = 0b10000000; static constexpr uint8_t FLAGUNITVOLT = 0b10000000;
bool connected{false}; // Connection and decoded meter state consumed by ESPHome sensors and the local display.
bool write_available{false}; bool connected{false}; // BLE link to the OWON meter is currently established.
bool is_plus{false}; bool write_available{false}; // The writable BLE characteristic is ready for button commands.
bool low_battery{false}; bool is_plus{false}; // True when the last notification used the compact B35T+ frame format.
bool overload{false}; bool low_battery{false}; // Battery indicator decoded from the meter status bits.
bool has_reading{false}; bool overload{false}; // True when the meter reports OL instead of numeric digits.
uint8_t selected_button{1}; bool has_reading{false}; // At least one valid BLE notification has been decoded.
uint32_t last_notify_ms{0}; uint8_t selected_button{1}; // UI-selected OWON remote button command (1..6).
uint32_t last_notify_ms{0}; // Timestamp of the last accepted meter notification.
// Decode a BLE notification from either supported OWON protocol variant and refresh cached values.
bool handle_notify(const std::vector<uint8_t> &data) { bool handle_notify(const std::vector<uint8_t> &data) {
if (data.size() > sizeof(this->raw_)) if (data.size() > sizeof(this->raw_))
return false; return false;
// B35T+ sends a compact 6-byte binary frame; convert it into the classic 14-byte layout.
if (data.size() == 6 && data[1] >= 0xF0) { if (data.size() == 6 && data[1] >= 0xF0) {
memset(this->raw_, 0, sizeof(this->raw_)); memset(this->raw_, 0, sizeof(this->raw_));
memcpy(this->raw_, data.data(), data.size()); memcpy(this->raw_, data.data(), data.size());
this->is_plus = true; this->is_plus = true;
this->parse_plus_(); this->parse_plus_();
} else if (data.size() == 14 && data[12] == 0x0D && data[13] == 0x0A) { } else if (data.size() == 14 && data[12] == 0x0D && data[13] == 0x0A) {
// Classic B35T sends an ASCII-like 14-byte frame terminated by CR/LF; it can be used directly.
memset(this->value_, 0, sizeof(this->value_)); memset(this->value_, 0, sizeof(this->value_));
memcpy(this->value_, data.data(), data.size()); memcpy(this->value_, data.data(), data.size());
this->is_plus = false; this->is_plus = false;
@@ -253,26 +313,32 @@ class Meter {
return false; return false;
} }
// Cache derived states so display drawing and Home Assistant sensors do not have to re-parse frames.
this->overload = memcmp(this->value_, OVERLOAD_FRAME, sizeof(OVERLOAD_FRAME)) == 0; this->overload = memcmp(this->value_, OVERLOAD_FRAME, sizeof(OVERLOAD_FRAME)) == 0;
this->display_value = this->calc_display_value_(); this->display_value = this->calc_display_value_(); // Numeric value exactly as shown on the meter.
this->base_value = this->calc_base_value_(); this->base_value = this->calc_base_value_(); // Same reading converted to base SI scale.
this->has_reading = true; this->has_reading = true;
this->last_notify_ms = millis(); this->last_notify_ms = millis();
return true; return true;
} }
// Called by the ESPHome BLE client once the meter connection and write characteristic are usable.
void on_connect() { void on_connect() {
this->connected = true; this->connected = true;
this->write_available = true; this->write_available = true;
} }
// Reset connection flags when BLE disconnects; the last reading is kept for display/sensor continuity.
void on_disconnect() { void on_disconnect() {
this->connected = false; this->connected = false;
this->write_available = false; this->write_available = false;
} }
// Numeric accessors used by ESPHome lambdas when publishing sensor state to Home Assistant.
float value() const { return this->display_value; } float value() const { return this->display_value; }
float value_base() const { return this->base_value; } float value_base() const { return this->base_value; }
// Boolean flag helpers keep the bit-mask details out of UI and sensor publishing code.
bool negative() const { return (this->value_[REGPLUSMINUS] & FLAGMINUS) == FLAGMINUS; } bool negative() const { return (this->value_[REGPLUSMINUS] & FLAGMINUS) == FLAGMINUS; }
bool auto_range() const { return (this->value_[REGMODE] & FLAGMODEAUTO) == FLAGMODEAUTO; } bool auto_range() const { return (this->value_[REGMODE] & FLAGMODEAUTO) == FLAGMODEAUTO; }
bool hold() const { return (this->value_[REGMODE] & FLAGMODEHOLD) == FLAGMODEHOLD; } bool hold() const { return (this->value_[REGMODE] & FLAGMODEHOLD) == FLAGMODEHOLD; }
@@ -284,6 +350,7 @@ class Meter {
bool diode() const { return (this->value_[REGSCALE] & FLAGSCALEDIODE) == FLAGSCALEDIODE; } bool diode() const { return (this->value_[REGSCALE] & FLAGSCALEDIODE) == FLAGSCALEDIODE; }
bool continuity() const { return (this->value_[REGSCALE] & FLAGSCALEBUZZ) == FLAGSCALEBUZZ; } bool continuity() const { return (this->value_[REGSCALE] & FLAGSCALEBUZZ) == FLAGSCALEBUZZ; }
// Translate decoded unit bits into the text suffix shown on the display and exposed via sensors.
const char *unit() const { const char *unit() const {
switch (this->value_[REGUNIT]) { switch (this->value_[REGUNIT]) {
case FLAGUNITFAHR: return "°F"; case FLAGUNITFAHR: return "°F";
@@ -298,6 +365,7 @@ class Meter {
} }
} }
// Translate decoded scale bits into SI prefixes or duty-cycle percent.
const char *scale() const { const char *scale() const {
if ((this->value_[REGSCALE] & FLAGSCALEDUTY) == FLAGSCALEDUTY) return "%"; if ((this->value_[REGSCALE] & FLAGSCALEDUTY) == FLAGSCALEDUTY) return "%";
if ((this->value_[REGSCALE] & FLAGSCALEMEGA) == FLAGSCALEMEGA) return "M"; if ((this->value_[REGSCALE] & FLAGSCALEMEGA) == FLAGSCALEMEGA) return "M";
@@ -307,6 +375,7 @@ class Meter {
return ""; return "";
} }
// Build a compact human-readable list of active meter modes for Home Assistant text sensors.
std::string mode_text() const { std::string mode_text() const {
std::string out; std::string out;
if (this->dc()) out += "DC "; if (this->dc()) out += "DC ";
@@ -322,6 +391,7 @@ class Meter {
return out; return out;
} }
// Format the current reading as a single string, including disconnected/waiting/overload states.
std::string reading_text() const { std::string reading_text() const {
if (!this->connected) return "Disconnected"; if (!this->connected) return "Disconnected";
if (!this->has_reading) return "Waiting for data"; if (!this->has_reading) return "Waiting for data";
@@ -331,6 +401,7 @@ class Meter {
return std::string(buf); return std::string(buf);
} }
// Classify the reading so ESPHome can publish it to the correct measurement-specific sensor.
enum Kind { KIND_OTHER, KIND_VOLTAGE, KIND_CURRENT, KIND_RESISTANCE, KIND_FREQUENCY, KIND_CAPACITANCE, KIND_TEMP_C, KIND_TEMP_F, KIND_DUTY }; enum Kind { KIND_OTHER, KIND_VOLTAGE, KIND_CURRENT, KIND_RESISTANCE, KIND_FREQUENCY, KIND_CAPACITANCE, KIND_TEMP_C, KIND_TEMP_F, KIND_DUTY };
Kind kind() const { Kind kind() const {
if ((this->value_[REGSCALE] & FLAGSCALEDUTY) == FLAGSCALEDUTY) return KIND_DUTY; if ((this->value_[REGSCALE] & FLAGSCALEDUTY) == FLAGSCALEDUTY) return KIND_DUTY;
@@ -346,6 +417,7 @@ class Meter {
} }
} }
// UI label for the currently selected remote-control command sent back to the OWON meter.
const char *selected_button_name() const { const char *selected_button_name() const {
static const char *const names[] = {"SELECT", "RANGE", "HLD/LIG", "REL/BT", "HZ/DUTY", "MAX/MIN"}; static const char *const names[] = {"SELECT", "RANGE", "HLD/LIG", "REL/BT", "HZ/DUTY", "MAX/MIN"};
uint8_t index = this->selected_button; uint8_t index = this->selected_button;
@@ -354,6 +426,7 @@ class Meter {
return names[index - 1]; return names[index - 1];
} }
// Move the selected remote button left/right; bounds match the six commands in selected_button_name().
void previous_button() { void previous_button() {
if (this->selected_button > 1) this->selected_button--; if (this->selected_button > 1) this->selected_button--;
} }
@@ -361,7 +434,12 @@ class Meter {
if (this->selected_button < 6) this->selected_button++; if (this->selected_button < 6) this->selected_button++;
} }
void render(Display &it, esphome::display::BaseFont *font) { // Draw either the OWON multimeter page or the Atorch DL24 load page on the M5Stack display.
void render(esphome::display::Display &it, esphome::display::BaseFont *font,
esphome::display::BaseFont *value_font, int display_page = 0,
bool atorch_connected = false,
float atorch_voltage = NAN, float atorch_current = NAN, float atorch_power = NAN,
float atorch_capacity = NAN, float atorch_energy = NAN, float atorch_temperature = NAN) {
const Color bg(0, 0, 0); const Color bg(0, 0, 0);
const Color fg(210, 210, 210); const Color fg(210, 210, 210);
// Chosen to map to a neutral dark gray in the RGB332 8-bit display palette. // Chosen to map to a neutral dark gray in the RGB332 8-bit display palette.
@@ -374,63 +452,127 @@ class Meter {
const Color green(0, 220, 0); const Color green(0, 220, 0);
const Color orange(255, 165, 0); const Color orange(255, 165, 0);
it.fill(bg); if (display_page == 0) {
bool status_active = this->connected && this->has_reading; // --- PAGE 1: OWON Multimeter ---
this->draw_icon_(it, 12, 8, 16, 16, ACCU_BMP, status_active ? (this->low_battery ? red : green) : inactive); it.fill(bg);
this->draw_icon_(it, 46, 8, 16, 16, BLE_BMP, this->connected ? blue : inactive); bool status_active = this->connected && this->has_reading; // Only highlight decoded flags after data arrives.
this->label_(it, font, 86, 8, "AUTO", status_active && this->auto_range() ? fg : inactive);
this->label_(it, font, 138, 8, "MAX", status_active && this->max_mode() ? red : inactive);
this->label_(it, font, 178, 8, "MIN", status_active && this->min_mode() ? green : inactive);
this->label_(it, font, 218, 8, "HOLD", status_active && this->hold() ? blue : inactive);
this->label_(it, font, 270, 8, "REL", status_active && this->relative() ? Color(128, 128, 0) : inactive);
this->label_(it, font, 8, 66, "DC", status_active && this->dc() ? cyan : inactive); // Top status row mirrors the physical meter annunciators: battery, BLE, range, min/max, hold, rel, diode, buzzer.
this->label_(it, font, 8, 102, "AC", status_active && this->ac() ? magenta : inactive); this->draw_icon_(it, 12, 8, 16, 16, ACCU_BMP, status_active ? (this->low_battery ? red : green) : inactive);
this->draw_icon_(it, 46, 8, 16, 16, BLE_BMP, this->connected ? blue : inactive);
this->label_(it, font, 86, 8, "AUTO", status_active && this->auto_range() ? fg : inactive);
this->label_(it, font, 138, 8, "MAX", status_active && this->max_mode() ? red : inactive);
this->label_(it, font, 178, 8, "MIN", status_active && this->min_mode() ? green : inactive);
this->draw_icon_(it, 218, 8, 16, 16, HOLD_BMP, status_active && this->hold() ? blue : inactive);
this->draw_icon_(it, 244, 8, 16, 16, REL_BMP, status_active && this->relative() ? Color(128, 128, 0) : inactive);
this->draw_icon_(it, 270, 8, 16, 16, DIODE_BMP, status_active && this->diode() ? magenta : inactive);
this->draw_icon_(it, 296, 8, 16, 16, BUZZ_BMP, status_active && this->continuity() ? orange : inactive);
if (!this->connected) { this->label_(it, font, 8, 104, "DC", status_active && this->dc() ? cyan : inactive);
this->draw_digits_(it, "----", false, inactive); this->label_(it, font, 8, 124, "AC", status_active && this->ac() ? magenta : inactive);
it.print(160, 148, font, inactive, esphome::display::TextAlign::CENTER, "scan/connect");
} else if (!this->has_reading) { // Main seven-segment area distinguishes connection, waiting-for-first-frame, overload, and normal readings.
this->draw_digits_(it, "8888", false, inactive); if (!this->connected) {
it.print(160, 148, font, inactive, esphome::display::TextAlign::CENTER, "waiting"); this->draw_digits_(it, "----", false, inactive);
} else if (this->overload) { it.print(160, 148, font, inactive, esphome::display::TextAlign::CENTER, "scan/connect");
this->draw_digits_(it, " OL ", false, fg); } else if (!this->has_reading) {
this->draw_digits_(it, "8888", false, inactive);
it.print(160, 148, font, inactive, esphome::display::TextAlign::CENTER, "waiting");
} else if (this->overload) {
this->draw_digits_(it, " OL ", false, fg);
} else {
char d[5];
d[0] = this->digit_char_(REGDIG1);
d[1] = this->digit_char_(REGDIG2);
d[2] = this->digit_char_(REGDIG3);
d[3] = this->digit_char_(REGDIG4);
d[4] = 0;
this->draw_digits_(it, d, this->negative(), fg);
this->draw_decimal_points_(it, fg);
}
if (status_active) {
std::string unit_line = std::string(this->scale()) + this->unit();
it.print(316, 141, font, yellow, esphome::display::TextAlign::BOTTOM_RIGHT, unit_line.c_str());
}
bool bargraph_active = status_active && !this->overload;
this->draw_bargraph_(it, bargraph_active ? this->digits_from_buffer_() : 0, bargraph_active);
// Bottom soft-button row shows the currently selected OWON command and whether BLE writes are available.
it.filled_rectangle(34, 212, 40, 24, this->write_available ? fg : inactive);
it.filled_rectangle(108, 212, 100, 24, this->write_available ? fg : inactive);
it.filled_rectangle(242, 212, 40, 24, this->write_available ? fg : inactive);
it.print(54, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, "<");
it.print(158, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, this->selected_button_name());
it.print(262, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, ">");
} else { } else {
char d[5]; // --- PAGE 2: Atorch DL24 DC load ---
d[0] = this->digit_char_(REGDIG1); it.fill(bg);
d[1] = this->digit_char_(REGDIG2); const Color panel_active(18, 24, 32);
d[2] = this->digit_char_(REGDIG3); const Color panel_inactive(12, 12, 12);
d[3] = this->digit_char_(REGDIG4); const Color panel_dim(10, 14, 20);
d[4] = 0; const Color border_active(55, 70, 86);
this->draw_digits_(it, d, this->negative(), fg); const Color border_inactive(42, 42, 42);
this->draw_decimal_points_(it, fg); const Color white(245, 245, 245);
const Color dim_value(110, 110, 110);
const Color dim_accent(65, 65, 65);
const Color panel = atorch_connected ? panel_active : panel_inactive;
const Color border = atorch_connected ? border_active : border_inactive;
const Color value_color = atorch_connected ? white : dim_value;
const Color voltage_color = atorch_connected ? cyan : dim_accent;
const Color current_color = atorch_connected ? orange : dim_accent;
const Color power_color = atorch_connected ? yellow : dim_accent;
const Color temp_color = atorch_connected ? magenta : dim_accent;
const Color header_color = atorch_connected ? cyan : dim_value;
// Prepare formatted metric strings before drawing so missing/NaN Atorch values display consistently.
char voltage_text[24];
char current_text[24];
char power_text[24];
char capacity_text[24];
char energy_text[24];
char temperature_text[24];
this->format_metric_(voltage_text, sizeof(voltage_text), atorch_voltage, "V", 2);
this->format_metric_(current_text, sizeof(current_text), atorch_current, "A", 3);
this->format_metric_(power_text, sizeof(power_text), atorch_power, "W", 2);
this->format_metric_(capacity_text, sizeof(capacity_text), atorch_capacity, "Ah", 3);
this->format_metric_(energy_text, sizeof(energy_text), atorch_energy, "Wh", 3);
this->format_metric_(temperature_text, sizeof(temperature_text), atorch_temperature, "°C", 1);
it.filled_rectangle(0, 0, 320, 30, atorch_connected ? panel_dim : panel_inactive);
it.print(10, 7, font, header_color, esphome::display::TextAlign::TOP_LEFT, "ATORCH DL24");
if (atorch_connected) {
this->draw_icon_(it, 152, 7, 16, 16, BLE_BMP, blue);
}
it.print(310, 7, font, inactive, esphome::display::TextAlign::TOP_RIGHT, "DC LOAD");
// Four primary Atorch measurements are shown as dashboard cards; accumulated counters fit in the footer.
this->draw_metric_card_(it, font, value_font, 10, 42, 145, 76, "VOLTAGE", voltage_text, voltage_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 165, 42, 145, 76, "CURRENT", current_text, current_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 10, 128, 145, 76, "POWER", power_text, power_color, panel, border, value_color);
this->draw_metric_card_(it, font, value_font, 165, 128, 145, 76, "TEMP", temperature_text, temp_color, panel, border, value_color);
it.filled_rectangle(10, 212, 300, 22, atorch_connected ? panel_dim : panel_inactive);
it.filled_rectangle(10, 212, 300, 1, border);
it.filled_rectangle(10, 233, 300, 1, border);
it.filled_rectangle(10, 212, 1, 22, border);
it.filled_rectangle(309, 212, 1, 22, border);
it.print(20, 216, font, inactive, esphome::display::TextAlign::TOP_LEFT, "CAP");
it.print(64, 216, font, value_color, esphome::display::TextAlign::TOP_LEFT, capacity_text);
it.print(170, 216, font, inactive, esphome::display::TextAlign::TOP_LEFT, "ENERGY");
it.print(306, 216, font, value_color, esphome::display::TextAlign::TOP_RIGHT, energy_text);
} }
if (status_active) {
std::string unit_line = std::string(this->scale()) + this->unit();
it.print(270, 140, font, yellow, esphome::display::TextAlign::CENTER, unit_line.c_str());
}
bool bargraph_active = status_active && !this->overload;
this->draw_bargraph_(it, bargraph_active ? this->digits_from_buffer_() : 0, bargraph_active);
this->draw_icon_(it, 300, 148, 16, 16, DIODE_BMP, status_active && this->diode() ? magenta : inactive);
this->draw_icon_(it, 300, 174, 16, 16, BUZZ_BMP, status_active && this->continuity() ? orange : inactive);
it.filled_rectangle(34, 212, 40, 24, this->write_available ? fg : inactive);
it.filled_rectangle(108, 212, 100, 24, this->write_available ? fg : inactive);
it.filled_rectangle(242, 212, 40, 24, this->write_available ? fg : inactive);
it.print(54, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, "<");
it.print(158, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, this->selected_button_name());
it.print(262, 216, font, bg, esphome::display::TextAlign::TOP_CENTER, ">");
} }
private: private:
uint8_t raw_[14]{}; uint8_t raw_[14]{}; // Last raw BLE payload, padded to the maximum supported OWON frame length.
uint8_t value_[14]{}; uint8_t value_[14]{}; // Normalized classic-frame view used by all accessors and display rendering.
float display_value{NAN}; float display_value{NAN}; // Meter reading with its displayed prefix still applied, e.g. 12.3 kΩ -> 12.3.
float base_value{NAN}; float base_value{NAN}; // Meter reading converted to base units, e.g. 12.3 kΩ -> 12300 Ω.
static constexpr uint8_t OVERLOAD_FRAME[5] = {0x2B, 0x3F, 0x30, 0x3A, 0x3F}; static constexpr uint8_t OVERLOAD_FRAME[5] = {0x2B, 0x3F, 0x30, 0x3A, 0x3F}; // "+?0:?" OL marker.
// Reconstruct the four visible seven-segment digits as an integer for value calculations/bargraph scaling.
uint16_t digits_from_buffer_() const { uint16_t digits_from_buffer_() const {
uint16_t out = 0; uint16_t out = 0;
if (this->value_[REGDIG1] >= '0' && this->value_[REGDIG1] <= '9') out += (this->value_[REGDIG1] - '0') * 1000; if (this->value_[REGDIG1] >= '0' && this->value_[REGDIG1] <= '9') out += (this->value_[REGDIG1] - '0') * 1000;
@@ -440,10 +582,12 @@ class Meter {
return out; return out;
} }
// Convert the normalized frame into the floating-point number shown by the meter display.
float calc_display_value_() const { float calc_display_value_() const {
if (this->overload) return NAN; if (this->overload) return NAN;
if (this->is_plus) { if (this->is_plus) {
// B35T+ encodes decimal placement and sign/magnitude as packed little-endian words.
uint16_t pair1 = static_cast<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8); uint16_t pair1 = static_cast<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8);
uint8_t decimal = pair1 & 0x07; uint8_t decimal = pair1 & 0x07;
if (decimal >= 7) return NAN; if (decimal >= 7) return NAN;
@@ -455,6 +599,7 @@ class Meter {
return negative ? -v : v; return negative ? -v : v;
} }
// Classic frames carry decimal placement as one of three point flags in the normalized buffer.
uint8_t decimal = 0; uint8_t decimal = 0;
switch (this->value_[REGPOINT] & 0x07) { switch (this->value_[REGPOINT] & 0x07) {
case 0b001: decimal = 1; break; case 0b001: decimal = 1; break;
@@ -466,6 +611,7 @@ class Meter {
return this->negative() ? -v : v; return this->negative() ? -v : v;
} }
// Apply the decoded SI prefix so Home Assistant receives comparable base-unit sensor values.
float calc_base_value_() const { float calc_base_value_() const {
if (std::isnan(this->display_value)) return NAN; if (std::isnan(this->display_value)) return NAN;
if (this->value_[REGUNIT] == FLAGUNITNF) return this->display_value * 1e-9f; if (this->value_[REGUNIT] == FLAGUNITNF) return this->display_value * 1e-9f;
@@ -476,17 +622,20 @@ class Meter {
return this->display_value; return this->display_value;
} }
// Decode the compact B35T+ payload and synthesize the 14-byte classic representation.
void parse_plus_() { void parse_plus_() {
memset(this->value_, 0, sizeof(this->value_)); memset(this->value_, 0, sizeof(this->value_));
this->value_[5] = 0x20; this->value_[5] = 0x20;
this->value_[12] = 0x0D; this->value_[12] = 0x0D;
this->value_[13] = 0x0A; this->value_[13] = 0x0A;
// First word: measurement function, SI scale, and decimal-point position.
uint16_t pair1 = static_cast<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8); uint16_t pair1 = static_cast<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8);
uint8_t function = (pair1 >> 6) & 0x0F; uint8_t function = (pair1 >> 6) & 0x0F;
uint8_t scale = (pair1 >> 3) & 0x07; uint8_t scale = (pair1 >> 3) & 0x07;
uint8_t decimal = pair1 & 0x07; uint8_t decimal = pair1 & 0x07;
// Translate B35T+ decimal count to the classic point-flag convention used by draw_decimal_points_().
switch (decimal) { switch (decimal) {
case 0: this->value_[REGPOINT] = FLAGPOINT0; break; case 0: this->value_[REGPOINT] = FLAGPOINT0; break;
case 1: this->value_[REGPOINT] = FLAGPOINT3; break; case 1: this->value_[REGPOINT] = FLAGPOINT3; break;
@@ -495,6 +644,7 @@ class Meter {
default: break; default: break;
} }
// Translate the function selector into classic unit and AC/DC/mode flags.
switch (function) { switch (function) {
case 0: this->value_[REGUNIT] |= FLAGUNITVOLT; this->value_[REGMODE] |= FLAGMODEDC; break; case 0: this->value_[REGUNIT] |= FLAGUNITVOLT; this->value_[REGMODE] |= FLAGMODEDC; break;
case 1: this->value_[REGUNIT] |= FLAGUNITVOLT; this->value_[REGMODE] |= FLAGMODEAC; break; case 1: this->value_[REGUNIT] |= FLAGUNITVOLT; this->value_[REGMODE] |= FLAGMODEAC; break;
@@ -512,6 +662,7 @@ class Meter {
default: break; default: break;
} }
// Translate the B35T+ scale selector into SI-prefix flags.
switch (scale) { switch (scale) {
case 2: this->value_[REGSCALE] |= FLAGSCALEMICRO; break; case 2: this->value_[REGSCALE] |= FLAGSCALEMICRO; break;
case 3: this->value_[REGSCALE] |= FLAGSCALEMILLI; break; case 3: this->value_[REGSCALE] |= FLAGSCALEMILLI; break;
@@ -520,6 +671,7 @@ class Meter {
default: break; default: break;
} }
// Second word: status flags such as hold, relative, auto-range, battery, and min/max.
uint16_t pair2 = static_cast<uint16_t>(this->raw_[2]) | (static_cast<uint16_t>(this->raw_[3]) << 8); uint16_t pair2 = static_cast<uint16_t>(this->raw_[2]) | (static_cast<uint16_t>(this->raw_[3]) << 8);
if (pair2 & (1 << 0)) this->value_[REGMODE] |= FLAGMODEHOLD; if (pair2 & (1 << 0)) this->value_[REGMODE] |= FLAGMODEHOLD;
if (pair2 & (1 << 1)) this->value_[REGMODE] |= FLAGMODEREL; if (pair2 & (1 << 1)) this->value_[REGMODE] |= FLAGMODEREL;
@@ -528,6 +680,7 @@ class Meter {
if (pair2 & (1 << 4)) this->value_[REGMINMAX] |= FLAGMIN; if (pair2 & (1 << 4)) this->value_[REGMINMAX] |= FLAGMIN;
if (pair2 & (1 << 5)) this->value_[REGMINMAX] |= FLAGMAX; if (pair2 & (1 << 5)) this->value_[REGMINMAX] |= FLAGMAX;
// Third word: signed 4-digit display value, with bit 15 indicating a negative reading.
uint16_t pair3 = static_cast<uint16_t>(this->raw_[4]) | (static_cast<uint16_t>(this->raw_[5]) << 8); uint16_t pair3 = static_cast<uint16_t>(this->raw_[4]) | (static_cast<uint16_t>(this->raw_[5]) << 8);
if (decimal < 7) { if (decimal < 7) {
uint16_t digits = pair3; uint16_t digits = pair3;
@@ -542,38 +695,72 @@ class Meter {
this->value_[REGDIG3] = '0' + ((digits / 10) % 10); this->value_[REGDIG3] = '0' + ((digits / 10) % 10);
this->value_[REGDIG4] = '0' + (digits % 10); this->value_[REGDIG4] = '0' + (digits % 10);
} else { } else {
// Decimal values 7 and above are used by this protocol to indicate overload/OL.
memcpy(this->value_, OVERLOAD_FRAME, sizeof(OVERLOAD_FRAME)); memcpy(this->value_, OVERLOAD_FRAME, sizeof(OVERLOAD_FRAME));
} }
} }
// Return a printable digit for a display register, using a blank for non-digit status bytes.
char digit_char_(uint8_t reg) const { char digit_char_(uint8_t reg) const {
uint8_t c = this->value_[reg]; uint8_t c = this->value_[reg];
return (c >= '0' && c <= '9') ? static_cast<char>(c) : ' '; return (c >= '0' && c <= '9') ? static_cast<char>(c) : ' ';
} }
// Format Atorch metrics, using "--" for missing values while keeping units visible.
void format_metric_(char *buffer, size_t size, float value, const char *unit, uint8_t decimals) const {
if (!std::isfinite(value)) {
snprintf(buffer, size, "-- %s", unit);
return;
}
char format[12];
snprintf(format, sizeof(format), "%%.%uf %%s", decimals);
snprintf(buffer, size, format, value, unit);
}
// Draw one Atorch dashboard tile with a colored accent, label, and centered numeric value.
void draw_metric_card_(Display &it, esphome::display::BaseFont *label_font, esphome::display::BaseFont *value_font,
int x, int y, int w, int h, const char *title, const char *value,
Color accent, Color fill, Color border, Color value_color) {
const Color bg(0, 0, 0);
const Color inactive(90, 100, 110);
it.filled_rectangle(x, y, w, h, fill);
it.filled_rectangle(x, y, w, 2, accent);
it.filled_rectangle(x, y + h - 1, w, 1, border);
it.filled_rectangle(x, y, 1, h, border);
it.filled_rectangle(x + w - 1, y, 1, h, border);
it.print(x + 10, y + 9, label_font, inactive, esphome::display::TextAlign::TOP_LEFT, title);
it.print(x + w / 2, y + 43, value_font, value_color, esphome::display::TextAlign::CENTER, value);
it.filled_rectangle(x + 10, y + h - 11, w - 20, 3, bg);
it.filled_rectangle(x + 10, y + h - 11, w - 20, 1, accent);
}
// Small wrapper for consistent top-left aligned labels.
void label_(Display &it, esphome::display::BaseFont *font, int x, int y, const char *text, Color color) { void label_(Display &it, esphome::display::BaseFont *font, int x, int y, const char *text, Color color) {
it.print(x, y, font, color, esphome::display::TextAlign::TOP_LEFT, text); it.print(x, y, font, color, esphome::display::TextAlign::TOP_LEFT, text);
} }
// Draw the large four-digit OWON readout, including a separate minus sign when needed.
void draw_digits_(Display &it, const char *text, bool negative, Color color) { void draw_digits_(Display &it, const char *text, bool negative, Color color) {
if (negative) this->draw_segment_(it, 8, 88, 26, 9, true, color); if (negative) this->draw_segment_(it, 8, 83, 26, 9, true, color);
constexpr int digit_x = 40; constexpr int digit_x = 40;
constexpr int digit_y = 35; constexpr int digit_y = 35;
constexpr int digit_w = 50; constexpr int digit_w = 50;
constexpr int digit_h = 88; constexpr int digit_h = 106;
constexpr int digit_distance = 64; constexpr int digit_distance = 64;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
this->draw_seven_segment_(it, digit_x + i * digit_distance, digit_y, digit_w, digit_h, text[i], color); this->draw_seven_segment_(it, digit_x + i * digit_distance, digit_y, digit_w, digit_h, text[i], color);
} }
} }
// Draw decimal points between the large seven-segment digits according to the normalized frame flags.
void draw_decimal_points_(Display &it, Color color) { void draw_decimal_points_(Display &it, Color color) {
uint8_t p = this->value_[REGPOINT]; uint8_t p = this->value_[REGPOINT];
if ((p & FLAGPOINT1) == FLAGPOINT1) it.filled_rectangle(95, 117, 8, 10, color); if ((p & FLAGPOINT1) == FLAGPOINT1) it.filled_rectangle(95, 135, 8, 10, color);
if ((p & FLAGPOINT2) == FLAGPOINT2) it.filled_rectangle(159, 117, 8, 10, color); if ((p & FLAGPOINT2) == FLAGPOINT2) it.filled_rectangle(159, 135, 8, 10, color);
if ((p & FLAGPOINT3) == FLAGPOINT3) it.filled_rectangle(223, 117, 8, 10, color); if ((p & FLAGPOINT3) == FLAGPOINT3) it.filled_rectangle(223, 135, 8, 10, color);
} }
// Draw one beveled horizontal or vertical segment used by the custom seven-segment font.
void draw_segment_(Display &it, int x, int y, int w, int h, bool horizontal, Color color) { void draw_segment_(Display &it, int x, int y, int w, int h, bool horizontal, Color color) {
if (horizontal) { if (horizontal) {
int cap = h / 2; int cap = h / 2;
@@ -588,6 +775,7 @@ class Meter {
} }
} }
// Plot a packed 1-bit bitmap icon, where each set bit becomes one colored display pixel.
void draw_icon_(Display &it, int x, int y, int w, int h, const uint8_t *data, Color color) { void draw_icon_(Display &it, int x, int y, int w, int h, const uint8_t *data, Color color) {
for (int row = 0; row < h; row++) { for (int row = 0; row < h; row++) {
for (int col = 0; col < w; col++) { for (int col = 0; col < w; col++) {
@@ -599,6 +787,7 @@ class Meter {
} }
} }
// Map a digit/OL/minus character to seven segment states and draw the active segments.
void draw_seven_segment_(Display &it, int x, int y, int w, int h, char ch, Color color) { void draw_seven_segment_(Display &it, int x, int y, int w, int h, char ch, Color color) {
bool a=false,b=false,c=false,d=false,e=false,f=false,g=false; bool a=false,b=false,c=false,d=false,e=false,f=false,g=false;
switch (ch) { switch (ch) {
@@ -639,6 +828,7 @@ class Meter {
if (g) this->draw_segment_(it, x + t / 2, mid_y, w - t, t, true, color); if (g) this->draw_segment_(it, x + t / 2, mid_y, w - t, t, true, color);
} }
// Draw the OWON-style bottom bargraph by scaling raw 0..6000 display digits to a 240 px ruler.
void draw_bargraph_(Display &it, uint16_t digits, bool active) { void draw_bargraph_(Display &it, uint16_t digits, bool active) {
const Color fg(255, 255, 255); const Color fg(255, 255, 255);
const Color inactive(80, 80, 80); const Color inactive(80, 80, 80);
+266 -21
View File
@@ -1,6 +1,14 @@
# Connects to an OWON BT35T/BT35T+ multimeter and an Atorch DL24 dc-load and mirrors their
# displays. Also sends those values to Home Assistant for logging and dashboard display.
# Also exposes actionable buttons to HA to control the devices.
#
# Derived work based on https://github.com/reaper7/M5Stack_BLE_client_Owon_B35T by reaper7. # Derived work based on https://github.com/reaper7/M5Stack_BLE_client_Owon_B35T by reaper7.
# AI (ChatGPT) has been used to adopt the Arduino sketch to ESPHome. # AI (ChatGPT (GPT5.5) has been used to adopt the Arduino sketch to ESPHome
# Ported to M5Stack Core2 due to memory constraints. # Ported to M5Stack Core2 due to memory constraints.
# Integrated Atorch BLE proxy functionality from https://github.com/syssi/esphome-atorch-dl24 by syssi.
# Soft buttons work as indicated for OWON meter. Left/right so select action, middle to execute.
# Long-press is supported. Display switches to last connected device, tap center of screen to
# switch. The dc-load has no on-device buttons, but both are available from HA.
substitutions: substitutions:
name: "lab-ble-proxy" name: "lab-ble-proxy"
@@ -17,10 +25,13 @@ esphome:
comment: ${device_description} comment: ${device_description}
min_version: 2024.6.0 min_version: 2024.6.0
includes: includes:
- lab-ble-proxy-owon.h - lab-ble-proxy.h
on_boot: on_boot:
priority: 850 priority: 850
then: then:
# The Core2 LCD/backlight rails are controlled by the AXP192 PMIC. ESPHome's
# stock M5CORE2 display setup does not initialize those rails here, so the
# custom header performs the M5Stack-specific power sequencing once I2C exists.
- lambda: |- - lambda: |-
owon_b35t::core2_axp192_init(id(core2_i2c)); owon_b35t::core2_axp192_init(id(core2_i2c));
project: project:
@@ -68,9 +79,57 @@ wifi:
captive_portal: captive_portal:
globals:
# 0 = OWON meter page, 1 = Atorch DL24 page. This is intentionally volatile so
# every boot starts with the multimeter view until one device connects.
- id: display_page
type: int
initial_value: "0"
restore_value: no
# The Atorch external component does not expose a simple connected flag that the
# display lambda can query, so BLE callbacks maintain this state explicitly.
- id: atorch_connected
type: bool
initial_value: "false"
restore_value: no
script:
- id: wake_backlight
mode: restart
then:
- script.stop: backlight_idle
- light.turn_on:
id: backlight
brightness: 100%
- id: backlight_idle
mode: restart
then:
- delay: 2min
- if:
condition:
# Only dim when both BLE devices are disconnected; active lab instruments
# keep the display fully lit so readings remain visible at a glance.
lambda: |-
return !owon_meter.connected && !id(atorch_connected);
then:
- light.turn_on:
id: backlight
brightness: 70%
- delay: 3min
- if:
condition:
# Re-check before turning the backlight off, because a connection may
# have been established during the preceding delay.
lambda: |-
return !owon_meter.connected && !id(atorch_connected);
then:
- light.turn_off: backlight
interval: interval:
- interval: 10s - interval: 10s
then: then:
# Periodic memory telemetry is useful on the Core2 because BLE, PSRAM, the
# MIPI framebuffer, and external components can fragment different heap pools.
- lambda: |- - lambda: |-
ESP_LOGI("mem", "heap free=%u min_free=%u internal_free=%u internal_largest=%u dma_free=%u dma_largest=%u psram_free=%u psram_largest=%u", ESP_LOGI("mem", "heap free=%u min_free=%u internal_free=%u internal_largest=%u dma_free=%u dma_largest=%u psram_free=%u psram_largest=%u",
static_cast<unsigned>(esp_get_free_heap_size()), static_cast<unsigned>(esp_get_free_heap_size()),
@@ -92,15 +151,61 @@ ble_client:
id: owon_ble_client id: owon_ble_client
on_connect: on_connect:
then: then:
- script.execute: wake_backlight
# Notify the custom parser/display object and switch to the meter page when
# the OWON connects, so the on-device screen follows the active instrument.
- lambda: |- - lambda: |-
owon_meter.on_connect(); owon_meter.on_connect();
id(display_page) = 0;
id(lcd).update();
on_disconnect: on_disconnect:
then: then:
# Keep the UI useful after a disconnect: if the Atorch is still online,
# automatically fall back from the OWON page to the Atorch page.
- lambda: |- - lambda: |-
owon_meter.on_disconnect(); owon_meter.on_disconnect();
if (id(display_page) == 0 && id(atorch_connected)) {
id(display_page) = 1;
}
id(lcd).update();
- if:
condition:
# Start the idle timer only after both BLE clients are gone; otherwise
# the remaining connected instrument still deserves an active display.
lambda: |-
return !owon_meter.connected && !id(atorch_connected);
then:
- script.execute: backlight_idle
- mac_address: ${dl24_mac_address} - mac_address: ${dl24_mac_address}
id: atorch_ble_client id: atorch_ble_client
on_connect:
then:
- script.execute: wake_backlight
# The Atorch component handles measurements, while this explicit flag/page
# switch keeps the shared display state synchronized with the BLE client.
- lambda: |-
id(atorch_connected) = true;
id(display_page) = 1;
id(lcd).update();
on_disconnect:
then:
# If the load disconnects while the meter is still connected, move the
# physical display back to the meter instead of leaving a stale load page.
- lambda: |-
id(atorch_connected) = false;
if (id(display_page) == 1 && owon_meter.connected) {
id(display_page) = 0;
}
id(lcd).update();
- if:
condition:
# Same idle rule as OWON disconnect: only dim/off when neither BLE
# target is connected anymore.
lambda: |-
return !owon_meter.connected && !id(atorch_connected);
then:
- script.execute: backlight_idle
atorch_dl24: atorch_dl24:
- id: atorch0 - id: atorch0
@@ -123,6 +228,8 @@ output:
type: float type: float
id: lcd_backlight id: lcd_backlight
write_action: write_action:
# Bridge ESPHome's generic monochromatic light level to the Core2-specific
# AXP192 backlight voltage helper implemented in lab-ble-proxy.h.
- lambda: |- - lambda: |-
owon_b35t::core2_axp192_set_backlight(state); owon_b35t::core2_axp192_set_backlight(state);
@@ -137,6 +244,8 @@ font:
- file: "fonts/Roboto-Regular.ttf" - file: "fonts/Roboto-Regular.ttf"
id: meter_font id: meter_font
size: 15 size: 15
# Glyphs are whitelisted to save flash/RAM; include symbols used by units,
# status labels, soft-button names, and Atorch metric text.
glyphs: glyphs:
[ [
" ", " ",
@@ -146,6 +255,7 @@ font:
"-", "-",
".", ".",
"/", "/",
":",
"0", "0",
"1", "1",
"2", "2",
@@ -182,6 +292,7 @@ font:
"Y", "Y",
"Z", "Z",
"a", "a",
"b",
"c", "c",
"d", "d",
"e", "e",
@@ -190,9 +301,11 @@ font:
"h", "h",
"i", "i",
"k", "k",
"l",
"m", "m",
"n", "n",
"o", "o",
"p",
"r", "r",
"s", "s",
"t", "t",
@@ -206,20 +319,86 @@ font:
"Ω", "Ω",
] ]
- file: "fonts/Roboto-Medium.ttf"
id: atorch_value_font
size: 22
# Larger Atorch value font only needs numeric characters and measurement units.
glyphs:
[
" ",
"+",
"-",
".",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"C",
"V",
"W",
"h",
"°",
]
display: display:
- platform: mipi_spi - platform: mipi_spi
id: lcd id: lcd
model: M5CORE2 model: M5CORE2
update_interval: 500ms update_interval: 500ms
# Rendering is delegated to the custom C++ helper because ESPHome display YAML
# primitives would be unwieldy for the OWON seven-segment clone and Atorch dashboard.
lambda: |- lambda: |-
owon_meter.render(it, id(meter_font)); owon_meter.render(
it,
id(meter_font),
id(atorch_value_font),
id(display_page),
id(atorch_connected),
id(atorch_voltage).has_state() ? id(atorch_voltage).state : NAN,
id(atorch_current).has_state() ? id(atorch_current).state : NAN,
id(atorch_power).has_state() ? id(atorch_power).state : NAN,
id(atorch_capacity).has_state() ? id(atorch_capacity).state : NAN,
id(atorch_energy_calculated).has_state() ? id(atorch_energy_calculated).state : NAN,
id(atorch_temperature).has_state() ? id(atorch_temperature).state : NAN
);
touchscreen: touchscreen:
- platform: ft63x6 - platform: ft63x6
id: touch id: touch
display: lcd display: lcd
on_touch:
then:
- script.execute: wake_backlight
- if:
condition:
# Touching an idle/disconnected unit wakes the display briefly, then
# restarts the idle timer if no BLE target is available.
lambda: |-
return !owon_meter.connected && !id(atorch_connected);
then:
- script.execute: backlight_idle
binary_sensor: binary_sensor:
- platform: touchscreen
touchscreen_id: touch
id: btn_toggle_page
x_min: 70
x_max: 250
y_min: 45
y_max: 195
on_press:
then:
# The large middle touch zone toggles between the two custom render pages.
- lambda: |-
id(display_page) = 1 - id(display_page);
id(lcd).update();
- platform: touchscreen - platform: touchscreen
id: button_a id: button_a
touchscreen_id: touch touchscreen_id: touch
@@ -230,6 +409,7 @@ binary_sensor:
internal: true internal: true
on_press: on_press:
then: then:
# Left soft button changes which OWON remote command the center button will send.
- lambda: |- - lambda: |-
owon_meter.previous_button(); owon_meter.previous_button();
- platform: touchscreen - platform: touchscreen
@@ -252,6 +432,8 @@ binary_sensor:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# OWON remote-control payload: first byte selects the meter button,
# second byte selects the normal/short-press action variant.
value: !lambda |- value: !lambda |-
std::vector<uint8_t> data = {owon_meter.selected_button, 0x01}; std::vector<uint8_t> data = {owon_meter.selected_button, 0x01};
return data; return data;
@@ -266,6 +448,8 @@ binary_sensor:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# Long-press encoding is not uniform: SELECT and HZ/DUTY still use
# 0x01, while RANGE/HOLD/REL/MAX-MIN use 0x00 for their alternate action.
value: !lambda |- value: !lambda |-
uint8_t press_type = (owon_meter.selected_button == 1 || owon_meter.selected_button == 5) ? 0x01 : 0x00; uint8_t press_type = (owon_meter.selected_button == 1 || owon_meter.selected_button == 5) ? 0x01 : 0x00;
std::vector<uint8_t> data = {owon_meter.selected_button, press_type}; std::vector<uint8_t> data = {owon_meter.selected_button, press_type};
@@ -280,28 +464,36 @@ binary_sensor:
internal: true internal: true
on_press: on_press:
then: then:
# Right soft button advances to the next OWON command label.
- lambda: |- - lambda: |-
owon_meter.next_button(); owon_meter.next_button();
- platform: template - platform: template
name: "${friendly_name} OWON Connected" name: "${friendly_name} OWON Connected"
icon: "mdi:bluetooth-connect"
# Template binary sensors expose state maintained by the custom OWON parser object.
lambda: |- lambda: |-
return owon_meter.connected; return owon_meter.connected;
- platform: template - platform: template
name: "${friendly_name} OWON Overload" name: "${friendly_name} OWON Overload"
icon: "mdi:debug-step-over"
lambda: |- lambda: |-
return owon_meter.overload; return owon_meter.overload;
- platform: template - platform: template
name: "${friendly_name} OWON Low Battery" name: "${friendly_name} OWON Low Battery"
icon: "mdi:battery-low"
lambda: |- lambda: |-
return owon_meter.low_battery; return owon_meter.low_battery;
- platform: template
- platform: atorch_dl24 name: "${friendly_name} Atorch Connected"
atorch_dl24_id: atorch0 device_class: connectivity
running: icon: "mdi:bluetooth-connect"
name: "${friendly_name} Atorch Running" lambda: |-
return id(atorch_connected);
sensor: sensor:
# This hidden characteristic sensor is the bridge from OWON BLE notifications into
# custom C++ parsing. The returned float becomes the source numeric meter reading.
- platform: ble_client - platform: ble_client
type: characteristic type: characteristic
ble_client_id: owon_ble_client ble_client_id: owon_ble_client
@@ -323,54 +515,77 @@ sensor:
atorch_dl24_id: atorch0 atorch_dl24_id: atorch0
voltage: voltage:
name: "${friendly_name} Atorch Voltage" name: "${friendly_name} Atorch Voltage"
id: atorch_voltage
current: current:
name: "${friendly_name} Atorch Current" name: "${friendly_name} Atorch Current"
id: atorch_current
power: power:
name: "${friendly_name} Atorch Power" name: "${friendly_name} Atorch Power"
id: atorch_power
capacity: capacity:
name: "${friendly_name} Atorch Capacity" name: "${friendly_name} Atorch Capacity"
energy: id: atorch_capacity
name: "${friendly_name} Atorch Energy"
temperature: temperature:
name: "${friendly_name} Atorch Temperature" name: "${friendly_name} Atorch Temperature"
id: atorch_temperature
dim_backlight: dim_backlight:
name: "${friendly_name} Atorch Dim Backlight" name: "${friendly_name} Atorch Dim Backlight"
runtime: id: atorch_dim_backlight
name: "${friendly_name} Atorch Runtime"
# The DL24 component exposes power, but this config computes Wh locally so the
# accumulated energy can be restored and reset alongside Atorch's own counters.
- platform: integration
name: "${friendly_name} Atorch Energy"
id: atorch_energy_calculated
sensor: atorch_power
time_unit: h
unit_of_measurement: "Wh"
icon: "mdi:lightning-bolt"
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
restore: true
integration_method: trapezoid
text_sensor: text_sensor:
- platform: template - platform: template
name: "${friendly_name} OWON Reading" name: "${friendly_name} OWON Reading"
update_interval: 1s update_interval: 1s
icon: "mdi:gauge"
# Human-readable mirror of the meter LCD, including waiting/disconnected/OL states.
lambda: |- lambda: |-
return owon_meter.reading_text(); return owon_meter.reading_text();
- platform: template - platform: template
name: "${friendly_name} OWON Unit" name: "${friendly_name} OWON Unit"
update_interval: 1s update_interval: 1s
icon: "mdi:ruler"
# Combines SI prefix and unit into one HA text entity, e.g. mV, kΩ, µA, %.
lambda: |- lambda: |-
return std::string(owon_meter.scale()) + owon_meter.unit(); return std::string(owon_meter.scale()) + owon_meter.unit();
- platform: template - platform: template
name: "${friendly_name} OWON Mode" name: "${friendly_name} OWON Mode"
icon: "mdi:knob"
update_interval: 1s update_interval: 1s
# Exposes decoded annunciators such as AC/DC, AUTO, HOLD, REL, MIN/MAX.
lambda: |- lambda: |-
return owon_meter.mode_text(); return owon_meter.mode_text();
- platform: atorch_dl24
atorch_dl24_id: atorch0
runtime_formatted:
name: "${friendly_name} Atorch Runtime Formatted"
button: button:
- platform: atorch_dl24 - platform: atorch_dl24
atorch_dl24_id: atorch0 atorch_dl24_id: atorch0
reset_energy: reset_energy:
name: "${friendly_name} Atorch Reset Energy" name: "${friendly_name} Atorch Reset Energy"
on_press:
- sensor.integration.reset: atorch_energy_calculated
reset_capacity: reset_capacity:
name: "${friendly_name} Atorch Reset Capacity" name: "${friendly_name} Atorch Reset Capacity"
reset_runtime: reset_runtime:
name: "${friendly_name} Atorch Reset Runtime" name: "${friendly_name} Atorch Reset Runtime"
reset_all: reset_all:
name: "${friendly_name} Atorch Reset All" name: "${friendly_name} Atorch Reset All"
on_press:
# Keep the locally integrated Wh counter in sync with the DL24 reset-all command.
- sensor.integration.reset: atorch_energy_calculated
usb_plus: usb_plus:
name: "${friendly_name} Atorch Plus" name: "${friendly_name} Atorch Plus"
usb_minus: usb_minus:
@@ -379,6 +594,8 @@ button:
name: "${friendly_name} Atorch Setup" name: "${friendly_name} Atorch Setup"
enter: enter:
name: "${friendly_name} Atorch Enter" name: "${friendly_name} Atorch Enter"
# Home Assistant button entities for direct OWON remote commands. The payloads
# are the same two-byte command format used by the touchscreen soft buttons.
- platform: template - platform: template
name: "OWON SELECT" name: "OWON SELECT"
id: owon_btn_select id: owon_btn_select
@@ -387,6 +604,7 @@ button:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# SELECT normal press.
value: !lambda "return std::vector<uint8_t>({1, 0x01});" value: !lambda "return std::vector<uint8_t>({1, 0x01});"
- platform: template - platform: template
@@ -397,44 +615,71 @@ button:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# RANGE normal press.
value: !lambda "return std::vector<uint8_t>({2, 0x01});" value: !lambda "return std::vector<uint8_t>({2, 0x01});"
- platform: template - platform: template
name: "OWON HLD/LIG" name: "OWON HOLD "
id: owon_btn_hold id: owon_btn_hold
on_press: on_press:
- ble_client.ble_write: - ble_client.ble_write:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# HOLD is the short/normal action on the shared HLD/LIG physical key.
value: !lambda "return std::vector<uint8_t>({3, 0x01});" value: !lambda "return std::vector<uint8_t>({3, 0x01});"
- platform: template - platform: template
name: "OWON REL/BT" name: "OWON LIGHT"
id: owon_btn_light
on_press:
- ble_client.ble_write:
id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# LIGHT is the alternate/long action on the same HLD/LIG key.
value: !lambda "return std::vector<uint8_t>({3, 0x00});"
- platform: template
name: "OWON RELATIVE"
id: owon_btn_rel id: owon_btn_rel
on_press: on_press:
- ble_client.ble_write: - ble_client.ble_write:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# RELATIVE is the short/normal action on the shared REL/BT key.
value: !lambda "return std::vector<uint8_t>({4, 0x01});" value: !lambda "return std::vector<uint8_t>({4, 0x01});"
- platform: template - platform: template
name: "OWON HZ/DUTY" name: "OWON BT"
id: owon_btn_bt
on_press:
- ble_client.ble_write:
id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# BT is the alternate/long action on the same REL/BT key.
value: !lambda "return std::vector<uint8_t>({4, 0x00});"
- platform: template
name: "OWON HZ | DUTY"
id: owon_btn_hz id: owon_btn_hz
on_press: on_press:
- ble_client.ble_write: - ble_client.ble_write:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# HZ/DUTY command uses the normal action variant.
value: !lambda "return std::vector<uint8_t>({5, 0x01});" value: !lambda "return std::vector<uint8_t>({5, 0x01});"
- platform: template - platform: template
name: "OWON MAX/MIN" name: "OWON MAX | MIN"
id: owon_btn_maxmin id: owon_btn_maxmin
on_press: on_press:
- ble_client.ble_write: - ble_client.ble_write:
id: owon_ble_client id: owon_ble_client
service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb" service_uuid: "0000fff0-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb" characteristic_uuid: "0000fff3-0000-1000-8000-00805f9b34fb"
# MAX/MIN command uses the normal action variant.
value: !lambda "return std::vector<uint8_t>({6, 0x01});" value: !lambda "return std::vector<uint8_t>({6, 0x01});"
+28 -2
View File
@@ -139,8 +139,34 @@
attributes: attributes:
last_reset: '1970-01-01T00:00:00+00:00' last_reset: '1970-01-01T00:00:00+00:00'
- name: internet_speed_out - name: internet_speed_out
unique_id: '9519483670667'
state: > state: >
{{ (( states('sensor.wan_out_derivative') | float * 8 / 1000000 ) | round(2)) }} {{ (( states('sensor.wan_out_derivative') | float * 8 / 1000000 ) | round(2)) }}
unit_of_measurement: 'Mbps' unit_of_measurement: 'Mbps'
attributes:
last_reset: '1970-01-01T00:00:00+00:00' # ── Kalender-Ereignisse für epaperframe ──
# Alle Events werden per Automation (automations.yaml) in input_text Helfer geschrieben.
# Diese template sensors lesen nur noch daraus. Das verhindert doppelte Logik und garantiert,
# dass sowohl "heute" als auch "morgen" Events mit Titeln, Uhrzeiten und Beschreibungen verfügbar sind.
- text_sensor:
# ── HEUTE ──
- name: "Kalender heute Privat"
unique_id: kalender_heute_privat
state: "{{ states('input_text.kalender_heute_privat') }}"
icon: mdi:calendar-account
- name: "Kalender heute Arbeit"
unique_id: kalender_heute_arbeit
state: "{{ states('input_text.kalender_heute_arbeit') }}"
icon: mdi:calendar-account
# ── MORGEN ──
- name: "Kalender morgen Privat"
unique_id: kalender_morgen_privat
state: "{{ states('input_text.kalender_morgen_privat') }}"
icon: mdi:calendar-calendar-today
- name: "Kalender morgen Arbeit"
unique_id: kalender_morgen_arbeit
state: "{{ states('input_text.kalender_morgen_arbeit') }}"
icon: mdi:calendar-calendar-today
+18
View File
@@ -0,0 +1,18 @@
# Helpers for epaperframe calendar display
input_text:
- name: "Kalender heute Privat"
initial: "-"
icon: mdi:calendar-account
mode: text
- name: "Kalender heute Arbeit"
initial: "-"
icon: mdi:calendar-account
mode: text
- name: "Kalender morgen Privat"
initial: "-"
icon: mdi:calendar-calendar-today
mode: text
- name: "Kalender morgen Arbeit"
initial: "-"
icon: mdi:calendar-calendar-today
mode: text