Giter Club home page Giter Club logo

sensor.unifigateway's Introduction

sensor.unifigateway

High level health status of UniFi Security Gateway devices via UniFi Controller

Version mantained forum

Connects to a Ubiquiti Controller instance to monitor high level health information on the setup including alerts and firmware updates

To get started download

/custom_components/unifigateway/manifest.json
/custom_components/unifigateway/__init__.py
/custom_components/unifigateway/sensor.py

into

<config directory>/custom_components/unifigateway/

Example configuration.yaml:

# Example configuration.yaml entry
sensor:
  - platform: unifigateway
    host: unifi
    username: username
    password: password
    monitored_conditions:
      - www
      - wlan
      - alerts
      - firmware

Configuration Variables

username

(string)(Required) A user on the controller

password

(string)(Required) The password for the account

host

(string)(Optional) The hostname or IP address of your controller Default value: localhost

port

(integer)(Optional) The port of your controller's web interface - this differs deopending on version - use 443 for UDMP-unifiOS Default value: 8443

version

(string)(Optional) Can also be set to 'v4' or 'UDMP-unifiOS' Default value: v5

site_id

(string)(Optional) For multisite installations, you can specify site_id to specify which is used Default value: default

verify_ssl

(boolean or filename)(Optional) Whether to do strict validation on SSL certificates of the Unifi controller. This can be true/false or the path to a locally trusted certificate to use for verification. Default value: false

monitored_conditions

(list)(Optional) A list of the sensors to monitor Default value: If not defined all sensors are setup

Monitored Conditions

The following sensors can be monitored

vpn

The status of the VPN sub-system

www

The status of the WWW sub-system Attribute data includes speedtest results

lan

The status of the LAN sub-system Attribute data includes the IP of the USG

wan

The status of the WAN sub-system Attribute data includes the WAN IP (e.g. dynamic IP as allocated by your ISP)

wlan

The status of the Wifi Access Points Attribute data includes number of guests

alerts

The number of unarchived alerts on the controller Attribute data lists the detail of each alert

firmware

The number of devices that are available for a firmware update. Attribute data lists the friendly name of the relvant devices.

In Development - Notes

The sensor currently accesses the controller everytime an individual sensor is updated. This should be optimised to access once and then feed data to the other appropriate sensors to reduce overhead.

sensor.unifigateway's People

Contributors

halkeye avatar jchasey avatar lociii avatar tmcarr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sensor.unifigateway's Issues

Sensors not available after upgrade

I just upgraded to the new version (0.3.2) but now my sensors are not available and I have the below my log file.
Home Assistant OS 5.12
supervisor-2021.03.6
core-2021.3.4
Reverted back to 0.2.3 and all works again.

`2021-03-24 15:58:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up unifigateway platform for sensor
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 531, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/unifigateway/sensor.py", line 88, in setup_platform
ctrl = Controller(host, username, password, port, version,
File "/usr/local/lib/python3.8/site-packages/pyunifi/controller.py", line 113, in init
self._login()
File "/usr/local/lib/python3.8/site-packages/pyunifi/controller.py", line 161, in _login
r = self.session.post(login_url, json=params)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))`

Unverified HTTPS request is being made to host

Error Message

This error originated from a custom integration.

Logger: py.warnings
Source: custom_components/unifigateway/sensor.py:171
Integration: unifigateway (documentation)
First occurred: 9:16:16 PM (3 occurrences)
Last logged: 10:02:16 PM

/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py:1056: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.10.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn(

**configuration.yaml **

sensor:
  - platform: unifigateway
    host: 192.168.10.1
    port: 443
    version: UDMP-unifiOS
    verify_ssl: false
    username: !secret u_unifi
    password: !secret p_unifi
    monitored_conditions:
      - www
      - wan

I tried reinstalling the component and also tried with and without verify_ssl. I don't know what to do, I'm getting so many warning Logs. Can anyone help me with this

Update for sensor fails after a couple hours

I am having an error that seemed to start on Home Assistant 2023.11. After a couple hours of restarting Home Assistant, the sensors fail and stop updating. The only FIX is to restart Home Assistant to get the sensor data back. But, it stops working and throws errors again after a couple hours.

Here's two entries in the Logs showing the errors.

Any help would be greatly appreciated!

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:696
First occurred: 12:38:35 PM (12 occurrences)
Last logged: 12:44:05 PM

Update for sensor.unifi_gateway_firmware_upgradable fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 696, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/unifigateway/sensor.py", line 166, in update
    if devices.get('upgradable'):
       ^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:696
First occurred: 12:38:35 PM (60 occurrences)
Last logged: 12:44:05 PM

Update for sensor.unifi_gateway_www fails
Update for sensor.unifi_gateway_wan fails
Update for sensor.unifi_gateway_wlan fails
Update for sensor.unifi_gateway_lan fails
Update for sensor.unifi_gateway_vpn fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 696, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 959, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/unifigateway/sensor.py", line 178, in update
    if sub['subsystem'] == self._sensor:
       ~~~^^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

multiple sites

Hi, Is there anyway to specify site because my controller handels multiple ones.

More Data like LTE for Failover possible

Very nice sensor, good work!
Is there a chance to get more data? I would like to have a sensor that monitors EVT_ULTE_ so I can setup a notifier in case that the failover is active in LTE and inactive in eth.

Could you give me a hint how to do this?

Error showing upgradable devices

I receive this every time HA restarts.

This means that HA no longer can see upgradable devices

2020-05-20 23:53:08 ERROR (MainThread) [homeassistant.components.sensor] unifigateway: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/unifigateway/sensor.py", line 157, in update
    self._attributes[devices['name']] = devices['upgradable']
KeyError: 'name' 

All other sensors appear to be fine.

Happy to help diagnose where I can.

Error 404

Hi!

I feel like I've tried everything, and I'm not getting anywhere.
Is there any particular requirements for setting this up with a Dream Machine Pro?

Unable to get sensor working via HACS Core-2021.6.3

Hi there,
Is used to use this as custom integration. Love it. Thanks very much.
I've since tried to use it since it was installed via HACS.
I simply un commented out the previous config, and it's failing to connect to my controller.
I'm running HAS on Debian (x86_64), with the Unifi Controller in a docker on the same machine. Current Version 0.23.1. Default ports. No cert installed.
I'm seeing this error in the HA logs:

Error while setting up unifigateway platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Here's my configuration.yaml extract:

  - platform: unifigateway
#    host: 192.168.1.178
    username: Admin
    password: !secret unifi_gw_sysmon
    monitored_conditions:
      - www
      - wlan
      - lan
      - wan
#      - alerts
      - firmware
#      - vpn

I tried commenting out the host ip to see if that would help at all..

What silly mistake am I making?

Thanks in advance,

After Update to 3.2 - no Sensor?

i update with HACS the Component to 3.2.
After this all sensor are disappeared?

my config is:

- platform: unifigateway
  host: 10.10.100.5
  username: admin
  password: xxxxxx
  monitored_conditions:
    - wlan
    - firmware
    - wan

image

How is the sensor now named?

Please explain the sensor result for a dummy like me :-)

I have created a sensor with this very cool custom component, and I get all the nice results like:

sensor.unifi_gateway_wan
OK
subsystem: wan num_gw: 1
num_adopted: 1
num_disconnected: 0
num_pending: 0
status: ok
wan_ip: x.x.x.x
gateways: x.x.x.x
netmask: 255.255.255.128
nameservers: 127.0.0.1
num_sta: 78
tx_bytes-r: 65571
rx_bytes-r: 72117
gw_mac: x.x.x.x.x.x.x.x
gw_name: null
gw_system-stats:
  cpu: '1'
  mem: '6'
  temps:
    Board (CPU): 52 C
    Board (PHY): 51 C
    CPU: 73 C
    PHY: 73 C
uptime: '133007'
gw_version: 4.4.50.5272479
friendly_name: UniFi Gateway WAN
icon: mdi:shield-outline

I have created this template for pulling the temperature:
{{ states.sensor.unifi_gateway_wan.attributes['gw_system-stats']['temps']['CPU'].split(' ')[0] | int }}
And that gives me a number of 73, but what does the 'Board (CPU)' and 'Board (PHY)' and 'PHY' mean, is it the right temperature I'm pulling out of it?

Need Help for sensor unifigateway

Hi,
I try to configure the HACS integration unifigateway with sensor.unifigateway

But it doesn’t work.

I have a UDM Pro with the latest firmware version

I configurer the sensor as indicated in the doc

Copy to clipboard

  • platform: unifigateway
    host: 192.168.X.X
    port: 443
    username: rodolphe
    password: XXXXXXXXX
    verify_ssl: false
    monitored_conditions:
    - wwwJ'ai configuré le senso
    - wan
    - lan
    - wlan
    - alerts
    - firmware

image

Thank you in advance for your help

Unifi Cloudkey firmware 2.0.24 support

Hi, after upgrading my unifi cloudkey to firmware version 2.0.24 the integration with hass is broken.

  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 353, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f8917e15b80>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 573, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.0.5', port=8443): Max retries exceeded with url: /api/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8917e15b80>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/unifigateway/sensor.py", line 84, in setup_platform
    ctrl = Controller(host, username, password, port, version='v4',
  File "/usr/local/lib/python3.8/site-packages/pyunifi/controller.py", line 89, in __init__
    self._login()
  File "/usr/local/lib/python3.8/site-packages/pyunifi/controller.py", line 137, in _login
    r = self.session.post(login_url, json=params)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.0.5', port=8443): Max retries exceeded with url: /api/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8917e15b80>: Failed to establish a new connection: [Errno 111] Connection refused'))

in the configuration.yaml i have tried to set
version: unifiOS
but that gives me another error:

Invalid config for [sensor.unifigateway]: [version] is an invalid option for [sensor.unifigateway]. Check: sensor.unifigateway->version. (See /config/sensors.yaml, line 36). Please check the docs at https://github.com/custom-components/sensor.unifigateway

Login failed

Getting an error, "Failed to connect to Unifi Security Gateway: Login failed - status code: 401"

cloudkey v2+, firmware: 2.1.4
controller version: 6.1.71

sensor config:

  • platform: unifigateway
    host: x.x.x.x
    username:
    password:
    version: unifiOS

If I remove, version: unifiOS it gives me and status code: 404

No integration with UDM PRo

Hi,

For a whole week I've been trying to setup te integration without luck. I constantly get messages that my sensors (unify gateway wan and others) are not available. I'm using a physical UDM Pro as gateway, tried using a local username and password, tried using port 443 and 8443... but without any success....

One thing I do encounter, when I log in to my console from Unifi, I got an ssl error, has this something to do with it ?

Can you confirm right port to use ? 443 or 8443 ? Version : unifiOS, ....

Kr,

USG3 and USG4 PRO on different cloudkey's

Hi

I have 2 different FW's in my installation. (Not on same controller)

When the component initialise the different connections they seem to do that in a random order...

So i don't know which unit a sensor belongs to, and that becomes a problem when I template the sensors as there are different one's on different models.

Is there a solution for this? (Maybe some form of site_id?)

Does not work

Authentication fails, but am absolutely certain of username/password

I suspect the integration has not been updated and is still trying to access the old port 8443 which is not used post 6.x

2021-10-07 09:57:00 ERROR (SyncWorker_5) [custom_components.unifigateway.sensor] Failed to connect to Unifi Security Gateway: Login failed - status code: 404

Unifi Cloudkey Gen 2, running Network 6.4.54

Cant get all sensors to show

Hi!
I am using HA 85.1 on Docker and trying to get this component to work. All i get i this error:

2019-01-15 23:35:12 ERROR (MainThread) [homeassistant.components.sensor] unifigateway: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 315, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/sensor/unifigateway.py", line 159, in update
    for devices in aps:
UnboundLocalError: local variable 'aps' referenced before assignment
2019-01-15 23:35:39 ERROR (SyncWorker_4) [custom_components.sensor.unifigateway] Failed to access health info: api.err.NoSiteContext

Here is my code:

sensor:
  - platform: unifigateway
    host: 192.168.1.12
    username: user
    password: pass
    site_id: id
    monitored_conditions:
      - www
      - wlan
      - alerts
      - firmware

Here is a picture of sensors i got.. but the only show "unknown"
skjermbilde 2019-01-15 kl 23 36 45

Cant figure out this warning Im getting

It seems to be working according the wan sensor but im constantly getting a warning in HA maybe you can help me understand it please?

Log Details (WARNING) Tue Aug 27 2019 22:45:15 GMT-0400 (Eastern Daylight Time) Failed to perform <function Controller._write at 0x7fe45b13ce60> due to ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Platform does not support 'port:' option

The problem

The integration does not support the option to specify the listening port of the admin URL. Many people run this system under Docker and the requirement to only listen on 8443 is limiting.

When the port is specified in the 'host:' section home assistant simply appends :8443 to the address.

Environment

arch | x86_64
dev | false
docker | true
hassio | false
os_name | Linux
os_version | 4.15.0-91-generic
python_version | 3.7.7
version | 0.107.7
virtualenv | false

  • Home Assistant Core release with the issue: All
  • Last working Home Assistant Core release (if known): None
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker

Problem-relevant configuration.yaml

  platform: unifigateway
  host: 10.x.x.x
  username: oliver
  password: *******
  monitored_conditions:
    - wlan
    - alerts
    - firmware

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 380, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/url.py", line 392, in parse_url
    return six.raise_from(LocationParseError(source_url), None)
  File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://10.x.x.x:8446:8443/api/login

Additional information

depreciated as of 2021.6

Custom integrations (custom_components)
As mentioned in every release since 2021.3, custom integrations will require a version key in their manifest file.

As of this release, if that version key is missing in the manifest, the custom integration will no longer be loaded.

For more details see our developer blog about it

(@ludeeus - #49916)

Templating issue

Hi,

When I try to create the following template "{{ states.sensor.unifi_gateway_wan.attributes.tx_bytes-r }}", I get the following error: "UndefinedError: 'mappingproxy object' has no attribute 'tx_bytes'". It seems that the "-r" at the end of the sensor is being interpreted as "subtract r from states.sensor.unifi_gateway_wan.attributes.tx_byte".

Can you (try to) rename the attributes that has the minus sing (-) to use the underscore (_)?

USG Pro 4

Hi,

I cannot get this to work, I used to have this working (many versions ago) and even created the template sensors but now, I am not getting any data actually coming though.

  1. I installed the component and keep it updated in HACS
    --> I have also uninstalled/installed but ot no avail
  2. I run the controller in docker on my Synology Nas.
  3. I use the USG Pro 4

Also, I am not seeing anything in the logs... the sensors etc are all created and avaialble, however there is not data available.

Thanks

IP of WAN2

Love this integration.

Would it be possible to add the WAN2 IP as an attribute to the WAN sensor just like the wan_ip attribute?

UCK 6.1.71: Changes in webinterface and 404

Hi,

just a quick heads up (and reaching out for a quick fix if possible):
The newest UCK-Software has some changes so the unifigateway wont connect with port 443.

Logger: custom_components.unifigateway.sensor
Source: custom_components/unifigateway/sensor.py:91 
Integration: unifigateway (documentation) 
First occurred: 12:03:18 PM (1 occurrences) 
Last logged: 12:03:18 PM

Failed to connect to Unifi Security Gateway: Login failed - status code: 404

This is my config which worked perfectly until the latest UCK update:

#Unifi Gateway
- platform: unifigateway
  host: 10.0.0.2
  port: 443
  username: !secret unifi_user_ro
  password: !secret unifi_password_ro
  monitored_conditions:
    - www
    - wlan
    - alerts
    - firmware
    - vpn
    - wan

I think it might just a small adaption of the url. As you can see, .../network/... has been added.
image

Any chances for me to fix it? I would really appreciate a small snippet.

Sensors unavailable when HASS and UniFi run on the same node

I got Home Assistant and my UniFi controller running on the same node (in Docker) and when my node is rebooted, the UniFi sensors are always unavailable. In the logging I see the following exception:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.1.1', port=8443): Max retries exceeded with url: /api/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fcec0af9c10>: Failed to establish a new connection: [Errno 111] Connection refused'))

Platform not found in 0.95

Updating HA to 0.95 got platform not found error during configuration check. Files placed in custom_components\unifigateway was working fine in previous version HA

Cut release for 0.3.0

I see that UniFi OS support was added in e010feb and the version badge was updated on readme.md after this. Is it possible to cut a 0.3.0 release so that HACS offers this version without having to install at master?

Thanks for the great work

Error updating the HA db with the component

when the component is enabled, its throwing below error for recorder. looks like its not compatible with new structure of HA DB. it goes away when its disabled

Error saving events: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.DataError) (1406, "Data too long for column 'attributes' at row 1") [SQL: INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, old_state_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)] [parameters: ('sensor', 'sensor.unifi_gateway_alerts', '409', '{"1": {"_id": "5f56cedc6f5c27082df69750", "archived": false, "timestamp": 1599524571, "flow_id": 1925892575841743, "in_iface": "br0", "event_type": " ... (648304 characters truncated) ... Shell UCE. From: 182.18.208.118:54008, to: 10.0.1.3:80, protocol: TCP"}, "friendly_name": "UniFi Gateway Alerts", "icon": "mdi:information-outline"}', 75894, datetime.datetime(2020, 9, 8, 5, 56, 26, 477953, tzinfo=), datetime.datetime(2020, 9, 8, 5, 56, 26, 477953, tzinfo=), datetime.datetime(2020, 9, 8, 5, 56, 30, 840655, tzinfo=), None)] (Background on this error at: http://sqlalche.me/e/13/9h9h) (Background on this error at: http://sqlalche.me/e/13/7s2a)

Add switches and AP's as sensor

Request here.

The UniFi API provides al metrics/sensors (even DPI info!). I've searched in the API using the https://github.com/Art-of-WiFi/UniFi-API-browser and found out that also switches and AP's show there CPU usage, CPU load 1|5|15, Memory usage, Uptime, Temperature etcetera.

It would be nice if these are added to this plugin.

Examples:

WIFI:

        "sys_stats": {
            "loadavg_1": "0.32",
            "loadavg_15": "0.11",
            "loadavg_5": "0.17",
            "mem_buffer": 0,
            "mem_total": 128360448,
            "mem_used": 72962048
        },
        "system-stats": {
            "cpu": "2.7",
            "mem": "56.8",
            "uptime": "1011227"
        },

Switch (with temperature):

        "sys_stats": {
            "loadavg_1": "1.24",
            "loadavg_15": "1.61",
            "loadavg_5": "1.48",
            "mem_buffer": 0,
            "mem_total": 262397952,
            "mem_used": 129912832
        },
        "system-stats": {
            "cpu": "57.4",
            "mem": "49.5",
            "uptime": "431015"
        },
        "ssh_session_table": [],
        "fan_level": 0,
        "general_temperature": 62,
        "overheating": false,

Question: Update frequency?

Hello,
Currently it appears the sensor state updates only every minute. Is it possible to increase the frequency and if so how please?
Thanks

Getting tons of errors "Expecting value: line 2 column 1 (char 1)"

Not sure when it started.

but getting a ton of these errors:

2021-03-27 19:32:00 ERROR (SyncWorker_21) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2021-03-27 19:32:01 ERROR (SyncWorker_12) [custom_components.unifigateway.sensor] Failed to access alerts info: Expecting value: line 1 column 1 (char 0)
2021-03-27 19:32:01 ERROR (SyncWorker_28) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2021-03-27 19:32:01 ERROR (SyncWorker_2) [custom_components.unifigateway.sensor] Failed to scan aps: Expecting value: line 2 column 1 (char 1)
2021-03-27 19:32:01 ERROR (SyncWorker_7) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2021-03-27 19:32:01 ERROR (SyncWorker_43) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)
2021-03-27 19:32:01 ERROR (SyncWorker_15) [custom_components.unifigateway.sensor] Failed to access health info: Expecting value: line 2 column 1 (char 1)

