dummylabs / thewatchman

Home Assistant custom integration to keep track of missing entities and actions in your config files
MIT License
475 stars 20 forks source link

Severe system hang when saving automations #128

Closed mehhhhhhhhhhhhhhhhhhhhhhhhhh closed 5 months ago

mehhhhhhhhhhhhhhhhhhhhhhhhhh commented 6 months ago

I suspect this integration isn't being maintained given all the unaddressed issues, but I figured this problem was big enough that it deserves documentation for others experiencing it.

In recent versions of Home Assistant (2024.x) Home Assistant will hang for 15-30 seconds when automations are saved. I have been dealing with this for months and finally tried disabling this integration. Sure enough, disabling Watchman solves the issue.

rrooggiieerr commented 6 months ago

I'm very happy I stumbled upon your issue as I also experienced delays and even crashing of my system when saving my automations. Also opening an automation could take quite some time. Disabling Watchman seems to have solved these issues.

My guess is it's related to https://github.com/dummylabs/thewatchman/issues/125

andreasbrett commented 5 months ago

I think this is caused here when opening each yaml file in blocking mode (no async/await). This should be easy to fix, I'll see what I can do over at https://github.com/andreasbrett/thewatchman. Since this repo appears to be stale, I'm trying to fix some of the accumulated annoyances and incompatiblities of watchman in this maintained fork.

andreasbrett commented 5 months ago

@mehhhhhhhhhhhhhhhhhhhhhhhhhh @rrooggiieerr I'm not sure how long it will take me to come up with a fix. Experience with asynchronous HA integrations is rather limited on my side. It should be easy but in the meantime, I propose to run watchman with an automation and in that automation to sandwich the watchman service call with 2 service calls to enable and disable watchman.

You can use https://github.com/frenck/spook for that. It provides homeassistant.enable_config_entry and homeassistant.disable_config_entry. Add a 15-30sek delay after enabling watchman and remember that watchman should be enabled the moment you create/modify the automation ;)

Even after fixing the bug I will keep my automation that way, as I find it rather wasteful that watchman is run on EVERY configuration change. I only want to have weekly reports. It's fine when watchman is only enabled during this weekly assessment.

image

andreasbrett commented 5 months ago

I just released a beta over on my fork. It fixes this issue. Could you please test it in your HA installations? Find the installation instructions in README and in HACS don't forget to enable "show beta versions".

https://github.com/andreasbrett/thewatchman/releases/tag/v0.6.2-beta0

dummylabs commented 5 months ago

Thanks to @andreasbrett this issue should be fixed in v0.6.2 along with #125 and #135.