clyra / unifics

Unifi Counter Sensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON Error

ZuluWhiskey opened this issue Β· comments

Thanks for taking the time to update / rewrite your sensor for the UniFi OS / UDM kit πŸ˜ƒ

I’m getting a JSON error in the logs. My configuration:


platform: unifics
name: Unifics
host: 10.0.0.5
port: 443
username: !secret unifi_username
password: !secret unifi_password
site: default
verify_ssl: False
udm: True

Relevant logs:

2021-03-18 17:49:53 WARNING (MainThread) [homeassistant.loader] You are using a custom integration unifics 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-03-18 17:49:54 INFO (MainThread) [homeassistant.setup] Setting up unifics
2021-03-18 17:49:54 INFO (MainThread) [homeassistant.setup] Setup of domain unifics took 0.0 seconds
2021-03-18 17:49:54 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.unifics
2021-03-18 17:49:55 ERROR (MainThread) [custom_components.unifics.sensor] Unexpected error fetching sensor data: Expecting value: line 2 column 1 (char 1)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 139, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/unifics/sensor.py", line 109, in async_update_data
    data = await hass.async_add_executor_job(api.list_devices)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/unificontrol/metaprogram.py", line 157, in wrapper
    return instance(client, *a, **kw)
  File "/usr/local/lib/python3.8/site-packages/unificontrol/metaprogram.py", line 128, in __call__
    return client._execute(url, method, rest_dict,
  File "/usr/local/lib/python3.8/site-packages/unificontrol/unifi.py", line 131, in _execute
    response = resp.json()
  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)
2021-03-18 17:49:55 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.unifics entity: sensor.unifics

Just to update, I missed the UI configuration ability. Just tried this but got the following errors:

2021-03-18 18:03:34 ERROR (MainThread) [custom_components.unifics.api_wrapper] 1
2021-03-18 18:03:34 INFO (MainThread) [custom_components.unifics.api_wrapper] host=10.0.0.5, port=443, username=[username], pw=[password], site=default, cert=FETCH_CERT
2021-03-18 18:03:34 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for unifics doing I/O at custom_components/unifics/api_wrapper.py, line 34: client.list_devices()
2021-03-18 18:03:34 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for unifics doing I/O at custom_components/unifics/api_wrapper.py, line 34: client.list_devices()
2021-03-18 18:03:34 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for unifics doing I/O at custom_components/unifics/api_wrapper.py, line 34: client.list_devices()
2021-03-18 18:03:34 INFO (MainThread) [custom_components.unifics.api_wrapper] unificontrol: OK
2021-03-18 18:03:34 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.unifics
2021-03-18 18:03:34 ERROR (MainThread) [custom_components.unifics.sensor] Unexpected error fetching sensor data: Expecting value: line 2 column 1 (char 1)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 151, in async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 139, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/unifics/sensor.py", line 69, in async_update_data
    data = await hass.async_add_executor_job(api.list_devices)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/site-packages/unificontrol/metaprogram.py", line 157, in wrapper
    return instance(client, *a, **kw)
  File "/usr/local/lib/python3.8/site-packages/unificontrol/metaprogram.py", line 128, in __call__
    return client._execute(url, method, rest_dict,
  File "/usr/local/lib/python3.8/site-packages/unificontrol/unifi.py", line 131, in _execute
    response = resp.json()
  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)
2021-03-18 18:03:34 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.unifics entity: sensor.unifics_2

Not sure if this helps at all?

commented

sort of... Most of my sensor relies on the unificontrol library and it seems that after the login what is being returned is not what the sensor expects. Please, may you try this: #1 (comment) ?

Change this "server_type=unificontrol.UnifiServerType.CLASSIC" to "server_type=unificontrol.UnifiServerType.UDM".

sort of... Most of my sensor relies on the unificontrol library and it seems that after the login what is being returned is not what the sensor expects. Please, may you try this: #1 (comment) ?

Change this "server_type=unificontrol.UnifiServerType.CLASSIC" to "server_type=unificontrol.UnifiServerType.UDM".

Done - I'm happy to share the raw output with you directly. How is best to do that?

commented

may you send to [hidden]? edit any sensitive information (if any).

may you send to poplyra [at] gmail.com? edit any sensitive information (if any).

Sent πŸ‘

commented

thanks. When you installed the sensor? I did a update today because the sensor couldnt handle a few device types. For instance, when the controller list a USG.

thanks. When you installed the sensor? I did a update today because the sensor couldnt handle a few device types. For instance, when the controller list a USG.

I installed earlier on and have version 0.1.1 πŸ‘

commented

Great. And you still have problems with 0.1.1.?

Great. And you still have problems with 0.1.1.?

I do yeah, the above / original error is with running 0.1.1

Recent commits have fixed my issues πŸ˜ƒ Thanks so much for creating this sensor to be compatible with UniFi OS, I used your old one for a few automations πŸ‘