lubeda / EspHoMaTriXv2

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

[BUG] can't update esphome to firmware 4.5 #14

Closed idodov closed 1 year ago

idodov commented 1 year ago

Error OTA updating & Error compiling with no more info at the log

lubeda commented 1 year ago

If OTA isn't working try update via USB! Compile errors do always have a log entry! What do you mean with firmware 4.5?

ehmtx does work on my ulanzi after update of esphome to 2023.5.0.

trip5 commented 1 year ago

Copy and paste your ESPHome log output if you want some help. Also, do you have any experience with ESPHome? This is tough project for a first run with ESPHome... What's your hardware? Is it an Ulanzi?

If this is all true, might I recommend downloading a legacy bin to your computer, plugging the Ulanzi in, then flashing with Tasmotizer instead?

Ulanzis appear to have some variation BTW. I have two and one is much more finicky than the other about being flashed. Both make a different squealing sound when in flash mode, too. They're wonderful but weird.

idodov commented 1 year ago

Sorry. I was talking about version 5.0 from today.

Here is the log. Any help will be helpful


Updating /config/esphome/pixel.yaml
------------------------------------------------------------

INFO Reading configuration /config/esphome/pixel.yaml...
INFO Updating https://github.com/lubeda/EspHoMaTriXv2@main
WARNING 
WARNING This is a beta version of https://github.com/lubeda/EspHoMaTriXv2
WARNING 
WARNING GPIO15 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Detected timezone 'Asia/Jerusalem'
INFO Detected timezone 'Asia/Jerusalem'
INFO Generating C++ source...
INFO Preparing icons, this may take some seconds.
INFO EsphoMaTrix: wrote html-file with icon preview: /config/esphome/pixel.html
INFO List of icons for e.g. blueprint:

["error","music","tv","home_assistant","temperature","lightbulb","music2","phone","car","sleep8x32",]

INFO Compiling app...
Processing ulanzi (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.3.0)
--------------------------------------------------------------------------------
Library Manager: Installing SPI
INFO Installing SPI
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 1.2.2
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 2.1.0
|   |-- AsyncTCP-esphome @ 1.2.2
|-- ESPmDNS @ 2.0.0
|-- Wire @ 2.0.0
|-- ArduinoJson @ 6.18.5
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
|-- NeoPixelBus @ 2.7.3
|   |-- SPI @ 2.0.0
Compiling /data/ulanzi/.pioenvs/ulanzi/src/main.cpp.o
/config/esphome/pixel.yaml: In lambda function:
/config/esphome/pixel.yaml:299:14: error: 'x' was not declared in this scope
           iconname: !lambda "return x.c_str();"
              ^
/config/esphome/pixel.yaml: In lambda function:
/config/esphome/pixel.yaml:300:14: error: 'y' was not declared in this scope
           text: !lambda "return y.c_str();"
              ^
/config/esphome/pixel.yaml:300:14: note: suggested alternative: 'yn'
           text: !lambda "return y.c_str();"
              ^
              yn
In file included from src/esphome.h:12,
                 from src/main.cpp:3:
