EspHoMaTriXv2
EspHoMaTriXv2 copied to clipboard
[BUG] on_empty_queue loop after ~25 days runtime
Bug report
Describe the bug
The clock displayed nothing but was reachable with HA. But it's really busy! Viewing Logs online was hard and HA freezes because of the amount of logs messages (because of the loop). Display and "Night mode" was on. It looped and always triggered "on_empty_queue"
Additional information
- used Hardware:
- ESP32 (ulanzi TC0001)
- EspHoMaTriXv2 version: 2024.4.1
To Reproduce
Steps to reproduce the behavior: I dont know. I just was running stable for ~25 days and one night this issue occured.
Expected behavior
Trigger "on_empty_queue" -> my yaml triggers "set_night_mode_on()" (or off) which add's at least an clock_screen. Do not loop.
Configuration
substitutions:
# Pin definition from https://github.com/aptonline/PixelIt_Ulanzi
battery_pin: GPIO34
ldr_pin: GPIO35
matrix_pin: GPIO32
left_button_pin: GPIO26
mid_button_pin: GPIO27
right_button_pin: GPIO14
scl_pin: GPIO22
sda_pin: GPIO21
external_components:
- source:
type: git
url: https://github.com/lubeda/EspHoMaTriXv2
ref: 2024.4.1
refresh: 1min
components: [ehmtxv2]
esphome:
comment: "Ulanzi TC001"
project:
name: "Ulanzi.EHMTXv2"
version: "2.0.0"
on_boot:
then:
- ds1307.read_time:
esp32:
board: esp32dev
#include device_base yaml
packages:
device_base: !include /config/esphome/common/device_base.yaml
font:
# Font included in this folder
# - file: mateine.ttf
# size: 16
# id: default_font
# glyphs: |
# !?"%()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ߧ€/
# Matrix Clock Fonts
# Grab these from https://github.com/trip5/Matrix-Fonts
# See https://github.com/lubeda/EspHoMaTriXv2#font
# Store in a "fonts" subfolder of your ESPHome config folder or change paths below
- file: fonts/MatrixLight8.bdf
id: special_font
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°
#- file: fonts/MatrixChunky6.bdf
# id: special_font
# glyphs: |
# ! "#$%&'()*+,-./0123456789:APMTapmt
- file: fonts/Calcium.ttf
id: default_font
size: 16
glyphs: |
!?"%‰()+*=,-_.:°µ²³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz€$@<>/
globals:
# aab = auto-adjustable brightness
- id: aab_enabled
type: "bool"
restore_value: true
initial_value: "true"
- id: aab_add
type: int
initial_value: '10'
- id: aab_max
type: int
initial_value: '220'
- id: display_enabled
type: "bool"
restore_value: true
initial_value: "true"
- id: night_mode_enabled
type: "bool"
restore_value: true
initial_value: "false"
- id: is_running
type: "bool"
initial_value: "false"
ehmtxv2:
id: rgb8x32
icons2html: true
matrix_component: ehmtx_display
time_component: ehmtx_time
time_format: "%H:%M"
date_format: "%d.%m"
show_seconds: false
brightness: 0 #0-255
# Uncomment below if using the mateine font
default_font_id: default_font
special_font_id: special_font
default_font_yoffset: 8
special_font_yoffset: 8
# Comment out below if using mateine font
#default_font_id: default_font
#default_font_yoffset: 8
#special_font_id: special_font
#special_font_yoffset: 6
# until here
# black boot logo with red dot
boot_logo: "[32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
clock_interval: 20 # show the clock at least each x seconds
show_dow: false # draw the day indicator on the bottom of the screen, defaults to true
#show_date: true # show the date for show_screen - show_clock seconds otherwise only shows the clock for show_screen seconds, defaults to true
week_start_monday: true # default monday is first day of week, false = sunday
night_mode_screens: [2,16]
icons:
- id: ha
lameid: 7956
- id: tempc
lameid: 2422
- id: plug
lameid: 403
- id: humidity
lameid: 51764
- id: co2
lameid: 30662
- id: weather_clear_night
lameid: 53383
- id: weather_cloudy
lameid: 53384
- id: weather_fog
lameid: 12196
- id: weather_hail
lameid: 53385
- id: weather_lightning
lameid: 50231
- id: weather_lightning_rainy
lameid: 49299
- id: weather_partlycloudy
lameid: 53802
- id: weather_pouring
lameid: 49300
- id: weather_rainy
lameid: 2284
- id: weather_snowy
lameid: 2289
- id: weather_snowy_rainy
lameid: 49301
- id: weather_sunny
lameid: 1246
- id: weather_windy
lameid: 17076
- id: weather_windy_variant
lameid: 15618
- id: weather_exceptional
lameid: 5464
- id: washing_machine_ready
lameid: 26673
- id: dryer_ready
lameid: 48497
- id: dishwasher_ready
lameid: 47488
- id: door_ringing
lameid: 24800
- id: fire
lameid: 24873
- id: water
lameid: 24116
- id: speaker
lameid: 59332
- id: mute
lameid: 31722
on_empty_queue:
then:
lambda: |-
//set flag that we are running and from now on the switch changes lambda take effect
id(is_running) = true;
//restore display state
if (id(display_enabled)) {
ESP_LOGI("on_empty_queue", "set display on!");
//id(displaycontrol).turn_on();
id(rgb8x32)->set_display_on();
} else {
ESP_LOGI("on_empty_queue", "set display off!");
//id(displaycontrol).turn_off();
id(rgb8x32)->set_display_off();
}
//restore night mode (this adds the clock_screen)
if (id(night_mode_enabled)) {
ESP_LOGI("on_empty_queue", "set night mode on!");
id(rgb8x32)->set_night_mode_on();
} else {
ESP_LOGI("on_empty_queue", "set night mode off!");
id(rgb8x32)->set_night_mode_off();
}
//add date screen
id(rgb8x32)->date_screen(1440,5);
on_start_running:
then:
lambda: |-
//set flag that we are running and from now on the switch changes lambda take effect
id(is_running) = true;
//restore display state
if (id(display_enabled)) {
ESP_LOGI("on_empty_queue", "set display on!");
//id(displaycontrol).turn_on();
id(rgb8x32)->set_display_on();
} else {
ESP_LOGI("on_empty_queue", "set display off!");
//id(displaycontrol).turn_off();
id(rgb8x32)->set_display_off();
}
//restore night mode (this adds the clock_screen)
if (id(night_mode_enabled)) {
ESP_LOGI("on_empty_queue", "set night mode on!");
id(rgb8x32)->set_night_mode_on();
} else {
ESP_LOGI("on_empty_queue", "set night mode off!");
id(rgb8x32)->set_night_mode_off();
}
//add date screen
id(rgb8x32)->date_screen(1440,5);
on_next_screen:
- homeassistant.event:
event: esphome.new_screen
data_template:
iconname: !lambda "return icon.c_str();"
text: !lambda "return text.c_str();"
on_night_mode:
then:
lambda: |-
if (state) {
id(aab_enabled) = false;
id(rgb8x32)->clock_screen(1440,10,true,$night_mode_r,0,0);
id(rgb8x32)->set_brightness($night_mode_brightness);
} else {
id(aab_enabled) = true;
id(rgb8x32)->clock_screen(1440,10,true,255,255,255);
}
#workaround that clock doesnt disappear after lifetime
interval:
- interval: 720min
then:
lambda: |-
//restore night mode (this adds the clock_screen)
if (id(night_mode_enabled)) {
ESP_LOGI("interval", "set night mode on!");
id(rgb8x32)->set_night_mode_on();
} else {
ESP_LOGI("interval", "set night mode off!");
id(rgb8x32)->set_night_mode_off();
}
//add date screen
id(rgb8x32)->date_screen(1440,5);
# workaround for compiling errors on esphome 2023.07: https://github.com/lubeda/EspHoMaTriXv2/issues/62#issuecomment-1643052894
animation:
- id: animation_black
file: icons/black_1x1_EspHoMaTriX.gif
binary_sensor:
- platform: status
name: "Status"
- platform: gpio
pin:
number: $left_button_pin
inverted: true
name: "Left button"
on_press:
then:
- number.decrement: screen_brightness
- platform: gpio
pin:
inverted: true
number: $mid_button_pin
mode: INPUT_PULLUP
name: "Middle button"
on_press:
then:
- switch.toggle: displaycontrol
- platform: gpio
pin:
number: $right_button_pin
inverted: true
name: "Right button"
on_press:
then:
- number.increment: screen_brightness
# example to switch to next screen
# lambda: |-
# id(rgb8x32)->skip_screen();
# Enable Home Assistant API
api:
services:
- service: brightness_set
variables:
brightness: int
then:
lambda: |-
id(rgb8x32)->set_brightness(brightness);
- service: skip_screen
then:
lambda: |-
id(rgb8x32)->skip_screen();
#disabled, we dont need the buzzer
# - service: tuneplay
# variables:
# tune: string
# then:
# - rtttl.play:
# rtttl: !lambda 'return tune;'
number:
- platform: template
name: "Brightness"
id: screen_brightness
min_value: 0
max_value: 255
update_interval: 10s
step: 1
lambda: |-
return id(rgb8x32)->get_brightness();
set_action:
lambda: |-
id(rgb8x32)->set_brightness(x);
switch:
- platform: template
name: "Display"
id: displaycontrol
icon: "mdi:power"
restore_mode: ALWAYS_ON
lambda: |-
return id(rgb8x32)->show_display;
turn_on_action:
lambda: |-
//just execute when is_running, otherwise we would manipulate display_enabled on an not so good point in time
if(id(is_running) == true)
{
id(rgb8x32)->set_display_on();
id(display_enabled) = true;
}
turn_off_action:
lambda: |-
//just execute when is_running, otherwise we would manipulate display_enabled on an not so good point in time
if(id(is_running) == true)
{
id(rgb8x32)->set_display_off();
id(display_enabled) = false;
}
- platform: template
name: "Auto-Adjust Brightness"
id: switch_autobrightness
icon: mdi:brightness-auto
restore_mode: ALWAYS_ON
lambda: |-
return(id(aab_enabled));
turn_on_action:
lambda: |-
id(aab_enabled) = true;
turn_off_action:
lambda: |-
id(aab_enabled) = false;
- platform: template
name: "Night mode"
id: switch_night_mode
icon: mdi:sleep
restore_mode: ALWAYS_ON
lambda: |-
return id(rgb8x32)->night_mode;
turn_on_action:
lambda: |-
//just execute when is_running, otherwise we would manipulate night_mode_enabled on an not so good point in time
if(id(is_running) == true)
{
id(rgb8x32)->set_night_mode_on();
id(night_mode_enabled) = true;
}
turn_off_action:
lambda: |-
//just execute when is_running, otherwise we would manipulate night_mode_enabled on an not so good point in time
if(id(is_running) == true)
{
id(rgb8x32)->set_night_mode_off();
id(night_mode_enabled) = false;
}
sensor:
- platform: sht3xd
temperature:
name: "Temperature"
humidity:
name: "Humidity"
update_interval: 60s
- platform: adc
id: light_sensor
name: "Illuminance"
pin: $ldr_pin
device_class: illuminance
update_interval: 10s
attenuation: auto
unit_of_measurement: lx
accuracy_decimals: 0
filters:
- lambda: |-
return (x / 10000.0) * 2000000.0 - 15 ;
on_value:
then:
- lambda: |-
if ( id(aab_enabled) ) {
int n = x / 4 + id(aab_add); // new_value
if (n > id(aab_max)) n = id(aab_max);
if (n < $aab_min) n = $aab_min;
int c = id(rgb8x32)->get_brightness(); // current value
c = c>0?c:1 ;
int d = (n - c) * 100 / c; // diff in %
if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n);
}
#disabled, we dont need the buzzer
#output:
# - platform: ledc
# pin: $buzzer_pin
# id: rtttl_out
#rtttl:
# output: rtttl_out
#The hardware design of the ulanzi isn't perfect. If your ulanzi makes a crazy beeping noise after removinf the rtttl-component you may use this setting to make it silent again.
output:
- platform: gpio
pin: GPIO15
id: crazy_hardware_workaround
i2c:
sda: $sda_pin
scl: $scl_pin
scan: true
id: i2cbus
light:
- platform: neopixelbus
id: ehmtx_light
type: GRB
internal: true
variant: WS2812
pin: $matrix_pin
num_leds: 256
color_correct: [30%, 30%, 30%]
gamma_correct: 2.0
name: "Light"
restore_mode: ALWAYS_OFF
time:
- platform: homeassistant
on_time_sync:
then:
ds1307.write_time:
- platform: ds1307
update_interval: never
id: ehmtx_time
display:
- platform: addressable_light
id: ehmtx_display
addressable_light_id: ehmtx_light
width: 32
height: 8
pixel_mapper: |-
if (y % 2 == 0) {
return (y * 32) + x;
}
return (y * 32) + (31 - x);
rotation: 0°
update_interval: 16ms
auto_clear_enabled: true
lambda: |-
id(rgb8x32)->tick();
id(rgb8x32)->draw();
Logs
EHMTXv2:1026]: oldest queue element not found
[07:37:42][D][EHMTXv2:180]: queue: UPPS
[07:37:42][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:42][I][on_empty_queue:180]: set display on!
[07:37:42][D][EHMTXv2:158]: display on
[07:37:42][I][on_empty_queue:191]: set night mode on!
[07:37:42][D][EHMTXv2:180]: night mode on
[07:37:42][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:42][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:42][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:42][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:42][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:42][W][component:232]: Component display took a long time for an operation (63 ms).
[07:37:42][W][component:233]: Components should block for at most 30 ms.
[07:37:42][C][logger:166]: Logger:
[07:37:42][W][component:232]: Component display took a long time for an operation (62 ms).
[07:37:42][W][component:233]: Components should block for at most 30 ms.
[07:37:42][C][i2c.arduino:059]: I2C Bus:
[07:37:42][C][i2c.arduino:060]: SDA Pin: GPIO21
[07:37:42][C][i2c.arduino:061]: SCL Pin: GPIO22
[07:37:42][C][i2c.arduino:062]: Frequency: 50000 Hz
[07:37:42][C][i2c.arduino:065]: Recovery: bus successfully recovered
[07:37:42][I][i2c.arduino:075]: Results from i2c bus scan:
[07:37:42][I][i2c.arduino:081]: Found i2c device at address 0x44
[07:37:42][I][i2c.arduino:081]: Found i2c device at address 0x68
[07:37:42][D][EHMTXv2:1026]: oldest queue element not found
[07:37:42][D][EHMTXv2:180]: queue: UPPS
[07:37:42][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:42][I][on_empty_queue:180]: set display on!
[07:37:42][D][EHMTXv2:158]: display on
[07:37:42][I][on_empty_queue:191]: set night mode on!
[07:37:42][D][EHMTXv2:180]: night mode on
[07:37:42][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:42][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:42][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:42][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:42][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:42][W][component:232]: Component display took a long time for an operation (67 ms).
[07:37:42][W][component:233]: Components should block for at most 30 ms.
[07:37:42][D][EHMTXv2:1026]: oldest queue element not found
[07:37:42][D][EHMTXv2:180]: queue: UPPS
[07:37:42][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:42][I][on_empty_queue:180]: set display on!
[07:37:42][D][EHMTXv2:158]: display on
[07:37:42][I][on_empty_queue:191]: set night mode on!
[07:37:42][D][EHMTXv2:180]: night mode on
[07:37:42][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:42][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:42][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:42][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:42][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:42][W][component:232]: Component display took a long time for an operation (62 ms).
[07:37:42][W][component:233]: Components should block for at most 30 ms.
[07:37:42][C][uptime.sensor:031]: Uptime Sensor 'Uptime'
[07:37:42][C][uptime.sensor:031]: Device Class: 'duration'
[07:37:42][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:42][I][on_empty_queue:180]: set display on!
[07:37:42][D][EHMTXv2:158]: display on
[07:37:42][I][on_empty_queue:191]: set night mode on!
[07:37:42][D][EHMTXv2:180]: night mode on
[07:37:42][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:42][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:42][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:42][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:42][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:42][W][component:232]: Component display took a long time for an operation (64 ms).
[07:37:42][W][component:233]: Components should block for at most 30 ms.
[07:37:42][C][gpio.output:010]: GPIO Binary Output:
[07:37:42][C][gpio.output:011]: Pin: GPIO15
[07:37:42][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Left button'
[07:37:43][C][gpio.binary_sensor:016]: Pin: GPIO26
[07:37:43][D][EHMTXv2:1026]: oldest queue element not found
[07:37:43][D][EHMTXv2:180]: queue: UPPS
[07:37:43][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:43][I][on_empty_queue:180]: set display on!
[07:37:43][D][EHMTXv2:158]: display on
[07:37:43][I][on_empty_queue:191]: set night mode on!
[07:37:43][D][EHMTXv2:180]: night mode on
[07:37:43][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:43][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:43][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:43][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:43][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:43][W][component:232]: Component display took a long time for an operation (62 ms).
[07:37:43][W][component:233]: Components should block for at most 30 ms.
[07:37:43][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Middle button'
[07:37:43][C][gpio.binary_sensor:016]: Pin: GPIO27
[07:37:43][D][EHMTXv2:1358]: on_empty_queue trigger
[07:37:43][I][on_empty_queue:180]: set display on!
[07:37:43][D][EHMTXv2:158]: display on
[07:37:43][I][on_empty_queue:191]: set night mode on!
[07:37:43][D][EHMTXv2:180]: night mode on
[07:37:43][D][EHMTXv2:2082]: clock_screen_color lifetime: 1440 screen_time: 10 red: 235 green: 0 blue: 0
[07:37:43][D][EHMTXv2:104]: queue: clock for: 10.0 sec
[07:37:43][I][EHMTXv2:2335]: set_brightness 20 => 7.84 %
[07:37:43][D][EHMTXv2:2096]: date_screen lifetime: 1440 screen_time: 5 red: 240 green: 240 blue: 240
[07:37:43][D][EHMTXv2:107]: queue: date for: 5.0 sec
[07:37:43][W][component:232]: Component display took a long time for an operation (63 ms).
[07:37:43][W][component:233]: Components should block for at most 30 ms.
[07:37:43][C][light:103]: Light 'Light'
[07:37:43][C][light:105]: Default Transition Length: 1.0s
[07:37:43][C][light:106]: Gamma Correct: 2.00
[07:37:43][C][template.switch:068]: Template Switch 'Display'
[07:37:43][C][template.switch:070]: Icon: 'mdi:power'
[07:37:43][D][EHMTXv2:104]: queue: clock for: 10.0 sec