31 changed files with 142 additions and 2716 deletions
+1 -1
View File
@@ -1 +1 @@
2026.9.3 2026.7.2
+9 -43
View File
@@ -70,9 +70,8 @@
action: light.turn_off action: light.turn_off
mode: single mode: single
- id: '1623673821789' - id: '1623673821789'
alias: Schlafen gehen alias: Gute Nacht!
description: Schalte alles (außer Schlafzimmer) aus und schließ die Wohnungstür, description: Schalte alles (außer Schlafzimmer) aus, sobald das Schlaftracking startet.
sobald das Schlaftracking startet.
triggers: triggers:
- trigger: state - trigger: state
entity_id: entity_id:
@@ -96,11 +95,6 @@
device_id: 6d1be741876624a70ab5b01b54c6fd6f device_id: 6d1be741876624a70ab5b01b54c6fd6f
entity_id: switch.kuche_musik entity_id: switch.kuche_musik
domain: switch domain: switch
- action: lock.lock
metadata: {}
target:
entity_id: lock.flur_wohnungstur
data: {}
- data: - data:
message: Gute Nacht! message: Gute Nacht!
action: notify.mobile_app_le2123 action: notify.mobile_app_le2123
@@ -257,7 +251,7 @@
action: tts.speak action: tts.speak
mode: single mode: single
- id: '1623954512941' - id: '1623954512941'
alias: Aufwachen alias: Licht im Schlafzimmer zum Aufwachen einschalten
description: Nach der Alarmquittierung description: Nach der Alarmquittierung
triggers: triggers:
- trigger: state - trigger: state
@@ -279,11 +273,6 @@
device_id: 68868390eda35e969ec60a13020f2407 device_id: 68868390eda35e969ec60a13020f2407
data: {} data: {}
action: light.turn_on action: light.turn_on
- action: lock.unlock
metadata: {}
target:
entity_id: lock.flur_wohnungstur
data: {}
mode: single mode: single
- id: '1624820688449' - id: '1624820688449'
alias: 'Anruf: Beim Klingeln grün blinken' alias: 'Anruf: Beim Klingeln grün blinken'
@@ -450,7 +439,7 @@
action: light.turn_on action: light.turn_on
mode: single mode: single
- id: '1630914505161' - id: '1630914505161'
alias: Wohnung verlassen alias: Beim Verlassen der Wohnung alles abschalten
description: '' description: ''
triggers: triggers:
- entity_id: person.marcus_scholz - entity_id: person.marcus_scholz
@@ -486,11 +475,6 @@
device_id: device_id:
- 231cd7ec37e32690faf126105b03ee02 - 231cd7ec37e32690faf126105b03ee02
- a6d24e7d93c114723bf525e9eac1c2df - a6d24e7d93c114723bf525e9eac1c2df
- action: lock.lock
metadata: {}
target:
entity_id: lock.flur_wohnungstur
data: {}
- type: turn_off - type: turn_off
device_id: c4ead7f6227e2ee4c43c4b0df829cd84 device_id: c4ead7f6227e2ee4c43c4b0df829cd84
entity_id: 7f7284b11f2bf50ae2f0ebeeb35411c0 entity_id: 7f7284b11f2bf50ae2f0ebeeb35411c0
@@ -1454,6 +1438,7 @@
device_id: 6d1be741876624a70ab5b01b54c6fd6f device_id: 6d1be741876624a70ab5b01b54c6fd6f
entity_id: 621e4377a089b7f5d92c7c9f2cc171a1 entity_id: 621e4377a089b7f5d92c7c9f2cc171a1
domain: switch domain: switch
- id: epaper_daily_demotivational_quote - id: epaper_daily_demotivational_quote
alias: Epaper tägliches Demotivationszitat alias: Epaper tägliches Demotivationszitat
description: Wählt täglich ein festes Zitat aus der lokalen Zitatbibliothek aus. description: Wählt täglich ein festes Zitat aus der lokalen Zitatbibliothek aus.
@@ -1461,33 +1446,14 @@
- trigger: homeassistant - trigger: homeassistant
event: start event: start
- trigger: time - trigger: time
at: 00:00:00 at: "00:00:00"
conditions: [] conditions: []
actions: actions:
- action: input_select.select_option - action: input_select.select_option
target: target:
entity_id: input_select.epaper_demotivationszitat entity_id: input_select.epaper_demotivationszitat
data: data:
option: '{% set quotes = state_attr(''input_select.epaper_demotivationszitat'', option: >-
''options'') %} {{ quotes[(now().strftime(''%j'') | int - 1) % (quotes | count)] {% set quotes = state_attr('input_select.epaper_demotivationszitat', 'options') %}
}}' {{ quotes[(now().strftime('%j') | int - 1) % (quotes | count)] }}
mode: single
- id: '1785863986502'
alias: SmartMirror neu laden
description: ''
triggers:
- trigger: time
at: 00:00:10
conditions: []
actions:
- action: button.press
metadata: {}
target:
entity_id: button.touchkio_smartmirror_refresh
data: {}
- action: button.press
metadata: {}
target:
entity_id: button.touchkio_raspberrypi_refresh
data: {}
mode: single mode: single
+8
View File
@@ -1,6 +1,12 @@
# Configure a default setup of Home Assistant (frontend, api, etc) # Configure a default setup of Home Assistant (frontend, api, etc)
default_config: default_config:
# Enable SSL/TLS
http:
server_port: 443
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
# Text to speech # Text to speech
tts: tts:
- platform: picotts_remote - platform: picotts_remote
@@ -85,3 +91,5 @@ frontend:
freedns: freedns:
url: !secret freedns6_url url: !secret freedns6_url
# - name: IPv4
# url: !secret freedns4_url
+2 -2
View File
@@ -4,7 +4,7 @@ substitutions:
external_components_source: github://syssi/esphome-atorch-dl24@main external_components_source: github://syssi/esphome-atorch-dl24@main
dl24_mac_address: !secret dl24_mac_address dl24_mac_address: !secret dl24_mac_address
project_version: 2.1.0 project_version: 2.1.0
device_description: "ESP32-S3 BLE client to monitor and control an Atorch DL24 programmable DC load" device_description: "Monitor and control a Atorch meter via bluetooth BLE"
esphome: esphome:
name: ${name} name: ${name}
@@ -36,7 +36,7 @@ api:
# Enable over-the-air updates # Enable over-the-air updates
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
network: network:
enable_ipv6: true enable_ipv6: true
+1 -3
View File
@@ -1,12 +1,10 @@
substitutions: substitutions:
name: "aussensensor" name: "aussensensor"
friendly_name: "Außensensor" friendly_name: "Außensensor"
device_description: "NodeMCU-32S outdoor temperature and humidity sensor using a DHT22"
esphome: esphome:
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
comment: ${device_description}
name_add_mac_suffix: false name_add_mac_suffix: false
project: project:
name: sensor.outdoor name: sensor.outdoor
@@ -42,7 +40,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# DHT22 sensor # DHT22 sensor
sensor: sensor:
+1 -1
View File
@@ -31,7 +31,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
+1 -1
View File
@@ -46,7 +46,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
wifi: wifi:
ssid: "Voltage-legacy" ssid: "Voltage-legacy"
+1 -3
View File
@@ -3,7 +3,6 @@
substitutions: substitutions:
name: "raspiaudio-muse-luxe" name: "raspiaudio-muse-luxe"
friendly_name: "RaspiAudio Muse Luxe" friendly_name: "RaspiAudio Muse Luxe"
device_description: "RaspiAudio Muse Luxe ESP32 voice assistant and media player with local wake-word detection, ES8388 audio codec and battery monitoring"
#States #States
P_starting: "0" P_starting: "0"
P_waiting: "1" P_waiting: "1"
@@ -19,7 +18,7 @@ api:
ota: ota:
- platform: esphome - platform: esphome
id: ota_esphome id: ota_esphome
encryption: password: !secret ota
external_components: external_components:
- source: github://RASPIAUDIO/esphomeLuxe@main - source: github://RASPIAUDIO/esphomeLuxe@main
@@ -44,7 +43,6 @@ wifi:
esphome: esphome:
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
comment: ${device_description}
min_version: 2025.2.0 min_version: 2025.2.0
name_add_mac_suffix: false name_add_mac_suffix: false
platformio_options: platformio_options:
+1 -3
View File
@@ -1,12 +1,10 @@
substitutions: substitutions:
name: "sleepingroom" name: "sleepingroom"
friendly_name: "Luftqualität Schlafzimmer" friendly_name: "Luftqualität Schlafzimmer"
device_description: "NodeMCU-32S bedroom air-quality monitor with SCD30 CO2, temperature and humidity, PM1006 particulate sensing, RGB status LED and IR receiver/transmitter"
esphome: esphome:
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
comment: ${device_description}
name_add_mac_suffix: false name_add_mac_suffix: false
project: project:
name: sensor.${name} name: sensor.${name}
@@ -82,7 +80,7 @@ api:
# Enable over-the-air updates # Enable over-the-air updates
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
+1 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
device_description: "ESP32-C3 bathroom temperature and humidity monitor with DHT22 and SHT3x sensors"
name: "bathroom" name: "bathroom"
friendly_name: "Bad" friendly_name: "Bad"
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -46,7 +44,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
-82
View File
@@ -1,82 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.components import time as time_
from esphome.const import CONF_ID, CONF_NUMBER, PLATFORM_ESP32
CODEOWNERS = ["@misterblack1"]
ESP_PLATFORMS = [PLATFORM_ESP32]
aip33628_ns = cg.esphome_ns.namespace("aip33628")
Aip33628Panel = aip33628_ns.class_("Aip33628Panel", cg.Component)
CONF_CLK_PIN = "clk_pin"
CONF_DATA_PIN = "data_pin"
CONF_CLK2_PIN = "clk2_pin"
CONF_DATA2_PIN = "data2_pin"
CONF_TIME_ID = "time_id"
CONF_MAX_CURRENT = "max_current"
CONF_TWELVE_HOUR = "twelve_hour"
CONF_BLINK_COLON = "blink_colon"
def _low_bank_pin(value):
"""Both buses are clocked from one write to the low GPIO output register.
That register only reaches GPIO0 to GPIO31. A pin above that would need a
second register and a second store per edge, which is most of the reason
the frame send is fast enough to subdivide a COM slot at all.
"""
pin = value[CONF_NUMBER]
if pin >= 32:
raise cv.Invalid(
f"GPIO{pin} is above GPIO31, and the display scan drives all four "
"lines from the low output register. Pick a pin below GPIO32."
)
return value
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(Aip33628Panel),
cv.Required(CONF_CLK_PIN): cv.All(
pins.internal_gpio_output_pin_schema, _low_bank_pin
),
cv.Required(CONF_DATA_PIN): cv.All(
pins.internal_gpio_output_pin_schema, _low_bank_pin
),
cv.Required(CONF_CLK2_PIN): cv.All(
pins.internal_gpio_output_pin_schema, _low_bank_pin
),
cv.Required(CONF_DATA2_PIN): cv.All(
pins.internal_gpio_output_pin_schema, _low_bank_pin
),
cv.Optional(CONF_TIME_ID): cv.use_id(time_.RealTimeClock),
# A fixed ceiling on IS[3:0]. It must not depend on what is on screen,
# or the whole panel changes brightness whenever the colon blinks.
cv.Optional(CONF_MAX_CURRENT, default=15): cv.int_range(min=0, max=15),
# Power on defaults only. Home Assistant owns both at run time
# through the template switches in clock.yaml.
cv.Optional(CONF_TWELVE_HOUR, default=True): cv.boolean,
cv.Optional(CONF_BLINK_COLON, default=True): cv.boolean,
}
).extend(cv.COMPONENT_SCHEMA)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
clk = await cg.gpio_pin_expression(config[CONF_CLK_PIN])
data = await cg.gpio_pin_expression(config[CONF_DATA_PIN])
clk2 = await cg.gpio_pin_expression(config[CONF_CLK2_PIN])
data2 = await cg.gpio_pin_expression(config[CONF_DATA2_PIN])
cg.add(var.set_pins(clk, data, clk2, data2))
if CONF_TIME_ID in config:
rtc = await cg.get_variable(config[CONF_TIME_ID])
cg.add(var.set_time(rtc))
cg.add(var.set_max_current(config[CONF_MAX_CURRENT]))
cg.add(var.set_twelve_hour(config[CONF_TWELVE_HOUR]))
cg.add(var.set_blink_colon(config[CONF_BLINK_COLON]))
-917
View File
@@ -1,917 +0,0 @@
#include "aip33628.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include <cmath>
#include <driver/gptimer.h>
#include <soc/gpio_struct.h>
namespace esphome {
namespace aip33628 {
static const char *const TAG = "aip33628";
// Each digit is one driver plus one pair of COM pairs, ten LED positions.
// Driver 1 carries the hours, driver 2 the minutes.
struct Block {
uint8_t drv;
uint8_t com_lo;
uint8_t com_hi;
};
static const Block BLOCKS[4] = {
{0, 0x30, 0xC0}, // hour tens, annunciator AM
{0, 0x03, 0x0C}, // hour ones, annunciator colon
{1, 0x30, 0xC0}, // minute tens, annunciator date dash
{1, 0x03, 0x0C}, // minute ones, annunciator degree mark
};
// Segment position within a block. Side 0 is COM low, side 1 is COM high.
struct SegPos {
uint8_t side;
uint8_t led;
};
static const SegPos SEGMAP[9] = {
{1, 5}, // A top
{1, 4}, // B top right
{1, 3}, // C bottom right
{1, 2}, // D bottom
{0, 5}, // E bottom left
{0, 4}, // F top left
{0, 3}, // G middle
{1, 1}, // annunciator
{0, 1}, // second annunciator, block 1 colon only
};
enum { SEG_ANNUN = 7, SEG_ANNUN2 = 8 };
// Physical position of every LED, extracted in docs/led-layout.md. The ids
// are the ones on the board layout map. Order matches SEGMAP.
const PosGeom GEOM[4][9] = {
{ // block 0, hour tens
{ 1, 19, 8}, // A top
{ 7, 41, 66}, // B top right
{ 6, 40, 194}, // C bottom right
{ 5, 19, 255}, // D bottom
{ 4, 0, 188}, // E bottom left
{ 2, 0, 66}, // F top left
{ 3, 20, 130}, // G middle
{ 8, 20, 65}, // AM mark
{0, 0, 0}, // unwired
},
{ // block 1, hour ones
{ 9, 93, 0}, // A top
{15, 112, 61}, // B top right
{14, 111, 198}, // C bottom right
{13, 90, 246}, // D bottom
{12, 72, 184}, // E bottom left
{10, 73, 65}, // F top left
{11, 92, 124}, // G middle
{16, 128, 68}, // colon upper
{18, 129, 189}, // colon lower
},
{ // block 2, minute tens
{19, 163, 5}, // A top
{25, 185, 67}, // B top right
{24, 185, 195}, // C bottom right
{23, 165, 247}, // D bottom
{22, 145, 188}, // E bottom left
{20, 143, 70}, // F top left
{21, 164, 122}, // G middle
{17, 128, 128}, // date dash
{0, 0, 0}, // unwired
},
{ // block 3, minute ones
{27, 233, 11}, // A top
{33, 255, 60}, // B top right
{32, 255, 190}, // C bottom right
{31, 234, 249}, // D bottom
{30, 216, 194}, // E bottom left
{28, 216, 68}, // F top left
{29, 235, 128}, // G middle
{26, 204, 18}, // degree mark
{0, 0, 0}, // unwired
},
};
// Seven segment font, bit 0 = A through bit 6 = G. The letters are the subset
// that reads unambiguously on seven segments, so a caller can put a unit or a
// short label in the rightmost position.
static uint8_t glyph(char c) {
switch (c) {
case 'A': return 0b1110111;
case 'b': return 0b1111100;
case 'C': return 0b0111001;
case 'c': return 0b1011000;
case 'd': return 0b1011110;
case 'E': return 0b1111001;
case 'F': return 0b1110001;
case 'H': return 0b1110110;
case 'h': return 0b1110100;
case 'L': return 0b0111000;
case 'n': return 0b1010100;
case 'o': return 0b1011100;
case 'P': return 0b1110011;
case 'r': return 0b1010000;
case 't': return 0b1111000;
case 'U': return 0b0111110;
case 'u': return 0b0011100;
case 'y': return 0b1101110;
case '0': return 0b0111111;
case '1': return 0b0000110;
case '2': return 0b1011011;
case '3': return 0b1001111;
case '4': return 0b1100110;
case '5': return 0b1101101;
case '6': return 0b1111101;
case '7': return 0b0000111;
case '8': return 0b1111111;
case '9': return 0b1101111;
case '-': return 0b1000000;
default: return 0;
}
}
// Home Assistant sends gamma encoded values and the panel is linear in
// current and in duty, so both have to be linearized here. 2.8 is the same
// exponent ESPHome uses by default, which is why gamma_correct is set to 1.0
// on the light itself. Applying it in both places would square it.
static const float PANEL_GAMMA = 2.8f;
// Slider position to a current step. A plain gamma curve assumes the output
// can reach zero. This panel bottoms out at IS_MA[0], so a third of the
// slider ends up clamped against that floor with nothing to show for it.
// Interpolating perceived output between the floor and full instead puts all
// sixteen steps across the whole slider.
static uint8_t current_for(float brightness) {
const float p_min = powf((float) IS_MA[0] / (float) IS_MA[15], 1.0f / PANEL_GAMMA);
float p = p_min + clamp(brightness, 0.0f, 1.0f) * (1.0f - p_min);
float want = powf(p, PANEL_GAMMA) * (float) IS_MA[15];
uint8_t best = 0;
for (uint8_t i = 1; i < 16; i++) {
if (fabsf((float) IS_MA[i] - want) < fabsf((float) IS_MA[best] - want))
best = i;
}
return best;
}
// Half brightness keeps the all-white hardware check brief and predictable.
static const float LAMP_BRIGHTNESS = 0.5f;
// Color component to a duty level. Duty is linear light, so the component
// has to be linearized before it is rounded, or every pastel rounds up to a
// saturated color. Pink is the clearest case, and rounds all the way to
// white.
static uint8_t duty_level(float c) {
return (uint8_t) lroundf(powf(clamp(c, 0.0f, 1.0f), PANEL_GAMMA) * (COLOR_LEVELS - 1));
}
static int com_index(uint8_t cs) {
for (int i = 0; i < 4; i++) {
if (COM_SEQ[i] == cs) return i;
}
return 0;
}
void Aip33628Panel::setup() {
for (auto *p : {clk_, data_, clk2_, data2_}) {
p->setup();
p->digital_write(false);
}
clk_mask_ = 1u << clk_->get_pin();
data_mask_ = 1u << data_->get_pin();
clk2_mask_ = 1u << clk2_->get_pin();
data2_mask_ = 1u << data2_->get_pin();
render_();
// A general purpose timer, not esp_timer. The esp_timer task dispatch path
// runs at task priority on core 0 alongside the WiFi task, which preempts
// it and stretches whichever COM slot happens to be lit. A 40us sub-frame
// does not ride that out, so this runs from the interrupt instead.
gptimer_config_t tcfg = {};
tcfg.clk_src = GPTIMER_CLK_SRC_DEFAULT;
tcfg.direction = GPTIMER_COUNT_UP;
tcfg.resolution_hz = 1000000; // one tick per microsecond
gptimer_alarm_config_t acfg = {};
acfg.alarm_count = UNIT_US; // fixed, one tick per binary weight unit
acfg.reload_count = 0;
acfg.flags.auto_reload_on_alarm = true;
gptimer_event_callbacks_t cbs = {};
cbs.on_alarm = &Aip33628Panel::scan_tick_;
gptimer_handle_t timer = nullptr;
if (gptimer_new_timer(&tcfg, &timer) != ESP_OK ||
gptimer_register_event_callbacks(timer, &cbs, this) != ESP_OK ||
gptimer_set_alarm_action(timer, &acfg) != ESP_OK ||
gptimer_enable(timer) != ESP_OK || gptimer_start(timer) != ESP_OK) {
ESP_LOGE(TAG, "could not start the scan timer");
this->mark_failed();
}
}
void Aip33628Panel::dump_config() {
ESP_LOGCONFIG(TAG, "AiP33628 panel:");
LOG_PIN(" CLK: ", clk_);
LOG_PIN(" DATA: ", data_);
LOG_PIN(" CLK_1: ", clk2_);
LOG_PIN(" DATA_1: ", data2_);
ESP_LOGCONFIG(TAG, " Max current: IS 0x%X, %u.%umA per lit sink", max_current_,
IS_MA[max_current_] / 10, IS_MA[max_current_] % 10);
ESP_LOGCONFIG(TAG, " Hour format: %s", twelve_hour_ ? "12 hour" : "24 hour");
ESP_LOGCONFIG(TAG, " Colon: %s", blink_colon_ ? "blinking" : "steady");
ESP_LOGCONFIG(TAG, " Network: %s", online_ ? "up" : "down");
const char *fx = effect_ == Effect::CYCLE ? "color cycle"
: effect_ == Effect::FLASH ? "flash" : "none";
const char *sp = spread_ == Spread::DIGIT ? "per digit"
: spread_ == Spread::LED ? "per LED" : "whole panel";
// INFO rather than LOGCONFIG on purpose. The rest of this block is wiring
// that cannot change, but the effect is live state worth being able to read
// back, and CONFIG level messages need a DEBUG logger to be visible at all.
ESP_LOGI(TAG, " Effect: %s, %s, %.1fs, axis %.0f deg, hue span %.0f deg, flash fade %.2fs",
fx, sp, effect_speed_, effect_angle_, hue_span_, flash_fade_);
}
// Emit one 30-bit frame to each driver and latch both. Bits are LSB first:
// SS[15:0], CS[7:0], IS[3:0], then two reserved zeros. Data only changes
// while CLK is low. The latch is a DATA rising edge while CLK is held high
// after the last bit, which is the sequence the stock 8051 produces.
//
// CS and IS are common to the two drivers and only SS differs, so one pass
// down the bits clocks both buses. That halves the work outright, and going
// straight to the port registers rather than through ISRInternalGPIOPin took
// the pair from 28.0us to 6.4us. The AiP33628 accepts 30MHz and asks for
// 16ns of CLK high and low, and a store to the GPIO port costs more than
// that on its own, so the loop needs no padding.
void IRAM_ATTR Aip33628Panel::send_pair_(uint16_t ss1, uint16_t ss2, uint8_t cs, uint8_t is) {
const uint32_t wire = (uint32_t) IS_WIRE[is & 0xF] << 24;
uint32_t f1 = (uint32_t) ss1 | ((uint32_t) cs << 16) | wire;
uint32_t f2 = (uint32_t) ss2 | ((uint32_t) cs << 16) | wire;
const uint32_t clks = clk_mask_ | clk2_mask_;
const uint32_t dats = data_mask_ | data2_mask_;
// Chip differentiation for the initial register reset
#if defined(CONFIG_IDF_TARGET_ESP32C3)
GPIO.out_w1tc.val = clks | dats;
#else
GPIO.out_w1tc = clks | dats;
#endif
for (int i = 0; i < 30; i++) {
uint32_t set = 0;
if (f1 & 1)
set |= data_mask_;
if (f2 & 1)
set |= data2_mask_;
f1 >>= 1;
f2 >>= 1;
// Data transmission loop
#if defined(CONFIG_IDF_TARGET_ESP32C3)
GPIO.out_w1tc.val = dats & ~set;
GPIO.out_w1ts.val = set;
GPIO.out_w1ts.val = clks;
if (i < 29)
GPIO.out_w1tc.val = clks;
#else
GPIO.out_w1tc = dats & ~set;
GPIO.out_w1ts = set;
GPIO.out_w1ts = clks;
if (i < 29)
GPIO.out_w1tc = clks;
#endif
}
// Final latch sequence
#if defined(CONFIG_IDF_TARGET_ESP32C3)
GPIO.out_w1tc.val = dats;
GPIO.out_w1ts.val = dats;
GPIO.out_w1tc.val = dats;
GPIO.out_w1tc.val = clks;
#else
GPIO.out_w1tc = dats;
GPIO.out_w1ts = dats;
GPIO.out_w1tc = dats;
GPIO.out_w1tc = clks;
#endif
}
// Walk the schedule the renderer built. The timer runs at a fixed UNIT_US
// and this counts ticks, rather than reprogramming the alarm per step.
// Reprogramming would be fewer interrupts, but an alarm set shorter than the
// counter has already reached never matches, and a single late interrupt
// would then freeze the panel until reboot. A fixed auto-reload alarm cannot
// do that: a late interrupt costs one wobbly sub-frame and nothing more.
//
// Most ticks do nothing. A saturated color collapses to one step per COM
// pair, so fourteen of every fifteen calls are a decrement and a return.
bool IRAM_ATTR Aip33628Panel::scan_tick_(gptimer_handle_t timer,
const gptimer_alarm_event_data_t *edata, void *arg) {
auto *self = static_cast<Aip33628Panel *>(arg);
if (self->wait_ > 0) {
self->wait_--;
return false;
}
const ScanBuf &b = self->buf_[self->front_];
// The renderer can flip the buffer between two steps, and the new schedule
// may be shorter than the old one, so the index is clamped rather than
// trusted. Worst case is one odd frame while a slider is moving.
uint8_t i = self->step_;
if (i >= b.n)
i = 0;
const ScanStep &st = b.step[i];
self->send_pair_(st.ss[0], st.ss[1], st.cs, b.is);
self->wait_ = (uint8_t) (st.units - 1); // this tick is the first of the step
uint8_t next = (uint8_t) (i + 1);
self->step_ = next >= b.n ? 0 : next;
return false; // no task woken, so no yield needed
}
void Aip33628Panel::write_pos_(uint8_t block, uint8_t seg, bool on) {
on_[block][seg] = on;
}
void Aip33628Panel::write_digit_(uint8_t block, char c) {
uint8_t bits = glyph(c);
for (int s = 0; s < 7; s++) {
on_[block][s] = (bits >> s) & 1;
}
}
// brightness is linear and carries the transition state, so it falls to zero
// on its own during a fade to off. The color components are the normalized
// ratio and do not scale with it. ESPHome guarantees the largest of the three
// is 1, so at least one channel always survives duty_level and a color can
// never round away to nothing.
void Aip33628Panel::set_light(bool on, float r, float g, float b, float brightness) {
enabled_ = on && brightness > 0.0f;
// Picking a new color on the master light means the whole panel, so it
// drops the digit and position tiers. Moving only the brightness slider
// leaves them alone, which matters because a transition calls this on
// every step and would otherwise wipe a gradient mid fade.
bool color_moved = fabsf(r - base_rgb_[0]) > 0.002f || fabsf(g - base_rgb_[1]) > 0.002f ||
fabsf(b - base_rgb_[2]) > 0.002f;
if (color_moved && effect_ == Effect::NONE) {
for (bool &v : digit_set_)
v = false;
clear_positions_();
}
base_rgb_[0] = r;
base_rgb_[1] = g;
base_rgb_[2] = b;
requested_current_ = current_for(brightness);
apply_colors_();
}
// Quantize whatever color each block is currently supposed to be. Everything
// that changes a color goes through here, so there is one place that decides
// what a block ends up at and one place that marks the panel dirty.
void Aip33628Panel::apply_colors_() {
// The lamp test outranks every color tier, including a running effect.
if (mode_ == Mode::LAMP) {
for (auto &blk : level_)
for (auto &seg : blk)
for (uint8_t &ch : seg)
ch = COLOR_LEVELS - 1;
dirty_ = true;
return;
}
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
const float *c = pos_set_[blk][seg] ? pos_rgb_[blk][seg]
: digit_set_[blk] ? digit_rgb_[blk]
: base_rgb_;
level_[blk][seg][CH_RED] = duty_level(c[0] * envelope_);
level_[blk][seg][CH_GREEN] = duty_level(c[1] * envelope_);
level_[blk][seg][CH_BLUE] = duty_level(c[2] * envelope_);
}
}
dirty_ = true;
}
// A digit of -1 sets all four at once, which is what a whole display effect
// wants. Components are taken as given and not normalized: the master light
// arrives already normalized with its magnitude in the current setting, but a
// caller here is asking for one digit to look a particular way next to the
// others, and scaling that back up would throw away the difference.
void Aip33628Panel::set_digit_color(int digit, float r, float g, float b) {
if (digit < -1 || digit > 3)
return;
for (int blk = 0; blk < 4; blk++) {
if (digit != -1 && digit != blk)
continue;
digit_rgb_[blk][0] = clamp(r, 0.0f, 1.0f);
digit_rgb_[blk][1] = clamp(g, 0.0f, 1.0f);
digit_rgb_[blk][2] = clamp(b, 0.0f, 1.0f);
digit_set_[blk] = true;
// Setting a whole digit drops any per position color inside it. Without
// this a gradient would sit on top and the digit color would do nothing
// visible, which reads as the call being ignored.
for (bool &v : pos_set_[blk])
v = false;
}
apply_colors_();
}
// Hand the whole panel back to the master light, per position overrides
// included. Anything else would leave a gradient stuck on with no obvious way
// to clear it.
void Aip33628Panel::clear_digit_colors() {
for (bool &v : digit_set_)
v = false;
clear_positions_();
apply_colors_();
}
void Aip33628Panel::clear_positions_() {
for (auto &blk : pos_set_)
for (bool &v : blk)
v = false;
}
// One LED, addressed by the id on the board layout map rather than by block
// and segment, so the numbering here is the same one written on the map.
void Aip33628Panel::set_position_color(int id, float r, float g, float b) {
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
if (GEOM[blk][seg].id != id)
continue;
pos_rgb_[blk][seg][0] = clamp(r, 0.0f, 1.0f);
pos_rgb_[blk][seg][1] = clamp(g, 0.0f, 1.0f);
pos_rgb_[blk][seg][2] = clamp(b, 0.0f, 1.0f);
pos_set_[blk][seg] = true;
apply_colors_();
return;
}
}
}
// A linear ramp across the panel between two colors. Angle is in degrees, 0
// running left to right and 90 top to bottom, so -45 runs from the bottom
// left corner to the top right.
//
// The ramp is normalized against the LEDs themselves rather than the panel
// outline, so the two colors asked for land exactly on the outermost LEDs
// whichever way the ramp points. Normalizing against the corners instead
// leaves both ends short, because no LED sits in a corner.
void Aip33628Panel::set_gradient(float r0, float g0, float b0, float r1, float g1, float b1,
float angle_deg) {
const float a = angle_deg * 3.14159265f / 180.0f;
const float ca = cosf(a), sa = sinf(a);
float lo = 1e9f, hi = -1e9f;
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
const PosGeom &g = GEOM[blk][seg];
if (g.id == 0)
continue;
float t = (g.nx / 255.0f) * ca + (g.ny / 255.0f) * sa;
if (t < lo)
lo = t;
if (t > hi)
hi = t;
}
}
float span = hi - lo;
if (span < 1e-6f)
span = 1.0f;
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
const PosGeom &g = GEOM[blk][seg];
if (g.id == 0)
continue; // nothing wired here
float t = ((g.nx / 255.0f) * ca + (g.ny / 255.0f) * sa - lo) / span;
t = clamp(t, 0.0f, 1.0f);
pos_rgb_[blk][seg][0] = clamp(r0 + (r1 - r0) * t, 0.0f, 1.0f);
pos_rgb_[blk][seg][1] = clamp(g0 + (g1 - g0) * t, 0.0f, 1.0f);
pos_rgb_[blk][seg][2] = clamp(b0 + (b1 - b0) * t, 0.0f, 1.0f);
pos_set_[blk][seg] = true;
}
}
apply_colors_();
}
// A temporary mode is capped rather than trusted. Ten minutes is far longer
// than any of these are useful for, and it means a bad automation cannot park
// the panel on a stale number forever.
static uint32_t mode_lifetime(int ms) {
if (ms < 100) return 100;
if (ms > 600000) return 600000;
return (uint32_t) ms;
}
void Aip33628Panel::show_seconds(int ms) {
mode_ = Mode::SECONDS;
mode_until_ = millis() + mode_lifetime(ms);
dirty_ = true;
}
void Aip33628Panel::show_number(int value, const std::string &unit, int ms) {
number_ = value;
// First character only. An empty unit gives the number the whole panel.
unit_ = unit.empty() ? '\0' : unit[0];
mode_ = Mode::NUMBER;
mode_until_ = millis() + mode_lifetime(ms);
dirty_ = true;
}
// Every populated position, white, at a fixed brightness, for a few seconds.
// This is a hardware check, so user color and brightness settings do not
// change the result.
void Aip33628Panel::lamp_test(int ms) {
mode_ = Mode::LAMP;
mode_until_ = millis() + mode_lifetime(ms);
lamp_current_ = current_for(LAMP_BRIGHTNESS);
apply_colors_();
}
// Right aligned, no colon. A unit takes the rightmost position and leaves
// three for the number, so 78F and -5C both fit. Without one the number gets
// all four. Out of range values are clamped rather than wrapped, because a
// wrapped temperature is a wrong reading and a clamped one is obviously
// pinned against the end.
//
// The widest values reach the hour tens position. With a unit that only
// happens at three digits or a signed two, and never for a temperature in F.
void Aip33628Panel::draw_number_(int value, char unit) {
int pos = 3;
if (unit != '\0' && glyph(unit) != 0) {
write_digit_(3, unit);
pos = 2;
// C and F are temperatures, so light the degree mark ahead of the unit.
if (unit == 'C' || unit == 'c' || unit == 'F')
write_pos_(3, SEG_ANNUN, true);
}
bool neg = value < 0;
if (neg) value = -value;
int room = pos + 1 - (neg ? 1 : 0); // positions left for digits
int limit = 1;
for (int i = 0; i < room; i++) limit *= 10;
if (value > limit - 1) value = limit - 1;
do {
write_digit_(pos--, (char) ('0' + value % 10));
value /= 10;
} while (value > 0 && pos >= 0);
if (neg && pos >= 0) write_digit_(pos, '-');
}
// Full saturation hue to RGB. Effects ride the color wheel rather than the
// master light's color, because a rainbow that keeps the user's tint is not
// a rainbow.
static void hue_rgb(float h, float *out) {
h -= floorf(h);
float x = h * 6.0f;
int i = (int) x;
float f = x - (float) i;
switch (i % 6) {
case 0: out[0] = 1.0f; out[1] = f; out[2] = 0.0f; break;
case 1: out[0] = 1.0f - f; out[1] = 1.0f; out[2] = 0.0f; break;
case 2: out[0] = 0.0f; out[1] = 1.0f; out[2] = f; break;
case 3: out[0] = 0.0f; out[1] = 1.0f - f; out[2] = 1.0f; break;
case 4: out[0] = f; out[1] = 0.0f; out[2] = 1.0f; break;
default: out[0] = 1.0f; out[1] = 0.0f; out[2] = 1.0f - f; break;
}
}
// Where every position sits along the effect axis, 0 at the trailing edge
// and 1 at the leading one. Same projection the gradient uses, normalized
// against the LEDs rather than the panel outline for the same reason. Only
// recomputed when the angle changes.
void Aip33628Panel::recompute_axis_() {
const float a = effect_angle_ * 3.14159265f / 180.0f;
const float ca = cosf(a), sa = sinf(a);
float lo = 1e9f, hi = -1e9f;
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
if (GEOM[blk][seg].id == 0)
continue;
float t = (GEOM[blk][seg].nx / 255.0f) * ca + (GEOM[blk][seg].ny / 255.0f) * sa;
if (t < lo) lo = t;
if (t > hi) hi = t;
}
}
float span = hi - lo;
if (span < 1e-6f)
span = 1.0f;
float blo = 1e9f, bhi = -1e9f;
for (int blk = 0; blk < 4; blk++) {
float sum = 0.0f;
int n = 0;
for (int seg = 0; seg < 9; seg++) {
if (GEOM[blk][seg].id == 0)
continue;
float t = ((GEOM[blk][seg].nx / 255.0f) * ca + (GEOM[blk][seg].ny / 255.0f) * sa - lo) / span;
axis_pos_[blk][seg] = t;
sum += t;
n++;
}
axis_blk_[blk] = n ? sum / (float) n : 0.0f;
if (axis_blk_[blk] < blo) blo = axis_blk_[blk];
if (axis_blk_[blk] > bhi) bhi = axis_blk_[blk];
}
// Normalized end to end, same as the per position axis. How much of the
// wheel that covers is the hue span setting's job, not this one's.
float bspan = bhi - blo;
if (bspan < 1e-6f)
bspan = 1.0f;
for (int blk = 0; blk < 4; blk++)
axis_blk_[blk] = (axis_blk_[blk] - blo) / bspan;
}
void Aip33628Panel::set_effect(int mode) {
Effect want = mode == 1 ? Effect::CYCLE : mode == 2 ? Effect::FLASH : Effect::NONE;
if (want == effect_)
return;
effect_ = want;
effect_t0_ = millis();
effect_at_ = 0;
// Leaving an effect hands the panel back rather than freezing on whatever
// frame it happened to stop at.
envelope_ = 1.0f;
if (want == Effect::NONE)
clear_positions_();
if (want == Effect::CYCLE)
recompute_axis_();
apply_colors_();
}
void Aip33628Panel::set_effect_speed(float seconds) {
effect_speed_ = seconds < 0.1f ? 0.1f : (seconds > 600.0f ? 600.0f : seconds);
}
void Aip33628Panel::set_effect_spread(int mode) {
spread_ = mode == 1 ? Spread::DIGIT : mode == 2 ? Spread::LED : Spread::PANEL;
}
void Aip33628Panel::set_effect_angle(float deg) {
effect_angle_ = deg;
recompute_axis_();
}
void Aip33628Panel::set_effect_hue_span(float deg) {
hue_span_ = deg < 0.0f ? 0.0f : (deg > 360.0f ? 360.0f : deg);
}
void Aip33628Panel::set_flash_fade(float seconds) {
flash_fade_ = seconds < 0.0f ? 0.0f : (seconds > 300.0f ? 300.0f : seconds);
}
// Advance whichever effect is running. Called from loop() at a fixed cadence
// rather than every pass, since the scan is what the eye sees and a redraw
// faster than about 25Hz buys nothing.
void Aip33628Panel::update_effect_(uint32_t now_ms) {
float period = effect_speed_;
float phase = fmodf((float) (now_ms - effect_t0_) / 1000.0f / period, 1.0f);
if (effect_ == Effect::FLASH) {
// A trapezoid. Rate and transition time are separate, so 1Hz with a 100ms
// ramp and 1Hz snapping hard are both reachable. The on and off halves
// stay even and the ramps eat into them rather than stretching the
// period, so changing the fade never changes the flash rate.
const float half = period * 0.5f;
const float f = flash_fade_ > half ? half : flash_fade_;
const float t = phase * period;
float e;
if (f <= 0.0f) {
e = t < half ? 1.0f : 0.0f; // square
} else if (t < f) {
e = t / f;
} else if (t < half) {
e = 1.0f;
} else if (t < half + f) {
e = 1.0f - (t - half) / f;
} else {
e = 0.0f;
}
envelope_ = e;
apply_colors_();
return;
}
// How much of the wheel the panel covers end to end. A full turn across
// four digits packs the whole spectrum into a hand span and reads as noise.
const float span = hue_span_ / 360.0f;
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++) {
if (GEOM[blk][seg].id == 0)
continue;
float t = spread_ == Spread::PANEL ? 0.0f
: spread_ == Spread::DIGIT ? axis_blk_[blk]
: axis_pos_[blk][seg];
hue_rgb(phase + t * span, pos_rgb_[blk][seg]);
pos_set_[blk][seg] = true;
}
}
apply_colors_();
}
void Aip33628Panel::loop() {
uint32_t now_ms = millis();
if (effect_ != Effect::NONE && (int32_t) (now_ms - effect_at_) >= 0) {
effect_at_ = now_ms + 40; // 25Hz, smooth enough for a fade to glide
update_effect_(now_ms);
}
// A temporary mode expires here rather than anywhere else, so there is one
// place that can put the panel back to being a clock.
if (mode_ != Mode::TIME && (int32_t) (now_ms - mode_until_) >= 0) {
bool was_lamp = mode_ == Mode::LAMP;
mode_ = Mode::TIME;
dirty_ = true;
if (was_lamp)
apply_colors_();
}
ESPTime now{};
bool valid = false;
if (time_ != nullptr) {
now = time_->now();
valid = now.is_valid();
}
// Whatever is on the panel, reduced to one number, so an unchanged display
// costs nothing. Time uses hour and minute together rather than the minute
// alone, because Home Assistant can push a new timezone at any point and
// every shift is a whole number of hours. A mode change sets dirty_ itself,
// so the key never has to encode which mode produced it.
int key = -1;
if (mode_ == Mode::NUMBER) {
key = number_;
} else if (valid) {
key = mode_ == Mode::SECONDS ? now.second : now.hour * 60 + now.minute;
}
// The colon blinks once a second, so the content changes more often than
// the time does. Blinking off means a steady colon, not a dark one.
bool colon = blink_colon_ ? ((now_ms / 1000) % 2 == 0) : true;
if (!dirty_ && key == last_key_ && colon == last_colon_) return;
last_key_ = key;
last_colon_ = colon;
dirty_ = false;
for (auto &blk : on_) {
for (bool &v : blk) v = false;
}
// A hardware check also works while the normal display light is off.
if (mode_ == Mode::LAMP) {
for (int blk = 0; blk < 4; blk++) {
for (int seg = 0; seg < 9; seg++)
on_[blk][seg] = GEOM[blk][seg].id != 0;
}
render_();
return;
}
if (!enabled_) {
render_();
return;
}
// A pushed number does not need the clock to be set, so it comes first.
if (mode_ == Mode::NUMBER) {
draw_number_(number_, unit_);
render_();
return;
}
if (!valid) {
// No time yet. Four dashes says so without pretending to know the hour.
for (int i = 0; i < 4; i++) write_digit_(i, '-');
render_();
return;
}
if (mode_ == Mode::SECONDS) {
// Seconds sit where the minutes normally do, behind a colon that stays
// steady, so the panel reads as :SS rather than as a bare two digit
// number that could be anything. The upper dot still follows the network.
write_digit_(2, (char) ('0' + now.second / 10));
write_digit_(3, (char) ('0' + now.second % 10));
if (online_) write_pos_(1, SEG_ANNUN, true);
write_pos_(1, SEG_ANNUN2, true);
render_();
return;
}
int hour = now.hour;
bool pm = hour >= 12;
if (twelve_hour_) {
hour = hour % 12;
if (hour == 0) hour = 12;
}
// Leading zero stays suppressed in 24 hour mode as well.
if (hour >= 10) {
write_digit_(0, (char) ('0' + hour / 10));
}
write_digit_(1, (char) ('0' + hour % 10));
write_digit_(2, (char) ('0' + now.minute / 10));
write_digit_(3, (char) ('0' + now.minute % 10));
if (colon) {
// Both dots when the network is up, the lower one alone when it is not.
// Block 2 COM low LED1 is the lower dot, see docs/display-map.md.
if (online_) write_pos_(1, SEG_ANNUN, true);
write_pos_(1, SEG_ANNUN2, true);
}
if (twelve_hour_ && !pm) {
write_pos_(0, SEG_ANNUN, true); // AM indicator, lit through the morning
}
render_();
}
// Collapse the panel state into a scan schedule. Each COM pair is split into
// COLOR_BITS binary weighted sub-frames, and a channel at duty level L is lit
// in sub-frame k whenever bit k of L is set. Any level from 0 to
// COLOR_LEVELS - 1 is reachable that way, with no constraint that a dimmer
// channel be a subset of a brighter one.
//
// Per digit color costs nothing here. Each driver and COM pair together
// belong to exactly one block, since the two blocks on a driver sit on
// different COM pairs, so a slot only ever holds one block's color per
// driver and the two drivers carry their own SS word anyway. Four different
// colors reach sixteen steps, which is exactly MAX_STEPS.
void Aip33628Panel::render_() {
uint16_t sub[2][4][COLOR_BITS] = {};
for (int blk = 0; blk < 4; blk++) {
const Block &b = BLOCKS[blk];
for (int seg = 0; seg < 9; seg++) {
if (!on_[blk][seg])
continue;
const SegPos &sp = SEGMAP[seg];
int ci = com_index(sp.side ? b.com_hi : b.com_lo);
int base = 3 * sp.led - 2; // LED1 is SEG1..SEG3, LED5 is SEG13..SEG15
for (int ch = 0; ch < 3; ch++) {
uint8_t lv = level_[blk][seg][ch];
if (lv == 0)
continue;
uint16_t bit = (uint16_t) (1u << (base + ch));
for (int k = 0; k < COLOR_BITS; k++) {
if (lv & (1u << k))
sub[b.drv][ci][k] |= bit;
}
}
}
}
// IS is set by the brightness alone and never by what is on screen. Making
// it depend on the lit sink count changes the brightness of the whole panel
// every time the colon blinks. The stock firmware held IS fixed across
// colon on and colon off, and ran 0xF with a white digit lit.
// The lamp test brings its own current, while max_current_ remains the
// thermal ceiling for every mode.
uint8_t want = mode_ == Mode::LAMP ? lamp_current_ : requested_current_;
uint8_t is = want < max_current_ ? want : max_current_;
ScanBuf &b = buf_[front_ ^ 1];
b.n = 0;
for (int ci = 0; ci < 4; ci++) {
for (int k = 0; k < COLOR_BITS; k++) {
uint16_t s0 = sub[0][ci][k];
uint16_t s1 = sub[1][ci][k];
uint8_t units = (uint8_t) (1u << k);
// Identical neighbors inside one COM pair merge, so a saturated color,
// where every sub-frame carries the same data, ends up as one step of
// the full 600us. Merging never crosses a COM boundary, because CS
// changes there and the drivers have to be re-sent regardless.
if (k > 0 && b.n > 0 && b.step[b.n - 1].ss[0] == s0 && b.step[b.n - 1].ss[1] == s1) {
b.step[b.n - 1].units = (uint8_t) (b.step[b.n - 1].units + units);
continue;
}
ScanStep &st = b.step[b.n++];
st.units = units;
st.ss[0] = s0;
st.ss[1] = s1;
st.cs = COM_SEQ[ci];
}
}
b.is = is;
// Publish. The barrier keeps the writes above from being reordered past the
// flip, which is what stops the scan callback seeing a torn pattern while a
// Home Assistant slider is being dragged.
__sync_synchronize();
front_ ^= 1;
}
} // namespace aip33628
} // namespace esphome
-272
View File
@@ -1,272 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/components/light/light_output.h"
#include "esphome/components/time/real_time_clock.h"
#include <driver/gptimer.h>
namespace esphome {
namespace aip33628 {
// Two AiP33628 drivers behind the HU-058D panel, one per two-wire bus.
// Mapping, scan timing and the current budget are documented in
// docs/display-map.md.
static const uint8_t DRAM_ATTR COM_SEQ[4] = {0x30, 0x0C, 0x03, 0xC0};
// Each COM pair holds the bus for 600us, so a full four pair cycle is 2400us
// and the panel refreshes at 416.7Hz, within a hertz of what the stock
// firmware ran.
//
// That 600us is subdivided into binary weighted sub-frames, 40, 80, 160 and
// 320us. A channel wanting duty level L is lit in the sub-frames whose weight
// bits are set in L, so four sub-frames buy sixteen levels rather than the
// five that four equal ones would. The shortest sub-frame is 40us against a
// 6.4us frame send, so there is room to spare.
static const uint8_t COLOR_BITS = 4;
static const uint8_t COLOR_LEVELS = 1 << COLOR_BITS; // 0 to 15 inclusive
static const uint32_t UNIT_US = 40;
static const uint8_t MAX_STEPS = 4 * COLOR_BITS;
// Current step to mA, from the datasheet. Tenths of a mA.
static const uint16_t IS_MA[16] = {25, 51, 76, 101, 126, 152, 177, 202,
227, 253, 278, 303, 328, 354, 379, 404};
// Current step to the nibble that goes on the wire. The frame carries IS[0]
// at bit 27 and IS[3] at bit 24, so the field is bit reversed against the
// rest of the frame. Steps 0 and 15 are palindromes, which is why getting
// this wrong looks correct at both ends of the brightness range and scrambles
// the order everywhere in between. The table is its own inverse.
static const uint8_t DRAM_ATTR IS_WIRE[16] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE,
0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};
enum Channel : uint8_t { CH_BLUE = 0, CH_GREEN = 1, CH_RED = 2 };
// Where each LED physically sits, from docs/led-layout.md. id is the number
// used by the board layout map and by set_position_color, 1 to 33, and 0
// marks a position the panel can address but nothing is wired to. nx runs 0
// at the left edge of the first digit to 255 at the right edge of the last,
// ny 0 at the top of a digit to 255 at the bottom.
struct PosGeom {
uint8_t id;
uint8_t nx;
uint8_t ny;
};
extern const PosGeom GEOM[4][9];
// Running effects. Each owns the panel while it is selected, and selecting
// NONE hands it back to whatever the colors were before.
enum class Effect : uint8_t { NONE = 0, CYCLE = 1, FLASH = 2 };
// How far apart an effect spreads its phase across the panel. PANEL moves
// everything together, DIGIT gives each digit its own phase, LED gives every
// position its own. The direction the spread runs is the effect angle.
enum class Spread : uint8_t { PANEL = 0, DIGIT = 1, LED = 2 };
// What the panel is showing. Everything except TIME is temporary and expires
// on its own, so no caller can leave the clock stuck not being a clock.
enum class Mode : uint8_t { TIME, SECONDS, NUMBER, LAMP };
// One step of the scan schedule: latch this pattern on both drivers, then
// hold it for this long. Adjacent sub-frames with identical data collapse
// into a single longer step, so a saturated color costs one send per COM
// pair, exactly what the two level scan cost before.
struct ScanStep {
uint8_t units; // dwell, in UNIT_US ticks, 1 to 15
uint8_t cs;
uint16_t ss[2];
};
// One complete scan pattern. render_() fills the back buffer and then flips
// front_, so the scan callback can never read a half written pattern.
struct ScanBuf {
ScanStep step[MAX_STEPS];
uint8_t n;
uint8_t is;
};
class Aip33628Panel : public Component {
public:
void set_pins(InternalGPIOPin *clk, InternalGPIOPin *data, InternalGPIOPin *clk2,
InternalGPIOPin *data2) {
clk_ = clk;
data_ = data;
clk2_ = clk2;
data2_ = data2;
}
void set_time(time::RealTimeClock *rtc) { time_ = rtc; }
void set_max_current(uint8_t is) { max_current_ = is; }
// Both of these are live. Home Assistant drives them through template
// switches, so each has to force a redraw rather than wait for the next
// rollover.
void set_twelve_hour(bool v) {
twelve_hour_ = v;
dirty_ = true;
}
void set_blink_colon(bool v) {
blink_colon_ = v;
dirty_ = true;
}
// Offline drops the upper colon dot, so a glance at the panel says whether
// the time is still being kept honest. Driven from the wifi triggers in
// clock.yaml rather than by including the wifi component here.
void set_online(bool v) {
online_ = v;
dirty_ = true;
}
void setup() override;
void loop() override;
void dump_config() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
// Called by the light platform. Color components and brightness are 0 to 1.
void set_light(bool on, float r, float g, float b, float brightness);
// Temporary displays, driven from the api actions in clock.yaml. Each takes
// a lifetime in milliseconds and falls back to the time when it runs out.
void show_seconds(int ms);
void show_number(int value, const std::string &unit, int ms);
// Every populated position, white, at a fixed brightness. Ignores the
// color tiers, any running effect, and the light being off.
void lamp_test(int ms);
// Per digit color. Blocks are 0 to 3, left to right, and each carries its
// own annunciator: block 0 the AM mark, block 1 the colon, block 2 the date
// dash. Components run 0 to 1 and are used as given rather than normalized,
// so a digit can be dimmer than its neighbors as well as a different hue,
// which is what a per digit fade needs. A digit with no color of its own
// follows the master light.
void set_digit_color(int digit, float r, float g, float b);
void clear_digit_colors();
// One LED, by the id in docs/led-layout.md. Overrides the digit color,
// which in turn overrides the master light.
void set_position_color(int id, float r, float g, float b);
// A linear ramp between two colors across the panel. The angle is in
// degrees, 0 running left to right and 90 top to bottom, and the ramp is
// always stretched to cover the whole panel whatever the angle.
void set_gradient(float r0, float g0, float b0, float r1, float g1, float b1,
float angle_deg);
// Effects. Everything here is live and takes hold on the next update.
void set_effect(int mode);
void set_effect_speed(float seconds);
void set_effect_spread(int mode);
void set_effect_angle(float deg);
void set_effect_hue_span(float deg);
void set_flash_fade(float seconds);
protected:
void render_();
void apply_colors_();
void update_effect_(uint32_t now_ms);
void recompute_axis_();
void clear_positions_();
void write_digit_(uint8_t block, char c);
void write_pos_(uint8_t block, uint8_t seg, bool on);
void draw_number_(int value, char unit);
static bool scan_tick_(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata,
void *arg);
void send_pair_(uint16_t ss1, uint16_t ss2, uint8_t cs, uint8_t is);
InternalGPIOPin *clk_{nullptr};
InternalGPIOPin *data_{nullptr};
InternalGPIOPin *clk2_{nullptr};
InternalGPIOPin *data2_{nullptr};
time::RealTimeClock *time_{nullptr};
// Port bit masks for the four pins. A frame goes out as direct register
// stores with both buses clocked together, which takes 6.4us against 28.0us
// for two passes through ISRInternalGPIOPin. All four pins have to live
// below GPIO32 for this, which __init__.py enforces at config time.
uint32_t clk_mask_{0}, data_mask_{0}, clk2_mask_{0}, data2_mask_{0};
uint8_t max_current_{15};
bool twelve_hour_{true};
bool blink_colon_{true};
bool online_{false};
// Which positions are lit, before color is applied.
bool on_[4][9]{}; // [block][segment], segments A..G then annunciator, annunciator 2
bool enabled_{false};
// [block][segment][channel], 0 to COLOR_LEVELS - 1, index by Channel.
uint8_t level_[4][9][3]{};
uint8_t requested_current_{15};
// Color before it is quantized, in three tiers. A position with pos_set_
// wins, then a block with digit_set_, then the master light's base_rgb_.
float base_rgb_[3]{1.0f, 1.0f, 1.0f};
float digit_rgb_[4][3]{};
bool digit_set_[4]{};
float pos_rgb_[4][9][3]{};
bool pos_set_[4][9]{};
// Scales every color on its way to a duty level. The flash effect drives
// it and nothing else touches it, so it stays at 1 the rest of the time.
float envelope_{1.0f};
Effect effect_{Effect::NONE};
Spread spread_{Spread::PANEL};
float effect_speed_{10.0f}; // seconds for one full cycle
float effect_angle_{0.0f};
// How much of the color wheel the panel covers end to end. A full turn on
// four digits packs the whole spectrum into a hand span and reads as
// noise, so the useful settings are narrow, a slice rather than the lot.
float hue_span_{90.0f};
// Seconds each flash transition takes. Zero snaps.
float flash_fade_{0.0f};
uint32_t effect_t0_{0};
uint32_t effect_at_{0};
// Where each position sits along the effect axis, 0 to 1, recomputed only
// when the angle changes rather than every frame.
float axis_pos_[4][9]{};
float axis_blk_[4]{};
ScanBuf buf_[2]{};
volatile uint8_t front_{0};
volatile uint8_t step_{0};
volatile uint8_t wait_{0}; // ticks left before the next step is latched
Mode mode_{Mode::TIME};
uint32_t mode_until_{0};
uint8_t lamp_current_{0};
int number_{0};
char unit_{'\0'};
int last_key_{-1}; // whatever the current mode reduces its content to
bool last_colon_{false};
bool dirty_{true};
};
class Aip33628Light : public light::LightOutput {
public:
void set_panel(Aip33628Panel *panel) { panel_ = panel; }
light::LightTraits get_traits() override {
auto traits = light::LightTraits();
traits.set_supported_color_modes({light::ColorMode::RGB});
return traits;
}
void write_state(light::LightState *state) override {
auto v = state->current_values;
// Color ratio comes from the raw components, which ESPHome has already
// normalized so the largest is 1. Magnitude comes through the helper
// rather than v.get_brightness(), because only the helper carries the
// transition state, without which a fade never moves. Both arrive linear,
// since gamma lives in the component.
float bright;
state->current_values_as_brightness(&bright);
panel_->set_light(v.is_on(), v.get_red(), v.get_green(), v.get_blue(), bright);
}
protected:
Aip33628Panel *panel_{nullptr};
};
} // namespace aip33628
} // namespace esphome
-27
View File
@@ -1,27 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import light
from esphome.const import CONF_OUTPUT_ID
from . import Aip33628Panel, aip33628_ns
DEPENDENCIES = ["aip33628"]
Aip33628Light = aip33628_ns.class_("Aip33628Light", light.LightOutput)
CONF_AIP33628_ID = "aip33628_id"
CONFIG_SCHEMA = light.RGB_LIGHT_SCHEMA.extend(
{
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(Aip33628Light),
cv.GenerateID(CONF_AIP33628_ID): cv.use_id(Aip33628Panel),
}
).extend(cv.COMPONENT_SCHEMA)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
await light.register_light(var, config)
panel = await cg.get_variable(config[CONF_AIP33628_ID])
cg.add(var.set_panel(panel))
-650
View File
@@ -1,650 +0,0 @@
substitutions:
device_description: "M5Stack Core energy dashboard for Home Assistant grid, solar and consumer usage, with analog/digital clock and WireGuard"
name: "energymonitor"
friendly_name: "Energy Monitor"
grid_power_gauge_max_w: "5000.0"
balcony_solar_gauge_max_w: "800.0"
esphome:
comment: ${device_description}
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
encryption:
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");
}
+8 -50
View File
@@ -1,13 +1,8 @@
# Device identity shared by ESPHome and Home Assistant.
substitutions: substitutions:
device_description: "ESP32 e-paper Home Assistant dashboard for indoor climate, energy and calendar events, with button-controlled pages"
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:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -23,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:
@@ -31,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
@@ -58,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
@@ -67,7 +60,7 @@ globals:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Power key of li-ion charger # Power key of li-ion charger
output: output:
@@ -131,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
@@ -209,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"
@@ -238,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:
@@ -259,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
@@ -274,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:
@@ -287,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"
@@ -757,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
@@ -783,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);
@@ -811,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],
@@ -1159,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"};
@@ -1173,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) {
@@ -1214,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>();
@@ -1237,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;
@@ -1280,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);
@@ -1330,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()) {
@@ -1352,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);
+1 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
device_description: "ESP32 Geiger counter with radiation dose rate, accumulated dose and MAX7219 seven-segment display"
name: "geigercounter" name: "geigercounter"
friendly_name: "Geigerzähler" friendly_name: "Geigerzähler"
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -46,7 +44,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
spi: spi:
clk_pin: 18 clk_pin: 18
+1 -5
View File
@@ -1,11 +1,9 @@
substitutions: substitutions:
device_description: "Home Assistant Voice PE voice assistant with microphone and speaker."
name: home-assistant-voice-09c0e7 name: home-assistant-voice-09c0e7
friendly_name: Home Assistant Voice Küche friendly_name: Home Assistant Voice Küche
packages: packages:
Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
name_add_mac_suffix: false name_add_mac_suffix: false
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
@@ -30,8 +28,6 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
http_request: http_request:
captive_portal:
+1 -5
View File
@@ -1,11 +1,9 @@
substitutions: substitutions:
device_description: "Home Assistant Voice PE voice assistant with microphone and speaker."
name: home-assistant-voice-0a7c6b name: home-assistant-voice-0a7c6b
friendly_name: Home Assistant Voice Wohnzimmer friendly_name: Home Assistant Voice Wohnzimmer
packages: packages:
Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml Nabu Casa.Home Assistant Voice PE: github://esphome/home-assistant-voice-pe/home-assistant-voice.yaml
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
name_add_mac_suffix: false name_add_mac_suffix: false
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
@@ -30,8 +28,6 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
http_request: http_request:
captive_portal:
+1 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
name: kamera-balkon name: kamera-balkon
friendly_name: Kamera Balkon friendly_name: Kamera Balkon
device_description: "Balcony ESP32-CAM with HTTP stream and snapshots, flash LED, and SHT3x temperature and humidity sensing."
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -45,7 +43,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
+1 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
name: kamera-wohnzimmer name: kamera-wohnzimmer
friendly_name: Kamera Wohnzimmer friendly_name: Kamera Wohnzimmer
device_description: "Living-room ESP32 camera with HTTP stream and snapshots and a controllable flash LED."
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -45,7 +43,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
+2 -8
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"
@@ -67,7 +61,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
network: network:
enable_ipv6: true enable_ipv6: true
+1 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
device_description: "ESP32 living-room air quality monitor with SCD30 CO2, temperature and humidity, PM2.5 sensing and RGB status LED"
name: "livingroom" name: "livingroom"
friendly_name: "Luftqualität Wohnzimmer" friendly_name: "Luftqualität Wohnzimmer"
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -88,7 +86,7 @@ api:
# Enable over-the-air updates # Enable over-the-air updates
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
+45 -85
View File
@@ -3,22 +3,18 @@
substitutions: substitutions:
name: m5stack-atom-echo name: m5stack-atom-echo
friendly_name: M5Stack Atom Echo friendly_name: M5Stack Atom Echo
device_description: "M5Stack Atom Echo ESP32 voice assistant with on-device or Home Assistant wake-word detection and timer announcements." micro_wake_word_model: okay_nabu # alexa, hey_jarvis, hey_mycroft are also supported
esphome: esphome:
comment: ${device_description}
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:
@@ -28,7 +24,7 @@ api:
ota: ota:
- platform: esphome - platform: esphome
id: ota_esphome id: ota_esphome
encryption: password: !secret ota
network: network:
enable_ipv6: true enable_ipv6: true
@@ -67,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:
@@ -87,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:
@@ -97,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%
@@ -107,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
@@ -142,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
@@ -176,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:
@@ -234,7 +215,7 @@ light:
default_transition_length: 0s default_transition_length: 0s
chipset: SK6812 chipset: SK6812
num_leds: 1 num_leds: 1
channel_colors: GRB rgb_order: grb
effects: effects:
- pulse: - pulse:
name: "Slow Pulse" name: "Slow Pulse"
@@ -254,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:
@@ -268,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:
@@ -283,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
@@ -377,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:
@@ -386,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:
@@ -396,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
+11 -22
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
@@ -91,7 +81,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Enable status LED # Enable status LED
status_led: status_led:
@@ -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"
+10 -22
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
@@ -91,7 +81,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Enable status LED # Enable status LED
status_led: status_led:
@@ -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 -3
View File
@@ -1,10 +1,8 @@
substitutions: substitutions:
device_description: "ESP32-C3 server-room temperature and atmospheric pressure monitor with BMP280 sensor"
name: "serverroom" name: "serverroom"
friendly_name: "Serverraum Luft" friendly_name: "Serverraum Luft"
esphome: esphome:
comment: ${device_description}
name: ${name} name: ${name}
friendly_name: ${friendly_name} friendly_name: ${friendly_name}
name_add_mac_suffix: false name_add_mac_suffix: false
@@ -46,7 +44,7 @@ api:
ota: ota:
platform: esphome platform: esphome
encryption: password: !secret ota
# Initialize I²C # Initialize I²C
i2c: i2c:
-450
View File
@@ -1,450 +0,0 @@
# Board: ESP32-C3 Super Mini (Generic)
# Definition: definitions/boards/esp32-c3-supermini/manifest.yaml
# Based largely on https://github.com/misterblack1/HU-058_ESPHome by Adrian Black aka "Adrian's Digital Basement"
# AI slop in here
substitutions:
device_description: "ESP32 Geiger counter with radiation dose rate, accumulated dose and MAX7219 seven-segment display"
name: "sleepingroom-clock"
friendly_name: "Schlafzimmeruhr"
esphome:
comment: ${device_description}
name: ${name}
friendly_name: ${friendly_name}
name_add_mac_suffix: false
project:
name: sensor.radiation
version: "1.0"
min_version: 2022.11.0
# Template numbers and selects restore their value by publishing it, which
# does not fire their set_action, so a restored effect would show in the UI
# and do nothing. Push the lot into the component once everything is up.
on_boot:
priority: -100
then:
- lambda: |-
id(panel)->set_effect_speed(id(effect_speed).state);
id(panel)->set_effect_angle(id(effect_angle).state);
id(panel)->set_effect_hue_span(id(effect_hue_span).state);
id(panel)->set_flash_fade(id(fx_flash_fade).state);
std::string sp = id(effect_spread).current_option();
id(panel)->set_effect_spread(sp == "Per Digit" ? 1 : sp == "Per LED" ? 2 : 0);
std::string ef = id(effect_mode).current_option();
id(panel)->set_effect(ef == "Color Cycle" ? 1 : ef == "Flash" ? 2 : 0);
esp32:
variant: esp32c3
flash_size: 4MB
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret apikey
actions:
- action: show_seconds
variables:
duration: int
then:
- lambda: id(panel)->show_seconds(duration);
# Right aligned digits with an optional unit in the rightmost position, so
# 78F and -5C both read correctly. A unit of C or F also lights the degree
# mark. Pass an empty unit to give the number all four positions. There is
# no decimal point on the panel, so round before sending.
- action: show_number
variables:
value: int
unit: string
duration: int
then:
- lambda: id(panel)->show_number(value, unit, duration);
# Every populated LED, white, for a few seconds, then back to the time.
# It ignores color, effects, brightness and the light being off. Duration
# is milliseconds, and 3000 is the button below.
- action: lamp_test
variables:
duration: int
then:
- lambda: id(panel)->lamp_test(duration);
# Per digit color. Digit 0 is the leftmost and 3 the rightmost, and -1
# sets all four at once. Components are 0 to 255 and are not rescaled
# against each other, so a digit can be dimmer than its neighbors as well
# as a different hue. Each digit carries its own annunciator, so the colon
# takes the color of the hour ones digit and the AM mark the hour tens.
# This is runtime state and is not remembered across a reboot.
- action: set_digit_color
variables:
digit: int
red: int
green: int
blue: int
then:
- lambda: |-
id(panel)->set_digit_color(digit, red / 255.0f, green / 255.0f, blue / 255.0f);
# Hand the whole panel back to the Display light, gradients included.
- action: clear_digit_colors
then:
- lambda: id(panel)->clear_digit_colors();
# One LED, by the id on the board layout map. See docs/led-layout.md.
- action: set_position_color
variables:
position: int
red: int
green: int
blue: int
then:
- lambda: |-
id(panel)->set_position_color(position, red / 255.0f, green / 255.0f,
blue / 255.0f);
# A linear ramp between two colors across the whole panel. Angle is in
# degrees, 0 left to right and 90 top to bottom, so -45 runs from the
# bottom left corner to the top right.
# Everything about the running effect in one call, for automations that
# want to set it up atomically rather than nudging five entities.
# mode 0 off, 1 color cycle, 2 flash. spread 0 whole panel, 1 per digit,
# 2 per LED. speed is seconds for one full cycle, which for flash is one
# complete on and off. angle is the direction the spread runs. hue_span is
# how many degrees of the color wheel the panel covers end to end.
# flash_fade is seconds per flash transition, 0 to snap.
- action: set_effect
variables:
mode: int
spread: int
speed: float
angle: float
hue_span: float
flash_fade: float
then:
# Drives the entities rather than the component, so the Home Assistant
# UI ends up showing what the panel is actually doing. Calling the
# component directly would work and leave every slider stale.
#
# Values are clamped here because a number call outside its range is
# dropped rather than clamped, which would silently ignore the whole
# setting.
- lambda: |-
id(effect_speed).make_call().set_value(clamp(speed, 0.2f, 600.0f)).perform();
id(effect_angle).make_call().set_value(clamp(angle, -180.0f, 180.0f)).perform();
id(effect_hue_span).make_call().set_value(clamp(hue_span, 0.0f, 360.0f)).perform();
id(fx_flash_fade).make_call().set_value(clamp(flash_fade, 0.0f, 30.0f)).perform();
id(effect_spread).make_call().set_option(
spread == 1 ? "Per Digit" : spread == 2 ? "Per LED" : "Whole Panel").perform();
id(effect_mode).make_call().set_option(
mode == 1 ? "Color Cycle" : mode == 2 ? "Flash" : "None").perform();
- action: set_gradient
variables:
red1: int
green1: int
blue1: int
red2: int
green2: int
blue2: int
angle: float
then:
- lambda: |-
id(panel)->set_gradient(red1 / 255.0f, green1 / 255.0f, blue1 / 255.0f,
red2 / 255.0f, green2 / 255.0f, blue2 / 255.0f, angle);
ota:
platform: esphome
encryption:
network:
enable_ipv6: true
wifi:
ssid: "Voltage-legacy"
password: !secret voltage_legacy_psk
#use_address: ${name}.home
power_save_mode: high
fast_connect: on
min_auth_mode: WPA2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Schlafzimmeruhr Fallback Hotspot"
password: !secret fallback_psk
captive_portal:
external_components:
- source:
type: local
path: components
time:
# No timezone on this one, deliberately. Home Assistant pushes its own
# timezone to the device on every time sync, DST rules included, but only
# if this platform has no timezone of its own. Setting one here compiles
# that path out and pins the clock to whatever is written instead.
- platform: homeassistant
id: ha_time
# SNTP is the fallback for a boot with no Home Assistant. It has nowhere to
# learn a timezone from, so this one is spelled out. It is also what the
# display shows for the first few seconds of every boot, until Home
# Assistant answers. Change it if the clock moves.
#- platform: sntp
# id: sntp_time
# timezone: !secret timezone
aip33628:
id: panel
clk_pin: GPIO21 # MCU socket pin 14 (HU-058D) or 16 (HU-058/SE), driver 1
data_pin: GPIO20 # MCU socket pin 5, driver 1
clk2_pin: GPIO10 # MCU socket pin 1, driver 2
data2_pin: GPIO9 # MCU socket pin 2, driver 2
time_id: ha_time
# Power on defaults. The switches below own both after that, and they
# restore their last state, so these only matter for a first ever boot.
twelve_hour: false
blink_colon: true
# Ceiling on IS[3:0], 0 to 15. Fixed, never varied by content. The stock
# firmware ran 0xF and drew 404mA doing it. Drop this if the drivers
# run hotter than you want. See docs/display-map.md.
max_current: 15
light:
- platform: aip33628
id: display
aip33628_id: panel
name: Display
restore_mode: RESTORE_DEFAULT_ON
# Gamma is applied inside the component, because it also has to allow for
# the 2.5mA floor the drivers cannot go below. Leaving it on here as well
# would square it.
gamma_correct: 1.0
# The two front panel buttons. Nothing on the board pulls these nets up. The
# stock 8051 held them high with its own quasi-bidirectional port pullup, and
# that chip is out of the socket, so the ESP32 internal pullup is the only one
# and the lines never see 5V. Switch closed shorts to ground, hence inverted.
#
# No behavior is attached here on purpose. Home Assistant is the control
# surface, so these are just inputs it can bind to. Press and hold patterns
# belong in an automation, not in this file.
binary_sensor:
- platform: gpio
id: button_1
name: Button 1
pin:
number: GPIO8 # MCU socket pin 9, net S1, top button on the case
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 20ms
- delayed_off: 20ms
- platform: gpio
id: button_2
name: Button 2
pin:
number: GPIO5 # MCU socket pin 10, net S2, bottom button on the case
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 20ms
- delayed_off: 20ms
switch:
- platform: template
id: twelve_hour_mode
name: 12 Hour Time
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- lambda: id(panel)->set_twelve_hour(true);
turn_off_action:
- lambda: id(panel)->set_twelve_hour(false);
# Off means a steady colon, not a dark one.
- platform: template
id: colon_blink
name: Blink Colon
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- lambda: id(panel)->set_blink_colon(true);
turn_off_action:
- lambda: id(panel)->set_blink_colon(false);
button:
# Three seconds of every populated LED lit white at half brightness, then
# back to the time with the settings it had before.
- platform: template
name: Lamp Test
on_press:
- lambda: id(panel)->lamp_test(3000);
# A shortcut for the common case, and something to press by hand.
# Anything more elaborate belongs in a Home Assistant automation calling
# the api actions above.
- platform: template
name: Show Seconds
on_press:
- lambda: id(panel)->show_seconds(5000);
# A UI handle for set_digit_color, and the quickest way to see the four
# digits driven independently.
- platform: template
name: Digit Color Demo
on_press:
- lambda: |-
id(panel)->set_digit_color(0, 1.00f, 0.00f, 0.00f);
id(panel)->set_digit_color(1, 1.00f, 0.45f, 0.00f);
id(panel)->set_digit_color(2, 0.00f, 1.00f, 0.25f);
id(panel)->set_digit_color(3, 0.10f, 0.30f, 1.00f);
- platform: template
name: Clear Digit Colors
on_press:
- lambda: id(panel)->clear_digit_colors();
# Green in the bottom left corner running to yellow in the top right, which
# is the sort of thing the stock firmware did. -45 degrees is that diagonal.
- platform: template
name: Diagonal Gradient
on_press:
- lambda: |-
id(panel)->set_gradient(0.00f, 1.00f, 0.10f,
1.00f, 0.85f, 0.00f, -45.0f);
# A UI handle for the show_number action, which otherwise lives only under
# Developer Tools > Actions. Setting either entity redraws immediately and the
# panel falls back to the time ten seconds later on its own.
select:
# Effects run on the device, not in Home Assistant, so a fade stays smooth
# and keeps going if the network drops. Every entity here is a normal one,
# so an automation can drive them, or call the set_effect action to set the
# lot at once.
- platform: template
name: Effect
id: effect_mode
optimistic: true
restore_value: true
initial_option: "None"
options: ["None", "Color Cycle", "Flash"]
set_action:
- lambda: |-
std::string v = x;
id(panel)->set_effect(v == "Color Cycle" ? 1 : v == "Flash" ? 2 : 0);
# Whole Panel moves everything together. Per Digit gives each digit its own
# phase, so the color walks across the four of them. Per LED gives every
# position its own, which is the smooth sweep.
- platform: template
name: Effect Spread
id: effect_spread
optimistic: true
restore_value: true
initial_option: "Whole Panel"
options: ["Whole Panel", "Per Digit", "Per LED"]
set_action:
- lambda: |-
std::string v = x;
id(panel)->set_effect_spread(v == "Per Digit" ? 1 : v == "Per LED" ? 2 : 0);
- platform: template
name: Test Unit
id: test_unit
optimistic: true
restore_value: true
initial_option: "F"
options: ["None", "F", "C"]
set_action:
- lambda: |-
std::string u = x;
if (u == "None") u.clear();
id(panel)->show_number((int) id(test_number).state, u, 10000);
number:
# Seconds for one full cycle. For Flash this is one complete on and off.
- platform: template
name: Effect Speed
id: effect_speed
optimistic: true
restore_value: true
initial_value: 10
min_value: 0.2
max_value: 600
step: 0.2
unit_of_measurement: s
mode: box
set_action:
- lambda: id(panel)->set_effect_speed(x);
# Which way the spread runs. 0 is left to right, 90 top to bottom, 180
# right to left. -45 is the bottom left to top right diagonal and 135 is
# the other one, top right to bottom left.
- platform: template
name: Effect Angle
id: effect_angle
optimistic: true
restore_value: true
initial_value: 0
min_value: -180
max_value: 180
step: 15
unit_of_measurement: deg
mode: box
set_action:
- lambda: id(panel)->set_effect_angle(x);
# How many degrees of the color wheel the panel covers end to end. A full
# 360 packs the whole spectrum across four digits and reads as noise, so
# the useful settings are narrow. 60 is roughly red through orange, 90
# reaches yellow. 0 puts the whole panel on one color that still cycles.
# Only Color Cycle uses this, and only when Spread is not Whole Panel.
- platform: template
name: Effect Hue Span
id: effect_hue_span
optimistic: true
restore_value: true
initial_value: 90
min_value: 0
max_value: 360
step: 5
unit_of_measurement: deg
mode: box
set_action:
- lambda: id(panel)->set_effect_hue_span(x);
# Seconds each flash transition takes, independent of the flash rate. 0
# snaps on and off. 0.1 gives a quick ramp. Anything past half the Effect
# Speed is capped there, which is the point where it becomes a triangle.
- platform: template
name: Flash Fade
id: fx_flash_fade
optimistic: true
restore_value: true
initial_value: 0
min_value: 0
max_value: 30
step: 0.05
unit_of_measurement: s
mode: box
set_action:
- lambda: id(panel)->set_flash_fade(x);
- platform: template
name: Test Number
id: test_number
optimistic: true
restore_value: true
initial_value: 72
min_value: -999
max_value: 9999
step: 1
mode: box
set_action:
- lambda: |-
std::string u = id(test_unit).current_option();
if (u == "None") u.clear();
id(panel)->show_number((int) x, u, 10000);
+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 -4
View File
@@ -11,8 +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
baseoid: .1.3.6.1.2.1.31.1.1.1.6.12 # IF-MIB::ifHCInOctets.12
version: 2c version: 2c
unit_of_measurement: "Octets" unit_of_measurement: "Octets"
- platform: snmp - platform: snmp
@@ -21,8 +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
baseoid: .1.3.6.1.2.1.31.1.1.1.10.12 # IF-MIB::ifHCOutOctets.12
version: 2c version: 2c
unit_of_measurement: "Octets" unit_of_measurement: "Octets"
+1 -2
View File
@@ -78,8 +78,7 @@
{% set waschmaschine = states('sensor.waschmaschine_leistung') | float %} {% set waschmaschine = states('sensor.waschmaschine_leistung') | float %}
{% set arcade = states('sensor.arcade_automat_leistung') | float %} {% set arcade = states('sensor.arcade_automat_leistung') | float %}
{% set spuelmaschine = states('sensor.spulmaschine_leistung') | float %} {% set spuelmaschine = states('sensor.spulmaschine_leistung') | float %}
{% set mikrowelle = states('sensor.waschetrockner_leistung') | float %} {{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine - arcade - spuelmaschine) | round(1) }}
{{ (total + solar - raumduft - keller - musik - bett - heimkino_sz - deko - schreibtisch - serverraum - heimkino_wz - spieleschrank - kuehlschrank - kaffeemaschine - waeschetrockner - waschmaschine - arcade - spuelmaschine - mikrowelle) | round(1) }}
device_class: power device_class: power
state_class: measurement state_class: measurement
attributes: attributes: