[RELEASE] Network Monitor HealthCheck (HTTP)

I created this as part of a HA setup.

The driver monitors both Internet and LAN connectivity using HTTP requests.
It implements the HealthCheck capability with a user-defined checkInterval.

The driver sends an HTTP GET request to both a defined Internet and LAN host.
If a response is received, the corresponding attribute is updated to "online."
If no response is received, the attribute remains "offline."

Additionally, it optionally monitors Hub connectivity.
If the Hub check is enabled, it sends an HTTP GET request to the defined Hub host.
If the Hub check is disabled, the hub attribute is set to "disabled."

This can be used to trigger certain actions based on the values, via RM

4 Likes

Thanks for this app. I think it will be very handy. The lan and internet checks are working but the hub connectivity shows "offline" regardless of whether I enter the hub ip or name.local.
image

Using C7 on 2.4.1.157

Any suggestions to correct?
Thanks

1 Like

You are using http://192.168.68.63 for the hub IP

Can you acces that IP from the subnet you are on?

Yes. Yes.

The code is placing a basic httpGet and it’s looking for a successful return (200).

The log is stating connection refused. Any firewalls in between?
Basically this hub is placing the httpGet but something on the way to that request, is blocking it…

FYI: The device event list is not showing that the hub check is running, only the lan and internet checks. But the log is showing the errors for hub check.

That is so weird.

I cannot replicate it on my side as all my hubs are on the same subnet.

I’ll look into it.

But the the driver (your code) is running on the hubitat, so why can't it connect to itself? Does the httpGet call have to bounce off the router?

I have a router that enables me to turn on 'device isolation' per device. I'll check to see if the hubitat is 'isolated' in this way. But I am able to connect with the hubitat via laptop, ipads, iphones, etc.

Edited: Device isolation feature is NOT enabled for the hubitat on the router.

Never thought of checking “self”.
I don’t understand why one would need that to be honest.
The goal is to check a separate host.
I don’t know to be honest the implemented limitations of the httpGet at hub level.

Indeed changing the hub IP to the local hub ip and even 127.0.0.1, returns that.

Maybe @bobbyD can help answer that ?

What about check the Hubitat cloud instead?

Could you elaborate on this?

What are you trying to achieve (might be a direction i never thought about)?

The goal of this driver, simplified, is this:

Do i have internet? Yes/No
Do I have Local Network? Yes/No
Do I have the other (backup) hub up ?

These are meant to be used in a Rule Machine as possible action points, separately or together.

Just a quick thought - no specific use case for me. You could just label the "Hub" entry as "Custom" instead so anyone could use for whatever they want.

1 Like

Good idea. I changed the code to reflect that.

Nice driver. Looks very promising for me to ping both of my ISP gateways and make a decision based on that.

Custom still does not appear to work for me. This is another/secondary hub. I can ping it using "ping" from my laptop and from the ping in the primary hub's network test tool.


That is strange.

What does the log say ?

It returns offline if a successful httpGet is not retrieved (return code 200).

So if it’s anything than that (404, 403 anything except 200) it says offline.

While these hosts are all “up”, since they didn’t return to 200, they show up as offline

I guess i can rewrite the code to return offline ONLY when the host is down down (No route to host).

I improved the online/offline logic and revamped the code.

It should behave now properly. Let me know if you face some other unforeseen errors.

My testing shows it working as expected

1 Like

@ramset,
Thanks for this driver.
All my hubs (HE, HA, Aqara M3, SmartThings) are showing as offline/unreachable (connection refused), except for the Hue bridge which shows as online.

All hubs are on the same subnet, 192.168.68.xxx


@iEnam
Are those hosts connecting via https?
The httpGet goes by default on port 80 when using http and if port 80 is closed, then it returns as refused.

You can use IP:port format to point it at a specific web server port

E.g. http://192.168.68.135:8080

L.E. Does it happen only for the Custom field hosts?

If you put one of the non responsive hosts in any of the first 2, does it behave the same way ?

I’m driving now and cannot test.

1 Like

Great, all non-responsive hubs work with port 8080, thanks :blush:

1 Like

It’s strange though. I know HE has 80 open …

¯\(ツ)

You can use the driver to check any host, despite the field names (“internet”, “lan”).
If you are monitoring so many, just disregard the naming and use it as needed.

Just don’t forget what’s what when automating :blush:

1 Like