Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'floorplan.text_set' is broken since 1.0.37 #355

Closed
RadekHvizdos opened this issue Aug 15, 2023 · 11 comments
Closed

'floorplan.text_set' is broken since 1.0.37 #355

RadekHvizdos opened this issue Aug 15, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@RadekHvizdos
Copy link

RadekHvizdos commented Aug 15, 2023

Describe the bug
'floorplan.text_set' is broken since 1.0.37. It now requires a newline (\n) character to be present to print even single lines.

To Reproduce
Steps to reproduce the behavior:

  1. Edit a floorplan yaml to call floorplan.text_set with a oneline service_data:
state_action:
  - service: floorplan.text_set
    service_data: ANYTEXT

Kindy note that step 1 is if the YAML is edited in the GUI. See pictures in the end of the issue-report.

  1. Observe there is no text visible on the floorplan
  2. Append newline (\n) character to the floorplan (need to use js to print newlines):
state_action:
  - service: floorplan.text_set
    service_data: |
      >
        return ANYTEXT + '\n';
  1. Text is now visible

Expected behavior
Single line text should be visible without using an explicit newline

Images
image

@RadekHvizdos RadekHvizdos added the waiting on review Issues which are not categorized, yet. label Aug 15, 2023
@OzGav
Copy link
Contributor

OzGav commented Aug 15, 2023

Can’t reproduce. It’s still works fine for me?

@OzGav
Copy link
Contributor

OzGav commented Aug 15, 2023

Is your text in quotes?

@exetico
Copy link
Member

exetico commented Aug 15, 2023

Thank you for the bug report.

Have you checked the release notes for 1.0.36 and 1.0.37?

https://github.com/ExperienceLovelace/ha-floorplan/releases/tag/1.0.36

I've just tested this:

        - service: floorplan.text_set
          service_data:
            text: |
              > /* Split text to two tspans*/
              return 'Multiline\nTSPAN-Print';

That work as expected.

The same goes for:

          service_data: '${"Multiline\nTSPAN-Print2"}'

But I can confirm that the following doesn't work:

# Doesnt work...
        - service: floorplan.text_set
          service_data: 'Multiline\nTSPAN-Print2'

As a end-user I'd expect that to work, too. That's the only solution where I face any issues. I'll try and remember that case, next time I'm looking into the code-base (Update: That part is now created as a separate issue - See #356 ).

However, I'm unable to reproduce the bug you're talking about. So I need more information. Here's my tests:

        - service: floorplan.text_set
          service_data: ANYTEXT

This logic works just fine here, and is rendered as expected.

image

Same goes for:

        - service: floorplan.text_set
          service_data: |
            >
              return entity.state + '\n';

That works, too.

image

I need a full example with both a bit mor YAML, tested where you're able to:

  1. Reproduce the error
  2. Show the other text with new-line, which works as expected

And I'd need a sample SVG file too, to see if it's here where things get problematic. Kindly provide a stripped down version, to speed things up.

@RadekHvizdos
Copy link
Author

Here is my sample yaml, only the second text is populated:
floorplan

Here is the result, and the sample floorplan in Inkscape:
ha-inkscape

Here is a sample svg floorplan, very simple:
text

@OzGav
Copy link
Contributor

OzGav commented Aug 15, 2023

You don’t need to wrap basic text in braces.

So change ${“ANYTEXT1”}to “ANYTEXT1”

@RadekHvizdos
Copy link
Author

Hi @OzGav
Adding single or double quotes doesn't help, they get stripped from service_data when I click on save, and the text still isn't shown. Interestingly that now it doesn't need the newline in the js part, the quotes are enough for the text to be shown.

image

I am using Edge on Windows 10, pretty standard setup. I can see the same behavior on my HA app on android.

@OzGav
Copy link
Contributor

OzGav commented Aug 16, 2023

Your further fault finding may prove useful. Of interest I don’t edit via the UI so I don’t have the quotes stripped off. Not sure if that makes a difference at the end of the day but thought I would mention it. Thoughts @exetico

@exetico
Copy link
Member

exetico commented Aug 16, 2023

@RadekHvizdos Oh, edited in GUI. I need to check how it's formatted and provided to ha-floorplan through the Home Assistant YAML parser. I guess you know the workaround by now, but I'll keep this open.

I have updated the first post. Just edit it, if you disagree with something.

@exetico exetico added enhancement New feature or request and removed waiting on review Issues which are not categorized, yet. labels Aug 16, 2023
@RadekHvizdos
Copy link
Author

Hi @exetico,

Have you had time to look at this issue already?

Thanks,

@exetico
Copy link
Member

exetico commented Sep 21, 2023

I'm unable to reproduce this. Have I misunderstood something?

image

image

This fails, as expected:
image
image

Pay attention to ${'ANYTEXT1'} vs ${“ANYTEXT1”} (OzGav typed that, I'm not sure if that was an issue)

But changing that to ', and things works as expected, even in your SVG file:

image

image

The only thing I've notived, is IF I open up the GUI editor, and have the following displayed:

image

And change the text to something else, whenthen it jumps back to the initial text in the SVG, and doesn't fill it:
image

But that's not the bug you're referring to, right?

Another version of ha-floorplan are on the way. Let me know if it's still a problem in that one. I'll try and remember to link it here - else, check tomorrow, or saturday.

ha-floorplan does not have official support for the GUI editor, as it's not designed for that. It's rendering ha-floorplan every time a element is changed (well, at least in the master branch).

@exetico
Copy link
Member

exetico commented Sep 22, 2023

The things I've picked up in the conversation should be fixed in:
https://github.com/ExperienceLovelace/ha-floorplan/releases/tag/1.0.38

Let me know if you disagree.

@exetico exetico closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants