Iāve tried your suggestions - firstly just adding to the URL and then changing the path within the sensor.py file but not having any luck - Iām getting this error in my logsā¦
2021-01-29 11:57:40 ERROR (MainThread) [homeassistant.components.sensor] my_unifi: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
await 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/my_unifi/sensor.py", line 107, in update
self._data.update()
File "/config/custom_components/my_unifi/sensor.py", line 240, in update
for device in device_list:
TypeError: 'NoneType' object is not iterable
Does that suggest that the changes havenāt worked?
hmā¦ not sure. It seems that either it couldnt login (but you should see a error saying that) or the API has changed a little bit more than we thought, because the line 240 is where the number of devices per essid is accounted. I will look more carefully at the code and will ask you to do a few more tests.
Ah, I missed a login error that was a little bit above this in my logs, hence missing it - I know the login is correct as it hasnāt changed but perhaps I need to do something with the new OS.
facing exactly the same issue and was wndering why nobody sppoke about it like port change and api call changesā¦ well fortunatley there are people out there I have a unifi controller running on the UDM basic Dream Machine. Hoope we will fix this as this sensor was just awesome
I may have a solution, but need someone to test. I made a simple script from the code of the sensor, but itās made to run āstand aloneā. Edit the variables USERNAME and PASSWORD. If you have the new controller (of course you do :-), change the UDM to āTrueā. If everything went as expected it should return a big json with all data from the controller (clients, aps, etc).
Ahā¦ do NOT add the āproxy/networkā in the baseurl.
running on a docker, with each update this will be gone I expectā¦ looking for something more permanent but interesting topics to follow, also looking in what is available with snmp to make something usefull,
Apologies as I completely missed your last couple of messages
Iāve tried to test your script but get no output whatsoever? Iāve changed the URL, username and password to the correct values and also changed UDM to True but nothing is output to the console I also changed UDM to False to see any errors but I get nothing there
I have managed to bastardise what youāve written into my sensor.py and Iām no longer getting login errors but I am now getting these errors: (All log aspects related to the component included for completeness)
2021-02-23 10:48:34 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for my_unifi which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2021-02-23 10:48:34 INFO (MainThread) [homeassistant.loader] Loaded my_unifi from custom_components.my_unifi
2021-02-23 10:48:42 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.my_unifi
2021-02-23 10:48:43 ERROR (MainThread) [homeassistant.components.sensor] my_unifi: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 358, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
await 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/my_unifi/sensor.py", line 107, in update
self._data.update()
File "/config/custom_components/my_unifi/sensor.py", line 239, in update
device_list = (self.list_clients())
File "/config/custom_components/my_unifi/sensor.py", line 198, in list_clients
data = r.json()['data']
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
hmā¦ no, it didntā¦ I need to figure out how to test this, as I dont have a UDM. I will update the custom integration and put a bit of logging inside so it will be easier to test (without the external script).
Hello,
Iāve copied my_unifi, and created sensor, but it shows nothing:
In logs Iāve got only: āYou are using a custom integration for my_unifi which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.ā
This is my configuration:
my_unifi: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 358, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
await 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/my_unifi/sensor.py", line 107, in update
self._data.update()
File "/config/custom_components/my_unifi/sensor.py", line 240, in update
for device in device_list:
TypeError: 'NoneType' object is not iterable
The site will be the element after āsiteā, in the examplo above, is default and you will not need to se āregionā. Also, enclose user and password in single quotes ā ā
I decided to rewrite my unifi sensor, but this time using the unificontrol library, so hopefully it will work with various unifi versions as soon as the library support it (thereās work done and should be merged in the stable version). So hold on for a few weeks :-).