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

Integration removes lovelace resources at startup. #287

Closed
FloX-Dev opened this issue Aug 7, 2022 · 10 comments
Closed

Integration removes lovelace resources at startup. #287

FloX-Dev opened this issue Aug 7, 2022 · 10 comments

Comments

@FloX-Dev
Copy link

FloX-Dev commented Aug 7, 2022

Hello,

I have a problem with lovelace resources with the Wiser integration. When the integration is activated, the resources other than those of wiser seem to be deleted at each restart! This happens since I switched to the release (R3.1.2), I skipped some version, I can't say exactly from which version the problem started to occur.

The problem seems to be when injecting "/wiser/wiser-schedule-card.js" and "/wiser/wiser-zigbee-card.js" to lovelace resources.

Before HomeAssistant restart:
before

After restart:
after

@msp1974
Copy link
Collaborator

msp1974 commented Aug 7, 2022

I did see this a couple of times when developing the schedule card and reworked the way it adds and added lovelace as a dependancy to the manifest so that it had loaded before it tries to add.

I would say, however, that if these are already added to resources, it doesn't try to add them at each restart. Can you confirm that it really is happening at each restart or just when you have deleted them from resources and restarted. Can you also provide a diagnostics download from the wiser integration so i can see your install method and what else you have loading tomsee if it is related to that.

@FloX-Dev
Copy link
Author

FloX-Dev commented Aug 7, 2022

This happens every time Home Assistant is restarted.
config_entry-wiser-9321e043fb136dfb9a3c349204b82b40.json.txt

To test, I commented out lines 381 to 389 of the __init__.py, this immediately solved the problem. This seems to confirm that the problem occurs when the integration adds the resources.

@msp1974
Copy link
Collaborator

msp1974 commented Aug 7, 2022

Ok thx. I think this can only happen if it tries to add the resources before lovelace has fully loaded. Can i assume you are running this on good hardware and it restarts/loads HA pretty quickly?

I will look to find a more robust way of ensuring lovelace has loaded its resources before it tries to read/add the wiser ones.

Will let you know when i have something if you would be able to test it for me.

@FloX-Dev
Copy link
Author

FloX-Dev commented Aug 7, 2022

Home Assistant is launched in a LXD container with 2 cores of an i7-10700K and 12GB of Ram (with an NVMe SSD + a RAM cache). The reboot only takes a few seconds (usually between 2 and 5 sec). So yes a pretty good hardware for HA.

No problem, I can do additional tests if needed.

@msp1974
Copy link
Collaborator

msp1974 commented Aug 8, 2022

@FloX-Dev - I have amended the code in the Dev branch to wait for Lovelace resources to have loaded before adding/checking the wiser ones. Would you be able to test for me? You will need to delete the wiser resources and restart to know if working properly. Thanks

@FloX-Dev
Copy link
Author

FloX-Dev commented Aug 8, 2022

The resources are no longer deleted, but the two JS files for the integration are not added. Here is an error in the logs:

Aug 08 16:21:28 HomeAssistant hass[83136]: 2022-08-08 16:21:28.206 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Aug 08 16:21:28 HomeAssistant hass[83136]: Traceback (most recent call last):
Aug 08 16:21:28 HomeAssistant hass[83136]:   File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
Aug 08 16:21:28 HomeAssistant hass[83136]:     result = self.fn(*self.args, **self.kwargs)
Aug 08 16:21:28 HomeAssistant hass[83136]: TypeError: check_lovelace_resources_loaded() takes 0 positional arguments but 1 was given

@msp1974
Copy link
Collaborator

msp1974 commented Aug 8, 2022

Sorry, finding hard to test as even though I have pushed my dev env upto 6 cores of an Ryzen 3900X and 16GB mem, cannot recreate your issue.

Pull from dev again and try now. Thx

@FloX-Dev
Copy link
Author

FloX-Dev commented Aug 8, 2022

It works! I have tried a dozen times, the resources are correctly added without removing the others.
After thinking about it, I think my home assistant installation starts faster because I don't have HACS installed (I use my own update system, which is independent from HA).

@msp1974
Copy link
Collaborator

msp1974 commented Aug 8, 2022

Ah, yes that maybe the reason. Anyway, great news, will include this in next 3.1.4 release.

@msp1974
Copy link
Collaborator

msp1974 commented Aug 19, 2022

Have released fix in 3.1.4. Regards

@msp1974 msp1974 closed this as completed Aug 19, 2022
@msp1974 msp1974 mentioned this issue Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants