UniFi Security Gateway

Just a general note to say that the controller software behaves erratically when under load.

I had an old Cloudkey and 50% of the time the integration would fail to connect. Since upgrading to a CloudKey 2, it connects 100% of the time.

Therefore the controller on an RPi may experience similar issues.

I have discovered that UPnP often causes some issues from the USG side. My component is often “unavailable” I then reset/delete all upnp connection via cli and it is discoverable again…

the controller is good when using official addon
no troubles there so…

got it working :slight_smile: had to add site_id , now its ok :stuck_out_tongue:

Great, nice to see. Saw also your answer at tweakers. :ok_hand:

1 Like

ah cool, ur a tweaker too :slight_smile:
i got one more question
i got all running for vpn and alerts too, but for firmware it says entity unkown
it is under monitored conditions though

is this the correct one?

  • entity: sensor.unifi_gateway_firmware

also for the vpn , it says its ok
but when does it say ok?
as soon as a device is connected through vpn or?

I have the sensor: sensor.unifi_gateway_firmware_upgradable

And have this in my sensor.yaml:

    monitored_conditions:
      - www
      - lan
      - wan
      - wlan
      - alerts
      - firmware
2 Likes

Thx Dennis,

That worked.
You are the guy who gave me this https://prnt.sc/qwsse6

How did you do the cpu and memory?
And the speedgraph

What about the vpn, it doesnt show if a device is connected through vpn, does it?
It just shows is enabled

I saw that to, but that’s not from me.
Did see this in the beginning. You have to create other sensors for this from the gateway. Use template and then create more sensors. Here are some that you can create.

For the VPN I can’t tell you. I don’t use the sensor for vpn.

  - platform: template
    sensors:
      unifi_gateway_wan_cpu:
        friendly_name: 'CPU percentage'
        value_template: "{{ states.sensor.unifi_gateway_wan.attributes['gw_system-stats']['cpu'] }}"
        unit_of_measurement: percentage
      unifi_gateway_wan_mem:
        friendly_name: 'Memory percentage'
        value_template: "{{ states.sensor.unifi_gateway_wan.attributes['gw_system-stats']['mem'] }}"
        unit_of_measurement: percentage
      unifi_gateway_wan_cpu_temp:
        friendly_name: 'CPU temperature'
        value_template: "{{ states.sensor.unifi_gateway_wan.attributes['gw_system-stats']['temps']['CPU']|replace('C', '') }}"
        unit_of_measurement: degrees
      unifi_gateway_www_xput_down:
        friendly_name: 'USG Speedtest Download'
        unit_of_measurement: Mbps
        value_template: "{{ states.sensor.unifi_gateway_www.attributes.xput_down }}"
        icon_template: mdi:speedometer
      unifi_gateway_www_xput_up:
        friendly_name: 'USG Speedtest Upload'
        unit_of_measurement: Mbps
        value_template: "{{ states.sensor.unifi_gateway_www.attributes.xput_up }}"
        icon_template: mdi:speedometer
      unifi_gateway_www_speedtest_ping:
        friendly_name: 'USG Speedtest Ping'
        unit_of_measurement: ms
        value_template: "{{ states.sensor.unifi_gateway_www.attributes.speedtest_ping }}"
      unifi_gateway_wan_download:
        friendly_name: 'WAN Download'
        unit_of_measurement: Kbps
        value_template: "{{ (states.sensor.unifi_gateway_wan.attributes['rx_bytes-r'] / 1024) | int }}"
      unifi_gateway_wlan_num_guest:
        friendly_name: 'Guests'
        value_template: '{{ states.sensor.unifi_gateway_wlan.attributes.num_guest }}'

thanks will try them

1 Like

the cpu temperature says its unavailable, but dont mind that, i wont use that

the download/upload and ping test, is showing 0 mbps or ms
i would like those though, why is it showing 0?
the other stuff works, thanks

Yes I had that also… couldn’t find what the problem is.

For the download and upload it is the ping results of the test inside your controller.
So you first have to do the test and it will be filled with the results.

ah ok, i have a better idea then, to test such speeds
thx

mmm
it gives me better result than to let HA use ookla.
Is there a way to make the usg test ad x times instead of doing it manually through controller?

You can setup the repeated time in your controller settings.
Under site.

Thx ok, damn, its in hours, instead of in days :stuck_out_tongue:

How much does it download once run? You know that?
Why dont you use it?

Unifi USG is limited to 100Mbps for speed test due to hardware constraints. Slightly higher for USG4P.
If you have a faster connection, you’ll have to try something else to get accurate results otherwise they will max out at their limit.

Do the math for the speed test download:

Your connection speed times the speed test average time.
So if you’ve got 100 Mbps (which is 12.5 Mbps) multiplied by the time it takes to complete. Some test take longer, some shorter depending on the amount of data to be used for the speed test and the speed connection.
The larger the data amount used for the speed test the more accurate it is, 10MB vs 300MB can have very different speed test results, the later one being more accurate.

For me it takes about 20 seconds and I have a 100Mbps, so 100/8 (so you have MB/s) gives you 12.5 MB/s, multiplied by 20 seconds equals 250 MB for each speed test.

Personally I wouldn’t run the speed test more than 4-8 times a day. Even twice a day is good enough, it will also cause network bandwidth issues when you’re streaming or doing something and the speed test runs.

Also in the US many ISP have data caps and start charging after that so if you have a 100Mbps connection that takes 20 seconds to complete and you set it run it hourly you’ll run into 6GB daily usage or 180GB per month usage. The higher the connection and the longer the speedtest takes, the more data it will consume. There’s people reporting 15-20TB of data per month by running it hourly on a 500Mbps connection.

anyone tried this with a UDM/Pro?

Yes, no luck :frowning:

2020-04-14 16:50:47 ERROR (SyncWorker_11) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:50:47 ERROR (SyncWorker_10) [custom_components.unifigateway.sensor] Failed to scan aps: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:50:47 ERROR (MainThread) [homeassistant.components.sensor] unifigateway: Error on device update!
  File "/config/custom_components/unifigateway/sensor.py", line 155, in update
2020-04-14 16:50:47 ERROR (SyncWorker_4) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:50:48 ERROR (SyncWorker_10) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:50:48 ERROR (SyncWorker_15) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:50:48 ERROR (SyncWorker_6) [custom_components.unifigateway.sensor] Failed to access alerts info: Expecting value: line 1 column 1 (char 0)
2020-04-14 16:50:48 ERROR (MainThread) [homeassistant.components.sensor] unifigateway: Error on device update!
  File "/config/custom_components/unifigateway/sensor.py", line 139, in update
2020-04-14 16:50:48 ERROR (SyncWorker_5) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:51:18 ERROR (SyncWorker_19) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:51:18 ERROR (SyncWorker_1) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2020-04-14 16:51:18 ERROR (SyncWorker_6) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)

Great addon!

Only I’m crazy about these warnings:

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:986: InsecureRequestWarning: Unverified HTTPS request is being made to host ‘192.168.1.2’. Adding certificate verification is strongly advised. See: Advanced Usage - urllib3 2.2.1 documentation
InsecureRequestWarning,

  • platform: unifigateway
    host: localhost
    username: !secret username_unifigateway
    password: !secret password_unifigateway
    verify_ssl: false
    monitored_conditions:
    - www
    - wan
    - lan
    - wlan
    - alerts
    - firmware

Any thoughts how to prevent this?