src/esphome/components/api/homeassistant_service.h: In instantiation of 'esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]':
src/esphome/components/api/homeassistant_service.h:27:108:   required from 'esphome::api::TemplatableKeyValuePair<Ts>::TemplatableKeyValuePair(std::__cxx11::string, T) [with T = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; Ts = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/esphome/components/api/homeassistant_service.h:42:36:   required from 'void esphome::api::HomeAssistantServiceCallAction<Ts>::add_data_template(std::__cxx11::string, T) [with T = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; Ts = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
/config/esphome/pixel.yaml:300:4:   required from here
src/esphome/components/api/homeassistant_service.h:22:90: error: invalid use of void expression
       : TemplatableValue<std::string, X...>([f](X... x) -> std::string { return to_string(f(x...)); }) {}
                                                                                 ~~~~~~~~~^~~~~~~~~
src/esphome/components/api/homeassistant_service.h: In instantiation of 'esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]':
src/esphome/components/api/homeassistant_service.h:27:108:   required from 'esphome::api::TemplatableKeyValuePair<Ts>::TemplatableKeyValuePair(std::__cxx11::string, T) [with T = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; Ts = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/esphome/components/api/homeassistant_service.h:42:36:   required from 'void esphome::api::HomeAssistantServiceCallAction<Ts>::add_data_template(std::__cxx11::string, T) [with T = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; Ts = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
/config/esphome/pixel.yaml:301:4:   required from here
src/esphome/components/api/homeassistant_service.h:22:90: error: invalid use of void expression
In file included from src/esphome/components/display/display_buffer.h:5,
                 from src/esphome/components/addressable_light/addressable_light_display.h:5,
                 from src/esphome.h:4,
                 from src/main.cpp:3:
src/esphome/core/automation.h: At global scope:
src/esphome/core/automation.h:33:3: error: 'esphome::TemplatableValue<T, X>::TemplatableValue(F) [with F = esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]::<lambda(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; T = std::__cxx11::basic_string<char>; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]', declared using local type 'esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]::<lambda(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>)>', is used but never defined [-fpermissive]
   TemplatableValue(F f) : type_(LAMBDA), f_(f) {}
   ^~~~~~~~~~~~~~~~
src/esphome/core/automation.h:33:3: error: 'esphome::TemplatableValue<T, X>::TemplatableValue(F) [with F = esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]::<lambda(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; T = std::__cxx11::basic_string<char>; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]', declared using local type 'esphome::api::TemplatableStringValue<X>::TemplatableStringValue(F) [with F = setup()::<lambda(std::__cxx11::string, std::__cxx11::string)>; typename std::enable_if<esphome::is_invocable<F, X ...>::value, int>::type <anonymous> = 0; X = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]::<lambda(std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>)>', is used but never defined [-fpermissive]
Compiling /data/ulanzi/.pioenvs/ulanzi/lib248/noise-c/protocol/errors.c.o
Compiling /data/ulanzi/.pioenvs/ulanzi/lib248/noise-c/protocol/handshakestate.c.o
Compiling /data/ulanzi/.pioenvs/ulanzi/lib248/noise-c/protocol/hashstate.c.o
Compiling /data/ulanzi/.pioenvs/ulanzi/lib248/noise-c/protocol/internal.c.o
*** [/data/ulanzi/.pioenvs/ulanzi/src/main.cpp.o] Error 1
Compiling /data/ulanzi/.pioenvs/ulanzi/lib248/noise-c/protocol/names.c.o
========================= [FAILED] Took 15.01 seconds =========================
============ [ERROR] /config/esphome/pixel.yaml ============```

Here is the yaml

```substitutions:
  devicename: ulanzi
  ledpin: GPIO32 
  buzzerpin: GPIO15
  friendly_name: LED Matrix
  board: esp32dev
  # 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 
  buzzer_pin: GPIO15 
  scl_pin: GPIO22 
  sda_pin: GPIO21 

switch:
  - 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: "$devicename Display"
    icon: "mdi:power"
    restore_mode: ALWAYS_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();

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: '20'

external_components:
  - source:
      type: git
      url: https://github.com/lubeda/EspHoMaTriXv2
      ref: main
    refresh: 60s 
    components: [ ehmtxv2 ]   

esphome:
  comment: "EHMTXv2 from LuBeDa"
  name: $devicename 
  on_boot:
    then:
      - ds1307.read_time:
      - delay: 30s        
      - lambda: |-
          id(rgb8x32)->del_screen("*",3);

esp32:
  board: esp32dev

font:
  - file: hebpixel.ttf
    size: 16
    id: default_font
    glyphs:  |
      !?'"%&[]()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüèéēøopqrstuvwxyzאבגדהוזחטיכךלמםנןסעפףצץקרשת@$<>|\/
  - file: ehmtx.ttf
    size: 16
    id: special_font
    glyphs:  |
      !?'"%&[]()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüèéēøopqrstuvwxyzאבגדהוזחטיכךלמםנןסעפףצץקרשת@$<>|\/

binary_sensor:
  - platform: status
    name: "$devicename Status"
  - platform: gpio
    pin:
      number: $left_button_pin
      inverted: true
    name: "Left button"
  - platform: gpio
    pin: 
      inverted: true
      number: $mid_button_pin
      mode: INPUT_PULLUP
    name: "Middle button"
  - platform: gpio
    pin: 
      number: $right_button_pin
      inverted: true
    name: "Right button"

logger:
  level: WARN

api:
  encryption:
    key: !secret esphome_enctyption
  services:
    - service: tune
      variables:
        tune: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return tune;'

sensor:
  - platform: sht3xd
    temperature:
      name: "$devicename Temperature"
    humidity:
      name: "$devicename Relative Humidity"
    update_interval: 60s
  - platform: adc
    pin: $battery_pin
    name: "$devicename Battery"
    id: battery_voltage
    update_interval: 10s
    device_class: battery
    accuracy_decimals: 0
    attenuation: auto
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 1
      - multiply: 1.6
      - lambda: |-
          auto r = ((x - 3) / 0.69 * 100.00);
          if (r >= 100) return 100;
          if (r > 0) return r;
          if (r <= 0) return 1;
          return 0;
    unit_of_measurement: '%'
  - platform: adc
    id: light_sensor
    name: "$devicename Illuminance"
    pin: $ldr_pin
    update_interval: 10s
    attenuation: auto
    unit_of_measurement: lx
    device_class: illuminance
    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
              int d = (n - c) * 100 / c; // diff in %
              if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n);
            }

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

web_server:

output:
  - platform: ledc
    pin: $buzzerpin
    id: rtttl_out

rtttl:
  output: rtttl_out

i2c:
  sda: $sda_pin
  scl: $scl_pin
  scan: true
  id: i2cbus

light:
  - platform: neopixelbus
    id: ehmtx_light
    type: GRB
    internal: True
    variant: WS2812
    pin: $ledpin
    num_leds: 256
    color_correct: [30%, 30%, 30%]
    gamma_correct: 2.0
    name: "$devicename Light"
    restore_mode: ALWAYS_OFF
