lubeda / EspHoMaTriXv2

A simple DIY status display with a 8x32 RGB LED matrix, implemented with esphome.io and Home Assistant.
MIT License
302 stars 30 forks source link

I`m preparing a release #190

Open lubeda opened 11 months ago

lubeda commented 11 months ago

Hi there, in the last time there were so many new features added (thanx @andrewjswan a) that it is now necessary to restructure the repo, clean it up and make the documentation easier to read and understand. I'm preparing it in the 2024.1.0-prerelease branch.

So stay calm, until the new release (with no new features), I suggest using the 2023.9.1 branch.

See you soon.

andrewjswan commented 10 months ago

So queue is not empty and no clock is shown.

Look https://github.com/lubeda/EspHoMaTriXv2/issues/93

popy2k14 commented 10 months ago

So queue is not empty and no clock is shown.

Look #93

That's exactly my issue! I don't see permanent screens in the documentation, so I am assuming that is not implemented? Should I'll open an issue for that?

My workaround for now:

#workaround that clock doesnt disappear after lifetime

interval:
  - interval: 720min
    then:
      lambda: |-
        ESP_LOGI("clock/date", "set clock and date screen!");
        id(rgb8x32)->clock_screen(1440,10);
        id(rgb8x32)->date_screen(1440,5);

That should keep the clock alive.

andrewjswan commented 10 months ago

The Issue was not opened, apparently everyone decided it similar to your solution, I recreate it once a day.

Whether to open it or not is up to you.

popy2k14 commented 10 months ago

Done see #208

popy2k14 commented 10 months ago

As stated, since I am on 2024.1.0 the clock crashes 50% after OTA (black screen) and needs a serial reflash to bring it back to live. This happens on my two clocks. Two times also just a few minutes after flash. The WAF is currently not so high, so I reverted to V1, and all runs fine again.

PS: maybe it has Todo with my HW mods (always on mod + no battery + DC/DC converter).

But as stated it's rock solid on v1

andrewjswan commented 10 months ago

This happens on my two clocks.

I have Ulanzy TC001 and no problem? In you clock Esp32? or 8266? Maybe decrease icon count and check?

popy2k14 commented 10 months ago

I have two ulanzi's with ESP32 and both showed the issue. It's not just an Software crash. And cold start (unplug and replug) does NOT solve the issue. As stated the clock's are dead! I have to reflash them.

Sorry the WAF was very low, i am now back at v1 since two days, and they are running flawlessly. Currently cant help debug any further.

andrewjswan commented 10 months ago

Yesterday I flashed Ulanzi without any problems.

andrewjswan commented 9 months ago

Look like we need 2024.2.0 release :)

andreasbrett commented 9 months ago

Looks like we need a 2024.3.0 release ;-P

lubeda commented 9 months ago

OK, I released a very but didn't improve the documentation like I had planned. :-( Too much work too few time!

Thanks for your support!

riker09 commented 9 months ago

You (and all the other contributors) are doing an amazing job. Thanks so much for all your hard work on this helpful software.

popy2k14 commented 8 months ago

@andrewjswan here is a serial log when the issue described above happens. It just doesnt boot anymore after a while:

[I][logger:158]: Log initialized
[C][ota:483]: There have been 9 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][EHMTXv2:024]: Constructor start
[D][EHMTXv2:199]: default today color r: 240 g: 240 b: 240
[D][EHMTXv2:205]: default weekday color: 100 g: 100 b: 100
[D][EHMTXv2:074]: Constructor finish
[D][EHMTXv2:2754]: add_icon no.: 0 name: ha frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 1 name: tempc frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 2 name: plug frame_duration: 192 ms
[D][EHMTXv2:2754]: add_icon no.: 3 name: humidity frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 4 name: co2 frame_duration: 300 ms
[D][EHMTXv2:2754]: add_icon no.: 5 name: weather_clear_night frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 6 name: weather_cloudy frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 7 name: weather_fog frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 8 name: weather_hail frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 9 name: weather_lightning frame_duration: 400 ms
[D][EHMTXv2:2754]: add_icon no.: 10 name: weather_lightning_rainy frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 11 name: weather_partlycloudy frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 12 name: weather_pouring frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 13 name: weather_rainy frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 14 name: weather_snowy frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 15 name: weather_snowy_rainy frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 16 name: weather_sunny frame_duration: 500 ms
[D][EHMTXv2:2754]: add_icon no.: 17 name: weather_windy frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 18 name: weather_windy_variant frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 19 name: weather_exceptional frame_duration: 20 ms
[D][EHMTXv2:2754]: add_icon no.: 20 name: washing_machine_ready frame_duration: 200 ms
[D][EHMTXv2:2754]: add_icon no.: 21 name: dryer_ready frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 22 name: dishwasher_ready frame_duration: 300 ms
[D][EHMTXv2:2754]: add_icon no.: 23 name: door_ringing frame_duration: 300 ms
[D][EHMTXv2:2754]: add_icon no.: 24 name: fire frame_duration: 100 ms
[D][EHMTXv2:2754]: add_icon no.: 25 name: water frame_duration: 200 ms
[D][EHMTXv2:2329]: set_display
[D][EHMTXv2:2407]: set_clock
[I][EHMTXv2:2309]: set_brightness 80 => 31.37 %
[I][EHMTXv2:1515]: replace_time_date off
[I][EHMTXv2:2300]: don't show day of week
[I][EHMTXv2:2294]: don't show seconds
[I][app:029]: Running through setup()...
[I][i2c.arduino:197]: Performing I2C bus recovery
[D][binary_sensor:034]: 'Left button': Sending initial state OFF
[D][binary_sensor:034]: 'Middle button': Sending initial state OFF
[D][binary_sensor:034]: 'Right button': Sending initial state OFF
[C][light:035]: Setting up light 'Light'...
[D][light:036]: 'Light' Setting:
[D][light:041]:   Color mode: RGB
[D][light:085]:   Transition length: 1.0s
[D][template.switch:046]:   Restored state OFF
[D][switch:016]: 'Display' Turning OFF.
[D][EHMTXv2:142]: display off
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d37a4  PS      : 0x00060c30  A0      : 0x800dba33  A1      : 0x3ffb2380
A2      : 0x00000000  A3      : 0x401ba5f8  A4      : 0x00000000  A5      : 0x00000000
A6      : 0x00000008  A7      : 0x00000000  A8      : 0x800d379c  A9      : 0x3ffb2360
A10     : 0x00000000  A11     : 0x3ffb2388  A12     : 0x3ffb238c  A13     : 0x00007ffe
A14     : 0x0000000b  A15     : 0x00000010  SAR     : 0x00000004  EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000  LBEG    : 0x4008b191  LEND    : 0x4008b1a1  LCOUNT  : 0xffffffff

Backtrace:0x400d37a1:0x3ffb23800x400dba30:0x3ffb23b0 0x401b8af9:0x3ffb23e0 0x400db6d9:0x3ffb2400 0x400db709:0x3ffb2420 0x400db6be:0x3ffb2440 0x400dec92:0x3ffb2460 0x400fb018:0x3ffb2480 0x400faed5:0x3ffb24a0 0x401ba4d7:0x3ffb24c0 0x401b9a79:0x3ffb24e0 0x400f10f9:0x3ffb2500 0x400f0a73:0x3ffb2520 0x400f1080:0x3ffb2540 0x400f108e:0x3ffb2570 0x401b9f55:0x3ffb2590 0x401b9ff1:0x3ffb25b0 0x400f91e1:0x3ffb25d0 0x400fef22:0x3ffb2600 0x4010d12a:0x3ffb2820

ELF file SHA256: 0000000000000000

Rebooting...

And here is part of important yaml:

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.3.0
    refresh: 120min
    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: default_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_enable
    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: aab_min
    type: int
    initial_value: '40'

ehmtxv2:
  id: rgb8x32
  icons2html: true
  matrix_component: ehmtx_display
  time_component: ehmtx_time
  time_format: "%H:%M"
  date_format: "%d.%m"
  show_seconds: false
  # Uncomment below if using the mateine font
  default_font_id: default_font
  special_font_id: default_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: "[60000, 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
  on_empty_queue:
    then:
      lambda: |-
        id(rgb8x32)->clock_screen(1440,10);
        id(rgb8x32)->date_screen(1440,5);
  on_start_running:
     then:
       lambda: |-
          id(rgb8x32)->clock_screen(1440,10);
          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_enable) = false;
            id(rgb8x32)->set_brightness(20);
            id(rgb8x32)->set_clock_color(235, 0, 0);
        } else {
            id(aab_enable) = true;
            id(rgb8x32)->set_clock_color(255, 255, 255);
        }

#workaround that clock doesnt disappear after lifetime
interval:
  - interval: 720min
    then:
      lambda: |-
        ESP_LOGI("clock/date", "set clock and date screen!");
        id(rgb8x32)->clock_screen(1440,10);
        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: 1s
    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: RESTORE_DEFAULT_ON
    lambda: |-
      return id(rgb8x32)->show_display;
    turn_on_action:
      lambda: |-
        id(rgb8x32)->set_display_on();
    turn_off_action:
      lambda: |-
        id(rgb8x32)->set_display_off();
  - platform: template
    name: "Auto-Adjust Brightness"
    id: switch_autobrightness
    icon: mdi:brightness-auto
    restore_mode: RESTORE_DEFAULT_ON
    lambda: |-
      if (id(aab_enable)) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      lambda: |-
        id(aab_enable) = true;
    turn_off_action:
      lambda: |-
        id(aab_enable) = false;
  - platform: template

    name: "Night mode"
    id: switch_night_mode
    icon: mdi:sleep
    restore_mode: RESTORE_DEFAULT_OFF
    lambda: |-
        return id(rgb8x32)->night_mode;
    turn_on_action:
      lambda: |-
        id(rgb8x32)->set_night_mode_on();
    turn_off_action:
      lambda: |-
        id(rgb8x32)->set_night_mode_off();

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_enable) ) {
              int n = x / 4 + id(aab_add); // new_value
              if (n > id(aab_max)) n = id(aab_max);
              if (n < id(aab_min)) n = id(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();

As stated, v1 is running without an issue.

I think it has todo with the display switch restore state to off, calling "id(rgb8x32)->set_display_off();" on boot.

[D][template.switch:046]:   Restored state OFF
[D][switch:016]: 'Display' Turning OFF.
[D][EHMTXv2:142]: display off
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

When the display was on (written to flash) before reboot the clock boots up normally after power down. The log then looks like:

[C][light:035]: Setting up light 'Light'...
[D][light:036]: 'Light' Setting:
[D][light:041]:   Color mode: RGB
[D][light:085]:   Transition length: 1.0s
**[D][template.switch:046]:   Restored state ON
[D][switch:012]: 'Display' Turning ON.
[D][EHMTXv2:154]: display on**
[D][template.switch:046]:   Restored state ON
[D][switch:012]: 'Auto-Adjust Brightness' Turning ON.

So it seems when calling "id(rgb8x32)->set_display_off();" during boot, it fails.

Any chance that you use my config to reproduce the issue?

Thank you

popy2k14 commented 8 months ago

Now i can reproduce the issue!

popy2k14 commented 8 months ago

Easier to reproduce, just add the following switch with "restore_mode: ALWAYS_OFF":

switch:
  - platform: template
    name: "Display"
    id: displaycontrol
    icon: "mdi:power"
    **restore_mode: ALWAYS_OFF**
    lambda: |-
      return id(rgb8x32)->show_display;
    turn_on_action:
      lambda: |-
        id(rgb8x32)->set_display_on();
    turn_off_action:
      lambda: |-
        id(rgb8x32)->set_display_off();

The issue happens immediately on boot. I am not so deep in the esphomematrix v2 code.

@andrewjswan Can you please look into the issue?

Thank you

popy2k14 commented 8 months ago

@andrewjswan @lubeda i have created an issue here: https://github.com/lubeda/EspHoMaTriXv2/issues/222

andrewjswan commented 1 month ago

I think we should do a release, or there is confusion about the branches. Maybe we should put all the changes into main, and then people will get to the current version at once.