Hubitat API and using Tasker on your Android phone

I have some Tasker automations which call some of the Hubitat API's. They work great... almost all of the time. Sometimes, however, Tasker throws an error: UnknownHostException: Unable to resolve host "cloud.hubitat.com": No address associated with hostname

Of course, it's completely plausible that cloud.hubitat.com would be down or unavailable. But I get this error too often for me to believe that would be the case. Anyone else have this sort of an issue?

I'm using some calls via tasker and I also sometimes get these errors, and it's starting to grate, because I don't like error messages...

java.net.UnknownHostEx ception: Unable to resolve host "cloud.hubitat.com"

Is there anything that can be done? Open specific ports or something? Any help greatly appreciated.

I have been using Tasker for about a year. I uses it to automatically turn off the power to the charger, when the charge reaches 80%. Because of this I only need to make local connections to the hub. It has never failed.

You seem to be experiencing a DNS lookup problem. Every Wi-Fi network, and every cell tower you connect to, can use different DNS servers. Have you noticed the problem only occurs at specific locations, perhaps home, work, or at the pub?

Many users have been discussing a similar problem with the Hubitat app, and/or dashboard, when connecting remotely. When you receive this Tasker error next time, please attempt to connect to your hub remotely and confirm if it is also unreachable.

1 Like

Most of the time it works, I'd say 20% of the time I get an error.
I'm using Adguatd DNS on the phone, maybe that's it?
Connecting to the hub remotely always works via a WG server.

1 Like

If that means you are connecting to a Wire Guard VPN server running at your home, then you are effectively connecting by a local connection when using the App. The app should say LOCAL or CLOUD when connected to confirm this.

If the VPN is always enabled on your phone, then use local endpoints in Tasker, rather than Cloud endpoints.

1 Like

That's the thing, it's not. The VPN for the home network isn't always on, on the phone I just use it to check local network stuff now and then

So I need the cloud endpoint to work reliably. Specifically I'm calling a webCoRE piston from Tasker.

Is your calling of the piston a situation where some kind of retry within Tasker would be worth looking at doing, if the HTTP call fails? Alternatively, would your situation work if you introduced some kind of delay before calling the piston, hoping to avoid the issue?

I suspect @user5298 is on the right track in saying that it is likely something external as you move between Wi-Fi and cell data or between cell towers. I'm guessing it is the former. Do you have certain situations where it happens the most, e.g. leaving home or some other location where you utilise Wi-Fi for data?

It might help to explain a little more about what you are trying to achieve in calling the piston. Like I have described above, there could be alternatives depending on what you want to have happen and when.

I have been using Tasker for some time as well, but for less critical things than calling an automation like you are, so a temporary glitch is less problematic, but I would be interested to understand some of the different approaches that could be used in situations like this. I have created but not fully tested a solution where I detect dropping out of a known set of Wi-Fi SSID's and switching from local to cloud communications with HE. It would take a bit to set it up from scratch again, but some variation on that theme may be of use to you if you are interested.

Yes thinking about it, it's surely to do with WiFi changing to mobile data.
The piston turns on/off a virtual presence sensor.
I've put the web call at the end of the Tasker routine with a 7 second delay.
If you know of any Tasker trick to send the web call again if it gets a fail?
If I run the Tasker "arrived routine" while I'm already on WiFi, it goes through ok..

Summary

I'll see what I can work out in the next few days....

1 Like

Yes it happened again when I left my home WiFi network...
Here's the error in full ..

Summary

It has completely stumped me!

Looking at your Task again... That you posted earlier....

What does Step 6 do? The "Function WireGuardSet.......

I'm thinking could that happen after step 8 to call the HE API?

I tried that, it's still complaining.
I'm running my Away disconnected Tasker Task whilst away, so already on a good mobile data signal, and it's throwing errors. The hubitat hub is behind a router with personal dedicated VPN address.

Summary

13.59.40/LicenseCheckerTasker Checking cached only
13.59.40/LicenseCheckerTasker cache validity left -81033
13.59.40/LicenseCheckerTasker Cached status: Licensed
13.59.40/LicenseCheckerTasker Cached only: Licensed
13.59.40/Ew add wait type EasyAction1 time 2147483647
13.59.40/Ew add wait type EasyAction1 done
13.59.40/E add wait task
13.59.51/E Error: 1
13.59.51/E No response from hub

Hmmm... This feels like something outside of a Tasker issue then....

Well I've turned off the VPN on the router and still get the same error.
I also turned off Adguatd on the router and on the mobile phone.
I'm in a good data coverage area, the router with SIM in is getting 350mbps and I again got the error.
15.40.01/LicenseCheckerTasker Checking cached only
15.40.01/LicenseCheckerTasker cache validity left -6101815
15.40.01/LicenseCheckerTasker Cached status: Licensed
15.40.01/LicenseCheckerTasker Cached only: Licensed
15.40.01/Ew add wait type EasyAction1 time 2147483647
15.40.01/Ew add wait type EasyAction1 done
15.40.01/E add wait task
15.40.31/E Error: 1
15.40.31/E java.util.concurrent.TimeoutException: The source did not signal an event for 30000 milliseconds and has been terminated.

And when I put web call through Firefox, it goes through every time.

Summary

Oh my, I think I may of finally sorted it! Thanks for the support @sburke781
In Tasker I'm now using the old deprecated HTTP Get call and I've run 10 tests with zero errors.
I should really tell João Dias, this has only been bugging me for 6 months!

1 Like

FYI, as I mentioned earlier, I have been using only local endpoints to turn off the phone charger when the phone battery reached 80%.

Out of curiosity, I generated a cloud endpoint to trigger the same rule. After turning off Wi-Fi on my phone, I had no problem controlling Hubitat either with HTTP Request, or the depricated HTTP Get.

Both methods also worked when connected to my home via an OPENVPN connection.

I should mention that initially I did receive errors very similar to your own. Each HTTP method displayed the warnings differently. It turned out that I had disabled cell data some time previously, and I had forgotten about it.

I spoke too soon, just got an error with the deprecated Tasker Get call :sob:

Summary

!

The following is the error message I received when both WiFi and cell data was turned off. It looks very similar to your screen capture in post 11.

The main difference is that your message says "no response from the hub", while mine says "unable to resolve host", as would be expected.

How did Tasker know there was a hub at the destination unless the connection was successful?

3 Likes

Exactly my thoughts. If anyone knows how to capture the Tasker Get Request Response from the hubitat hub within tasker, maybe put it in a Variable? It would be interesting to see the response.

Just jumping in on this. I also use tasker to toggle a virtual presence when leaving the geofence area. I also had problems with this.

My thought of what was going on was that the tasker geofence profile radius was kicking in while the network was still trying to connect fully to cell data as I was leaving my wifi. (The coverage is horrbile here, so the connection takes a little longer than it should). I was connected per what the phone thought. But, at the same time, I was also having issues with waze routing in the same spot and would have to wait another several hundred meters before it would work. I put the two and two together and just guessed that the two issues might be related.

I increased the radius on my tasker geofence profile so that it would not happen until I was in an area where I could almost always assure that the connection would be working and my error went away so that it only happens very rarely now. (A similar problem was solved a similar way with the built in geofence for the HE app itself).

It is worth a try.

2 Likes