-
Notifications
You must be signed in to change notification settings - Fork 418
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
list_services() not showing newly registered services #977
Comments
Thanks much! I do appreciate the work you do. |
FWIW, every major system has been updated, yet the problem remains. Now running I am not "resting assured." In looking at the above linked PR, it looks like it is being blocked by one reviewer? |
@blyons16 the PR has not been merged, so you will have to merge it locally in your own instance |
Please excuse my ignorance, but I have no idea how to "merge it locally." Can you direct me to some documentation of how to do that? Is that even possible with what used to be known as "hassio?" I thought that was locked down to prevent deviations from the standard releases. |
you are right, you cant do that with hassio (at least not easy, when you want the change to stay) |
I got the problem again after Home Assistant 0.113 update. Dev version worked fine with 0.112. |
I have the same (?) issue. Appdaemon 4.0.5 Basic services like "light" are missing until I restart appdaemon. I think it is because home assistant now uses lazy loading when starting so appdaemon doesn't get the full list if services. |
make sure that HA is completely loaded and ready before AD starts. |
Thanks, will do. Wouldn't it be nicer though if appdaemon waited with loading the services list until the "ha started" event was sent? edit: Just to be sure, you are talking about |
AD waits for that event. there are several ways to delay ADs connection to HA. |
Thanks, I missed this part of the documentation. https://appdaemon.readthedocs.io/en/latest/CONFIGURE.html#hass-plugin-startup-conditions Excellent, thank you! |
I think ideally there would be a second event from home assistant indicating when it is fully initialized. I am, however, grateful that appdaemon includes these very well thought out startup options. For those following, the documentation does state this but I found it easy to misunderstand:
Based on this entry appdaemon will delay startup of the HASS plugin for 60 seconds and wait (if needed) for the existence of entity cover.garage_door if you restart home assistant while appdaemon continues to run. If you restart appdaemon or restart appdaemon and home assistant this entry does nothing. If you want the same functionality in either case you would need to change the entry to:
|
i think it is something that is missed while creating it. the plugin startup conditions should work also for the first time the plugin is started. if so then its a bug that the plugin startup conditions are not checked when AD is restarted. allthough when i think about it more, i guess the problem lies in that when 1 plugin initialisation is hold up all others are also hold up. |
@ReneTode , @acockburn - |
Replying on my phone so can’t easily check but there are separate arguments for plug-in restart vs start delays/conditions |
I have delays (120 seconds) in both
|
just to make sure: when you start AD 120 seconds after you started HA you get less then 100 services, how about when you delay AD for 5 mins? |
@bg1000 i didnt say there shouldnt be seperate startup conditions, and they are there for a good reason. as intended. plugin restart isnt the same as HASS restart. allthough when you restart HASS you will also see that the plugin will be restarted. i just concluded that the plugin start conditions should always take effect when the plugin starts. (initial start and restart) i never used those conditions, but if the plugin start conditions are intentionally not for the first plugin start, i always advised people the wrong way. |
@ReneTode It still loads less then 100 services with 300 seconds delays too. |
hmm, thats a very strange problem. what if you dont start AD, when you start HA and you start AD 5 mins after HA is started manually? |
All services will be loaded in this case. I have a problem only when HA and AD start simultaneously. |
i just looked at your log again. the plugin connects before the delay. i see the big problem with that though, AD needs to be connected to HA to be able to evaluate if the startup conditions are met, but as soon as HA is connected there is no update from the services anymore. and i dont believe HA has a new_service, or service_added event, so AD cant listen for new services. the only solution i see (but thats not for hassio users) is to delay the startup from the AD service. |
Unfortunately I also regularly have an issue where AppDaemon cannot see a zwave service ( Also.. do multiple startup_conditions work in the State condition type? Because AppDaemon logs only the last one always:
|
yes multiple conditions work if you do it right ;)
is no list, so yaml only sees the last line.
should work. |
I created a new issue about the startup conditions, I don't want to hijack this one. ( #1051) |
I just had an issue where I was getting a lot of Strange I've been running AppD for all these years and never noticed this one. |
the problem is not AD, but HA. if the problem comes back, the best way it to add a delay to the start from AD. |
Actually I believe this has been fixed in |
is it? |
if i look at it, then that comment says that AD now listens for newly registered events. |
Ah just checked and this was actually merged in 4.0.4, which is part of the present release; it’s actually in the change log. Now if this issue still exists, then the fix not working properly. Need to investigate a bit more on that then. |
i cant find it in the changes from 4.0.4, but if it is added there, it certainly isnt solved ;) |
I do still occasionally get issues like |
@ruifung only after a restart, right? in that case i suspect that your remote integration is starting slow, so i advise to add a delay to appdaemon.yaml |
Happened again. This seems to be more prevalent with the recent versions of HASS. Until someone figures out a fix I'll just add an appdaemon restart to the HASS restart script. |
in general i always advised to restart AD when you restart HA. there always have been, and probably always will be issues to be taken care off, when you restart HA and dont restart AD. in all the years i use AD/HA/Dashboard, i never have restarted the base program (HA) without the depending programms (AD) for addons (or depending programs like AD) its hardly possible to make sure everything keeps running, with a constant changing environment as HA is. |
@ReneTode - I understand your point about dependent applications. For me, this problem directly correlated to the change in HA to bring the gui up before the app has fully initialized. Before this, I don't think I ever had to restart Appdaemon after restarting HA. I appreciate the changes that were made to allow a delay and check other startup conditions. I contributed a small PR to the docs on this which is now in the dev branch. I use both of these in my configuration but it still isn't 100% reliable and I end up manually restarting Appdaemon after HA is fully up. This isn't the end of the world but it feels like this one thing doesn't work as well as it used to which is a little frustrating sometimes. |
@Odianosen25 I'd be happy to try this. I am currently running 4.0.5 with docker. It looks like all of the code changes for PR1147 are in appdaemon/plugins/hass/hassplugin.py. Did you want me to apply this to 4.0.5 or to the current dev branch or something else? |
I think it’s better if tried against the dev, branch as it’s against that the PR was made. regards |
@Odianosen25 - No problem. I should be able to work on this tonight. I'll get back to you with some results or if I have any questions/problems. |
@Odianosen25 It's probably a little early to declare victory but so far so good! I have dev + PR1147 running and have done 5 restarts of homeassistant so far without any issues. Before I started testing I removed all startup checks/delays from my appdaemon.yaml as well. I'll try to get this up around 20 in the next day or two and touch base when I do. Thank you for working on this. This is likely a separate issue but the container would not build for me as pulled from the repo. I had to add "ARG CRYPTOGRAPHY_DONT_BUILD_RUST=1" to the Dockerfile due to the cryptology build failing. I don't see how your PR could have effected this. I do see some changes in requirements.txt between master and dev. If you agree that this is worth looking into I can open as a separate issue with better documentation of the error. |
Thanks for confirming, and someone else just also confirmed it seems to work for them, so most likely all good now. Will merge the PR later today into dev. On the second issue you are right the build fails, and thanks for the pointer as I hadn’t been able to properly look into it yet. You can create a separate issue, or a PR to fix it. Though I would have preferred avoiding the need to add that arg to the docker file, but will see how it goes. regards |
Ok this has been merged and @bg1000, I have fixed the build issue. Regards |
@Odianosen25 - Your fix to the Dockerfile is obviously better than what I did. I fetched the current dev branch. It built and started up without issue. Thanks again for working on this. |
Yeah thanks for the acknowledgement @bg1000, it was a security related issue and avoiding rust from my research wasn't a good idea; so had to find another solution. If any other thing, can always let us know. |
Looks like its still happening. I left home and my doors didn't lock. There are 3 script calls in the AD function and all threw warnings.
|
@bbrendon I believe the fix is only in the dev branch currently. Are you running the current dev branch? |
I'm not sure how to tell what version i have... this?
|
@bbrendon The recent fix @Odianosen25 put in for this was #1147. You can check for this with |
Yes. I have that comment in my git log. |
Not what I was hoping you would say . . . |
Fact is with HA plugin, I still think some time like 10 secs should be added to the plugin startup no matter what. Just help to ensure at least no matter what happens, The plugin will come up right. Regards |
Here is the fix. Run this in cron. :)
|
Even 120 seconds is not enough for me. My workaround is to use domain, service = data.get('service_name').split('/', maxsplit=1)
service_data = data.get('service_data')
logger.debug("Running {}.{} with data: {}".format(domain, service, service_data))
hass.services.call(domain, service, service_data) Usage: self.call_service('python_script/call_service', service_name='', service_data={}) @Odianosen25 Can you reopen the issue? It's definitely not fixed. |
For the past few months, I have been struggling with "unknown domain" and other errors which I have traced to missing services. I have posted that journey here: https://community.home-assistant.io/t/unknown-domain-default-remote-in-call-service/173595/6
I spent the weekend spinning up a new RPi4, and in that process had plenty of opportunity to experiment with different methods, configuration, and timing. I think I have found the root cause.
It appears that the list of services returned by the AppDaemon function self.list_services() is only updated once, at the launch of AppDaemon. If any new services come online after AD startup, they will not be returned by list_services(). Since, after a cold system start, it takes a while for z-wave services to be registered, this is why I am experiencing the problem mostly with z-wave. However, the problem happens with any newly added services with new integrations or components. Since AppDaemon runs in a separate container from Core HA, newly registered components regularly appear when AppDaemon has not been restarted.
I proved this by having my initialize() function test for the existence of a zwave device, and if it is not ready, set a listener for a z-wave service_registered event. Then, when that event is triggered, get list_services() still does not show the services that was just registered. And if you manually run list_services() later, it still doesn't show up.
Example code snippets:
The only workaround I have found is to manually restart AppDaemon after all services have been registered, and only after that, compare my stored list of expected services with the list returned by list_services().
Currently running:
HassOS 3.13
Supervisor 222
HA Core 0.109.6
AppDaemon 4.0.2.5
The text was updated successfully, but these errors were encountered: