custom-components / authenticated

A platform which allows you to get information about sucessfull logins to Home Assistant.
MIT License
82 stars 28 forks source link

Sensor will not load #48

Closed acordill closed 4 years ago

acordill commented 5 years ago

Version of the custom_component

1.2.0 Describe the bug A clear and concise description of what the bug is. The sensor will not load log

2019-09-17 17:13:40 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for authenticated which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-09-17 17:13:41 ERROR (MainThread) [homeassistant.components.sensor] authenticated: Error on device update!
  File "/config/custom_components/authenticated/sensor.py", line 209, in update
ludeeus commented 5 years ago

And where is the rest of the log?

acordill commented 5 years ago
2019-09-18 00:17:08 ERROR (MainThread) [homeassistant.components.sensor] authenticated: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 441, 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 "/config/custom_components/authenticated/sensor.py", line 189, in update
    for ipaddr in sorted(tokens, key=lambda x:tokens[x]['last_used_at'], reverse=True):
TypeError: '<' not supported between instances of 'str' and 'NoneType'
jimmyeao commented 5 years ago

Having the same issue since HASS 0.99

a323870 commented 5 years ago

me too after upgrade HA from 0.98.5 to 0.99.2

a323870 commented 5 years ago

Upgrade HA to 0.100 but the problem persist.

2019-10-10 11:28:14 ERROR (MainThread) [homeassistant.components.sensor] authenticated: Error on device update! Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity await entity.async_device_update(warning=False) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 448, 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 "/media/usb2/homeassistant/custom_components/authenticated/sensor.py", line 209, in update tokens, key=lambda x: tokens[x]["last_used_at"], reverse=True TypeError: '<' not supported between instances of 'str' and 'NoneType'

SiliconAvatar commented 5 years ago

After upgrading to 0.100.2 I'm experiencing this issue as well, which was not present before upgrading from 0.99.X to my knowledge.

The error log is:

authenticated: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, 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 "/config/custom_components/authenticated/sensor.py", line 209, in update
    tokens, key=lambda x: tokens[x]["last_used_at"], reverse=True
TypeError: '<' not supported between instances of 'str' and 'NoneType'
waltermo commented 5 years ago

Exact same issue with exact same error in the log. On 0.99.2

adrien4 commented 5 years ago

Same issue with 99.3 and 100.3

dorko87 commented 5 years ago

Same issue with 100.2

jperquin commented 4 years ago

Same issue with 100.3

romquenin commented 4 years ago

Same issue.

arsaboo commented 4 years ago

Same issue with 101.3

DavidFW1960 commented 4 years ago

This is weird... mine has not stopped working and is working now as well... I wonder what the issue is? This was updated 20 days ago - I assume y'all are running the latest one?

SiliconAvatar commented 4 years ago

I assume y'all are running the latest one?

Version 1.2.0 according to HACS. Also, the error references a specific bit of code in sensor.py at line 209 (tokens, key=lambda x: tokens[x]["last_used_at"], reverse=True) which is the same as the version of sensor.py on github, so the error seem to match the latest version.

Honestly, I'm not sure how python's sorted function works, but it's used in line 208 to sort the output of line 209. Line 209 seems to be extracting something with a key/value pair that contains "last_used_at". The error is saying it can't compare a string and NoneType. So it looks like one of the entries in the list (or dict, whatever) is correct and one is NoneType, causing the sort function to fail.

In line 168 it's pulling this data for the list from storage/auth.

When I look in my own auth file, I see an entry with "last_used_at": null, in it. If I had to guess, this is what's generating the error.

@ludeeus , does this seem correct? If so, is this a case that can be guarded against?

andriej commented 4 years ago

I have the same error, latest hass.io image (0.101.3) and latest authenticated (1.2.0):


Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 450, 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 "/config/custom_components/authenticated/sensor.py", line 209, in update
    tokens, key=lambda x: tokens[x]["last_used_at"], reverse=True
TypeError: '<' not supported between instances of 'NoneType' and 'str'
ludeeus commented 4 years ago

I have not been able to replicate it, not even with changing the auth file to have null values... https://github.com/custom-components/authenticated/releases/tag/1.2.1 have some more checks.

SiliconAvatar commented 4 years ago

After updating to 1.2.1 the error is gone. Thanks!