Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
15 stars 10 forks source link

Velbus in HomeAssistant not loading any modules; after waiting a day all modules load but entities unavailable #113

Closed KevChief closed 1 month ago

KevChief commented 2 months ago

I just updated to the latest HA version; and now all entities are unavailable.

I’ve checked the logs, and I’m getting the following error a lot: Restarting Velbus writer due to AttributeError(“‘NoneType’ object has no attribute ‘is_closing’”)

Never seen that one before.

My Velbus set-up hasn’t changed, just updated to latest DietPi version (9.5.1) and latest HA (2024.7.1)

I let it sit for the day (because I was at work); was now looking at it , and I thought to get some more logging by reloading the velbus integration... Now I do get a successful sync with a lot of devices and it seems to be working again (I didn't reboot or restart HA or anything, just let it sit for the day)... Not sure why; can't explain it.

I do notice though that not everything is loading, I have a few devices where all entities are unavailable (mostly VMB4RYNO, VMBEL1, VMBEL2, VMBEL4 and VMBELO)

I've created a bug report and added a ZIP file of my logging file:

Unavailable entities on device: image

Same Velbus module but other physical device; all is fine there: image

home-assistant_2024-07-08T22-29-29.914Z.zip

Let me know if I can help with something to debug or if I can try something to get the unavailable entities online Thanks!

sidlgor commented 2 months ago

Version 2024.7.1 is not the latest version (there is a bug in locating the cache files). Latest version is 2024.7.5 On the faulty module instance: did you change the name in HAS of the unavailable channels?

KevChief commented 2 months ago

I didn't rename any modules

I've been looking at it some more today; I can see now that after deleting the Velbus folder as well as reloading the integration a few times, now it seems the modules are loaded and all entities are available (a few with new entity ID's, so have to relink them in my UI, but ok).

I do notice though that , now after 12 hours of so of a reload of the integration, the .json files in the Velbus folder still get changes (the last modified time keeps getting updated). Is that expected behavior?

sidlgor commented 2 months ago

Did you switch to latest 2024.7.5 ?

Renaming modules is not important, renaming channels is !

The new implementation (starting from 2024.7.*) makes a full scan of all module addresses when no cache files are detected. Otherwise active modules are determined by the presence of the cache (json) files. To avoid canBus saturations ONLY the first scan will be slow (several minutes and counter intuitive: the less modules you have the longer it will take because of more timeouts) .

When you still have 2024.7.1 the failure to detect the cache files will make the integration decide there is no cache and will always perform a full (slow) scan. This will work but ... the slow start will make it tempting to restart.

When you have 2024.7.5 only the first scan will be slow BUT WHEN A RESTART IS MADE DURING A FULL SCAN a partial (or even invalid) cache will exist and this will CAUSE MISSING MODULES (I would have preferred to explicit mark the end of a full successful scan instead of scanning for any cache files: just read more about this brainstorm in thread #112)

The version 2024.7.1 + multiple restarts makes it hard to determine exactly what happened to your config. I would recommend to switch to 2024.7.5, clear complete cache, restart HAS and patiently wait for full load to complete!

The changed entity ID's may also be caused by breaking the order of detecting the modules. This has to do with a vulnerability in the implementation for changes in module order detection and channel naming (entity ID is not enforced by determinitic channel key but auto derived from name). Also more about that in thread #112 ... feel free to join brainstorm !

Cereal2nd commented 2 months ago

@KevChief the version your speaking off is the hass version i guess, and not the velbusaio version. correct?

KevChief commented 2 months ago

@sidlgor : I didn't update yet to the 2024.7.5 version ; I'm on DietPi and for now 2024.7.1 is the latest compatible version. I can try to upgrade to the latest manually later maybe if that could fix things.

I will check out that brainstorm for sure; I think I'm good right now with modules ; I let it run and seems that everything is ok as long as I don't reload the integration for now. I do see however indeed that it keeps updating those JSON files, so it seems like it just keeps scanning and never finishes? I'm only 'worried' (for lack of another word) about that right now because it could be in an infinite loop of scanning the bus. If that's nothing to worry about, I'll wait till DietPi releases a new version with a new HA version as well; if it's concerning though, I would like to try to update to the latest for sure. (when updating with the DietPi script right now, it seems to think that 2027.7.1 is the latest version already)

@Cereal2nd : indeed, the HASS version; I use the build-in Velbus integration from there.

sidlgor commented 2 months ago

My mistake: I thought you meant the velbusaio version ! For my info: What version of velbusiao commes standard with latest version of HAS? When upgrading HAS is there also an automatic upgrade of integration (velbus) ?

Cereal2nd commented 2 months ago

yea hass 2024.7.1 has velbusaio 2024.7.5

On Tue, Jul 9, 2024 at 2:12 PM sidlgor @.***> wrote:

My mistake: I thought you meant the velbusaio version ! For my info: What version of velbusiao commes standard with latest version of HAS? When upgrading HAS is there also an automatic upgrade of integration (velbus) ?

— Reply to this email directly, view it on GitHub https://github.com/Cereal2nd/velbus-aio/issues/113#issuecomment-2217482399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4LF4OFNSNF7ZMFNQEAG4TZLPHSTAVCNFSM6AAAAABKRWI5Q2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJXGQ4DEMZZHE . You are receiving this because you were mentioned.Message ID: @.***>

KevChief commented 2 months ago

Ooohh my bad; I was also confused haha xD

Ok, then I'm on the newest version for both! Seems like all is ok then, but maybe because I have a lot of modules, for some reason after the upgrade it was acting up.

so my only open question now, is: is it "normal" behavior that even now, after almost 24 hours, I can still see the json files in the velbus folder being updated ?

Cereal2nd commented 2 months ago

are you talking about the cache folder?

yes that will constantly update

KevChief commented 2 months ago

Interesting; I was under the impression this was just created and build during a scan for saving the Velbus set-up and mapping them to HomeAssistant devices and entities (which then wouldn't justify constant updates but only when Velbus modules are added or modified)

Cereal2nd commented 1 month ago

i think we can optimize something here, previously we used python pickle to generate the cache for a module, this would save all info for a module/channel. This system changed recently to a json cache file. Since then we only store the minimal needed info in the cache, so now we could optimize this to only write the files during a scan.

KevChief commented 1 month ago

That definitely sounds interesting; right now I indeed don't see the benefit or the purpose of a constant rewrite and edit of the cache when there is no difference in set-up of the Velbus system. Once the scan is fully done, the cache is complete until a next scan happens which could mean changes of the set-up happened (new modules, renames, other configuration) which triggers new cache JSON files.

So definitely sounds logical to me as well that this could be a one time (during scan) write of cache as an optimisation , unless we are missing something here right now

Since you opened a new item for the above about caching, I'll close this item because it seems that everything is stable right now as far as I can see in the current build for me. Thanks for the support on this earlier!

KevChief commented 1 month ago

See last comment above; can be closed