Event handler execution order of local vs. internet-based apps

My Hubitat system has been slow lately. I've been doing some debugging to try to figure out why and I think I've identified the problem.

A huge draw of Hubitat is the local processing, so that if/when your internet goes down, your lights still work (for all non-internet-connected apps). My internet has been a little flaky lately, with occasionally very large ping times, and this is causing a perceived slowdown in Hubitat.

Here's what's happening:

I have a pico remote that talks to a Lutron Pro Bridge, and controls some zwave lights using the built-in lighting controller app. I also have the Amazon Echo Skill app installed. It looks like since I expose the zwave light to the Echo app, every time its state changes, the Echo app makes a blocking call to api.amazon.com. Here's the problem, sometime this call happens before the "on" zwave command is actually sent to the light! If my internet is slow to respond, my light won't turn on before I either get a response from api.amazon.com or the request times out (this can be ~10 seconds if my internet is actually down)!.

Is there a way to make sure that all local-only events are processed first, before any internet-required events? In my mind, the call to api.amazon.com should come after all the local stuff happens (zwave command sent, local rules triggered/evaluated, etc.). If my internet is acting slow, I don't care if it takes a few seconds for the Echo integration to get back in sync, but I do care very much if my slow internet causes a 5-second delay to turn on my light for what should be a local-only event (lutron pico -> lutron bridge -> telnet -> hubitat -> zwave command).

For now, I've completely uninstalled the Amazon Echo app since I'd rather have lights that respond immediately to local button pushes.

Thoughts? Comments? Have I got this all wrong?

1 Like

Are you using the Echo App or Skill? The skill has replaced the app and may work better for you. This assumes you are in the US since the skill is not yet available outside the US.

It was the skill I was using (I'll double check when I get home).

The fundamental problem though is that the event scheduling system allows a blocking call to a webservice to happen before the local zwave command is sent.

Thanks for your analysis! We will look into this.

1 Like

That's a good find. I'm still hoping for one of @jp0550's suggestions back in April to have the ability to set priority for each subscription. Similar when you go to a device and can see all the apps it's included in. Possibly a subscribers table as well where you can order their priority. Making sure the skill is async will probably help in this instance but I'm still looking forward to more of this higher level control.
An example I have now is there's a lot logic setup for my garage door and it takes forever for the light to turn on. I'd rather have that execute first, then run all the secondary less time sensitive apps.