IPv6 address on WAN sensor

Is it possible to add the USG IPv6 address into the WAN sensor?
I looked into the code and assume that the unified controller isn't deliver the information, right?

Add option to Include 2FA

with the recent breach Ubiquiti is pushing ppl to activate 2fa can you add a prompt to input the code otherwise we cannot connect.

`Logger: custom_components.unifigateway.sensor
Source: custom_components/unifigateway/sensor.py:87
Integration: unifigateway (documentation)
First occurred: 9:32:39 AM (1 occurrences)
Last logged: 9:32:39 AM

Failed to connect to Unifi Security Gateway: Login failed - status code: 400`

InsecureRequestWarning spams log

Hello! I find this component very useful! However, my Core log is getting spammed with this warning:

warnings.warn(
/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host '10.0.1.47'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

My config is setup as below:
- platform: unifigateway
host: !secret host_ip
site_id: !secret unifi_site_id
username: !secret username
password: !secret mqtt_password
monitored_conditions:
- www
- wlan
- firmware

The component works fine but as stated the log is getting spammed. The Unifi controller is running as an add-on to my home assistant installation. My server is not exposed to the www and SSL is not setup. I am running a fully updated HassOS image on my NUC.
I've tried reinstalling the component and also tried with and without verify_ssl. I also tried verify_ssl: true.

Default now 443?

My integration stopped working a while back, after adding the port configuration option and setting is to 8443 it's working again. Did the default change from 8443 to 443 (according to the wiki 8443 was default before)?

No WAN2 (failover) for USG Pro

I use USG Pro 4 with the integration and in the 'wan' sensor it doesn't show any info about WAN2 (failover), just WAN:

Снимок экрана 2022-02-15 в 23 39 35

Multiple sites changing sensor IDs at reboot

I have two sites and so have set my configuration as follows:

## UNIFI SENSORS
# UniFi Gateway - Site 1
  - platform: unifigateway
    host: 192.168.1.175
    port: 8443
    username: !secret unifi_username
    password: !secret unifi_password
    monitored_conditions:
      - www
      - wan
      - lan
      - wlan
      - alerts
      - firmware
      #- vpn

# UniFi Gateway - Site 2
  - platform: unifigateway
    host: 192.168.1.175
    port: 8443
    site_id: !secret unifi_site_id
    username: !secret unifi_username
    password: !secret unifi_password
    monitored_conditions:
      - www
      - wan
      - lan
      - wlan
      - alerts
      - firmware
      #- vpn

The sensors then populate as:

sensor.unifi_gateway_wan
sensor.unifi_gateway_wan_2

wan is not always the default (Site 1), and wan_2 is not always the Site 2 id.
Sometimes they switch, throwing off my named templates, e.g. wan somtimes maps to Default (Site 1) and sometimes to Site 2.

Is there a way, using a friendly name or otherwise, to always map wan to Default (Site 1) and wan_2 to Site 2?

Thanks!

Dream Machine SE / HASIO different VLAN

I can't manage to connect to a Dream Machine SE while HASIO is on a different subnet.

I created the LAN_IN rules which allow HASIO_IP to access 443 PORT but same issue
regarding the user, it's a local user, which at first was view only, I temporary changed to admin, same problem

my config file is :

  - platform: unifigateway
    host: 192.168.3.1
    port: 443
    version: UDMP-unifiOS
    username: username
    password: password
    monitored_conditions:
      - www
      - wan
      - wlan
      - lan
      - alerts
      - firmware

mDNS is enabled on both network.

I'm trying to access directly with the VLAN gateway IP but I also tried with the management IP *192.168.1.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.