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

Character not being rendered correctly even it's in the font #189

Open Alex-joomla opened 11 months ago

Alex-joomla commented 11 months ago

Question

I call a service node in node red to add a Icon_screen:

{
    "icon_name": "dishwasher",
    "text": "{{payload}}",
    "lifetime": "1",
    "screen_time": "1",
    "r": 255,
    "g": 255,
    "b": 255,
    "default_font": true
}

payload is this: "Geschirrspüler: finished / noch 0 Minuten"

But what I get are two big white blocks with a x2F in the middle instead of the Dash. The Dash is a Glyph, i know, but it's availible in my font:

font:
  - file: CalciumThin.ttf
    id: default_font
    size: 16
    glyphs:  |
      !?"%‰()+*=,'-_.:°µ²³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz€$@<>/

Logs

Additional context

trip5 commented 11 months ago

This likely isn't an issue with ehmtx. Like the dash being used in the payload isn't the same as the hyphen-dash you're including in the glyphs section. Node red may be giving you an em dash or en dash...?

Edit: sorry I was working from my phone and I didn't realize that is a slash... but still, this isn't an ehtmx problem. It's a character-encoding problem.

I'm pretty sure the payload is including CR or LF characters which are not going to be interpreted well by anything in mqtt... I don't have experience with Node red but perhaps you can copy and paste the entire payload into Notepad++ and view hidden characters and see if I'm right...

Another solution is to try to move the punctuation in the encoding a bit, sandwiching it between known "good" characters because maybe ESPHome is interpreting the string badly... try this:

!?"%‰()+*=,'-_.:°µ²³0123456789€$@<>/ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz

If that doesn't work, try using the font in my own repo to test another font. I'm sure mine does have those characters. Too many fonts are missing punctuation characters...

Please do return to this thread with an update if you can/can't fix the issue.

Alex-joomla commented 11 months ago

Thank you for your hints. Interesting thing is: if I feed the glyph into the call service node via a flow it gets rendered incoreectly. But if I type it directly in the call service node, it works. Wont work:

Bildschirmfoto 2023-12-28 um 18 49 27

Works:

Bildschirmfoto 2023-12-28 um 18 51 41

Should I take it to a NodeRed Forum?

trip5 commented 11 months ago

Probably? I've somehow missed adding Nodered to my setup.

It's a bit weird... 2F is clearly the code for the solidus slash... but the blocks around it are unprintable characters / characters not available in the font (they could be anything, even a 00 null character)... you should probably find out what those are...

Try viewing the payload through Home Assistant in developer services and copying and pasting into Notepad++ as I said. You'll have a better idea of what exactly the problem is.

Addition: You might be able to do a character filter either through Home Assistant or the folks in Nodered forums might be able to help.

trip5 commented 3 months ago

Did you ever work this out?