#    effects:
#      - e131:
#          universe: 1
#          channels: RGB
    on_turn_on:
      lambda: |-
         id(ehmtx_display)->set_enabled(false);
    on_turn_off:
       lambda: |-
         id(ehmtx_display)->set_enabled(true);

#e131:
#  method: multicast

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();

ehmtxv2:
  id: rgb8x32
  icons2html: true
  matrix_component: ehmtx_display
  time_component: ehmtx_time
  time_format: "%H:%M:%S"
  date_format: "%d.%m"
  week_start_monday: false 
  show_dow: true
  show_seconds: false
  default_font_id: default_font
  default_font_yoffset: 6
  special_font_id: special_font
  icons: 
    - id: error
      lameid: 40530
    - id: music
      lameid: 5865
    - id: tv
      lameid: 10972
    - id: home_assistant
      lameid: 47693
    - id: temperature
      lameid: 2056
    - id: lightbulb
      lameid: 1762
    - id: music2
      lameid: 45625
    - id: phone
      lameid: 1232
    - id: car
      lameid: 2819
    - id: sleep8x32
      url: https://user-images.githubusercontent.com/16407309/224850723-634c9b2d-55d9-44f2-9f93-765c0485b090.gif 
  on_next_screen:
    - homeassistant.event:
        event: esphome.new_screen
        data_template:
          iconname: !lambda "return x.c_str();"
          text: !lambda "return y.c_str();"```
``
trip5 commented 1 year ago

Two things possible here. First check the basics. You have your ehtmxv2.ttf file in the same folder as your yaml?

Second, your Hebrew text will cause issues. The glyphs in the list MUST exist in the font file. Install the ttf to Windows and BE SURE of this. At 12kb, I'm pretty sure ehtmxv2.ttf doesn't have Hebrew characters. So trying to force it to add Hebrew glyphs that aren't in the ttf will absolutely fail. It's a pretty minimal European character set.

To be honest, try working with the basics first, then adding stuff bit-by-bit. Try doing as basic as you can make it, then after success, move onto the next step.

Ie. AFTER successfully making your first YAML based on the basic one here, then: 1) switch from ehtmxv2.ttf to a Hebrew ttf file (change the reference in your YAML file) - don't use 2 fonts yet. 2) add the Hebrew glyphs as below 3) test if the Hebrew text displays correctly 4) now start working with 2 fonts

Maybe try copying and pasting this? I removed the European characters in case you have to use an English/Hebrew-only font):

glyphs: |
  !?'"%&+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzאבגדהוזחטיכךלמםנןסעפףצץקרשת@$<>|/

And PS, in the future, use 3 of these ` to format your logs as above.

lubeda commented 1 year ago

ALSO remove the part in the yaml

starting with

on_next_screen to the end.

There where some changes!

idodov commented 1 year ago

Seems that I solved the problem. My yaml code and fonts are working perfect after removing this lines. `on_next_screen:

thank for your help and looking forward to the RTL direction support!

lubeda commented 1 year ago

For the RTL support: can you sketch what it should look like?

Like this for the word "text" ltr3 ltr2 ltr1

idodov commented 1 year ago

This is the order for RTL: First: 239053136-ad467132-fe54-45df-82fa-fb785360e768 Middle: 239053131-f3288faf-d950-4703-a45b-5ff70313d17f Last: 239053135-51f1867f-c171-40a7-b773-8156c1c95a15

The string start from Right to Left.

lubeda commented 1 year ago

Hi, is this the right way for rtl? https://youtu.be/mHEXAHn6b0A

idodov commented 1 year ago

Indeed, it appears that your camera was positioned upside down, necessitating the need to rotate the video. Here is the corrected version of the video: https://www.youtube.com/watch?v=jcc9m_tlyok

idodov commented 1 year ago

After having support for the direction of the given text string, If possible, could you consider adding support for the Bi-directional Text (BiDi) algorithm to your code?

Currently, ESPHome does not have native support for languages that are written in a right-to-left direction, such as Hebrew, Arabic, and others. The BiDi algorithm is a standard method for handling such languages.

You can find more information about the algorithm here: https://unicode-org.github.io/icu/userguide/transforms/bidi.html

There is an open-source solution available that addresses this issue, called the Bidi Reference C++ project. You can access it here:

https://unicode.org/Public/PROGRAMS/BidiReferenceCpp/v26/

Integrating this solution into your custom ESPHome code would greatly enhance its compatibility and usability for right-to-left languages.

Supporting the BiDi function is a killer feature for this kind of project, and it would greatly help users avoid using workarounds like string reversal to accommodate right-to-left languages automatically.

lubeda commented 1 year ago

Hi, after investigating some background information about bidi, I will not implement it in my software. Because it does not belong to driving the display. It is more about overall display handling. Especially the reversing of numbers and {[()]} is beyond my scope.

I see the problem, but I can't help.

idodov commented 1 year ago

It's ok. We still have some workaround method to handle the bidi problem