wiserHomeAssistantPlatform icon indicating copy to clipboard operation
wiserHomeAssistantPlatform copied to clipboard

Integration removes lovelace resources at startup.

Open FloX-Dev opened this issue 1 year ago • 2 comments

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

FloX-Dev avatar Aug 07 '22 15:08 FloX-Dev

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.

msp1974 avatar Aug 07 '22 16:08 msp1974

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.

FloX-Dev avatar Aug 07 '22 16:08 FloX-Dev

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.

msp1974 avatar Aug 07 '22 17:08 msp1974

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.

FloX-Dev avatar Aug 07 '22 17:08 FloX-Dev

@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

msp1974 avatar Aug 08 '22 14:08 msp1974

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

FloX-Dev avatar Aug 08 '22 14:08 FloX-Dev

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

msp1974 avatar Aug 08 '22 14:08 msp1974

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).

FloX-Dev avatar Aug 08 '22 14:08 FloX-Dev

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

msp1974 avatar Aug 08 '22 15:08 msp1974

Have released fix in 3.1.4. Regards

msp1974 avatar Aug 19 '22 13:08 msp1974