UniFi Network Integration - Confirm WAN Internet is UP/Down?

THanks for taking a look at.
Apologies I dont quite understand, where do I find the download sensor - I can’t see anything obvious other than in your integration the UniFi WAN Download sensor which shows mbit/s (assuming thats current speed) however can’t see totals as such?
I also dont appear to have anything like that in the official Unifi HA integration.

So using the UniFi WAN Download sensor, create an intregral sensor:

Then a utility meter using the new sensor you’ve just created ( Offset 10 days ):

You should end up this:

Thank you so much for your help. I used chatgpt to help me with this and suspect it may have messed a few things up. The current unifi wan download shows Mbit/s should it actually be MB? Image attached.
Many thanks.

No it is Mbit/s

Thank - you

If you follow the 2 steps above it will create the sensor you need

This is brilliant and working perfectly. I spent nearly 3 days on chatgpt trying to achieve this, it made a real mess. It seemed a simple thing but was driving me mad! Can’t express gratitude enough. Have you a “buy a coffee” link?

No probs and thanks for the offer, glad you got sorted

I’ve added cumulative sensors to the integration now, with a configurable reset date.
Also added a configurable rate for the upload and download sensors to update more frequently if needed. I have tested at 2 seconds and looks like no noticeable increase in UDMPRO CPU, yours might differ so please monitor it and reduce if needed.

1 Like

This is fantastic, what a superb addition to the set of tools.

This is much more useful than the standard Unifi integration @Holdestmade. Thanks for building this. I added a PR to your github to make it easier to introduce compatibility with other Unifi gateway types beyond ugw and udm.

I’m using this to restart my cable modem every hour if WAN2 is the active WAN link. My cable modem is not co-located with my UXG, so the built in modem reboot outlet functionality in the UXG is useless to me. I’ve noticed some very odd behavior recently where after an ISP outage, the cable modem essentially freezes and doesn’t recover without a reboot. Spent weeks blaming Unifi network and UXG but eventually had another ISP outage and confirmed it is the cable modem behaving this way. Even more strangely, it wasn’t always like this. My modem (Ubiquiti UCI) used to recover fine after Cox outages. In the last few months though, it is reliably freezing and not recovering :frowning:

Thanks, that looks useful, I have merged it

Thank you for the integration you made @Holdestmade! I’ve been using it and it works great. However, I recently introduced WAN3 interface to my network and so I submitted a PR to make it dynamically fetch the available WAN interfaces instead of hardcoding to WAN1 and WAN2 for the extra flexibility. (I am relatively new to writing custom integrations, so please let me know if there are any bad practices.)

Thank you. I can’t test the multiple wan interfaces but I’ll merge it and we’ll see if anyone else has any issues

Sounds good! I’m using it personally, so I’ll continue to monitor how well it works.

1 Like

Hi this is a fabulous addition and though i am only really making use of sensor.wan_download_total to monitor my isp data restrictions I have found that theres a overhead on polling (according to chat GPT) though i changed polling scan interval to 900 and rate to 1, The sensor grows each second. Is there something I can do to restrict this, Thank you.

The latest versions (0.9.0+) removes the totals sensors because of this.

You’ll need to recreate using integral sensors and utility meters to set up daily, monthly usage etc, this way the data is saved in HA instead of the integration

I’ve also just published a new version, 0.9.5 that allows the fast polling of the upload and download sensors to be disabled.

EDIT: I’ve added a new version, 0.9.6 that adds WAN upload and download sensors that are updated using the Scan Interval (the original sensors that are updated using Rate Interval remain). You can use these with the integral sensors and utility meters to reduce updates

Ok thanks will attempt this. Appreciated.