danielperna84 / hass-configurator

Configuration UI for Home Assistant
MIT License
306 stars 168 forks source link

File Editor formatting issues caused by a binary sensor (state attributes) #217

Closed jirimissbach closed 1 year ago

jirimissbach commented 2 years ago

The problem

FileEditor display gets broken by a HACS plugin. I have installed https://github.com/slesinger/HomeAssistant-PREdistribuce and added a basic configuration as follows:

binary_sensor:

This is scaping of the local electricity provider website, somehow the received result breaks the File Editor (tested in Chrome and Brave browser). Commenting out/disabling the plugin, removes the issue

A sample of the problem is shown on the attached picture, the oddly displayed text is actually state attribute of the newly created sensor "binary_sensor.hdo_aktualne"

Environment

Problem-relevant configuration

https://github.com/slesinger/HomeAssistant-PREdistribuce and added a basic configuration as follows:

binary_sensor:

Traceback/Error logs

Additional information image

I do understand that the plugin may be the cause of the issue but assuming FileEditor should not be broken by a content of a sensor. I can attach the particular full state attributes as well

danielperna84 commented 2 years ago

As I can't see the HTML I can't really pinpoint the issue. The configurator loads the entities, services etc. while loading the page. It is expected that the data is properly formatted in JSON with no special characters. The screenshot reveals, that there seem to be numerous (escaped) unicode-symbols or something like that. Hence the File Editor seems to fail to properly parse the data.

The editor is using default tools, which have worked for a couple of years now. Your problem seems to be an edge case I have never seen before. As I'm not really maintaining this project actively (except if big issues arise), I'll leave this issue open for others to find a solution.

In general the source of the problem is the data associated with those entities. In particular, as mentioned above, probably specials characters. I guess this information is useful to whoever wants to fix this issue.

Mustang1977 commented 1 year ago

i'm experiencing the same problem maybe someone can help to solve this? What has changed: 1) sensors created to reduce costs for water consumption 2) add the HACS mini graph card

Then I got the split screen as pictured above.

I made an gist: https://gist.github.com/Mustang1977/b5b8029b1c961b09c6fb99085b1981c8

danielperna84 commented 1 year ago

@Mustang1977

Thanks. I have saved the file to my computer. You can delete the gist now. 👍

It seems (at least) the sensor.watermeter is causing the problem. Its state is HTML, instead of a number or whatever it should be. I don't know if that's how it should be, or if there is still some configurational problem.

As a temporary workaround you could try to disable the entity in Home Assistant, then reload the file editor. That could help getting the editor back to be able to work with the files again. Then once you're done, you can enable the entity again.

I'll have a further look if I can make the editor not get stuck on this. But at first glance everything is looking properly escaped, so I'm not sure why it's causing this problem in the first place.

Edit:

I have narrowed it down a bit. It's the <script src=\"https://oi.esphome.io/v2/www.js\"></script> part of the entities state that is causing the problem.

Mustang1977 commented 1 year ago

thank you so much. I have tried to disable the sensor.watermeter but this is a read only entity. I have looked up Google but I can't acces the .storage folder true Studio Code Server (the only file reader I can use at this pont) any suggestions?

Mustang1977 commented 1 year ago

No idea what solved the problem, but I returned file editor ! Appreciate your help, thank you!