homeassistant-phonetrack
homeassistant-phonetrack copied to clipboard
Integration doesn't seem to be working anymore
I get the following errors when starting up homeassistant with this integration:
2020-07-12 16:12:52 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 76, in async_setup_legacy
discovery_info,
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/phonetrack/device_tracker.py", line 33, in setup_scanner
PhoneTrackDeviceTracker(hass, config, see)
File "/config/custom_components/phonetrack/device_tracker.py", line 50, in __init__
self._update_info()
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/phonetrack/device_tracker.py", line 61, in _update_info
data = data[self.token]
TypeError: list indices must be integers or slices, not str```
Is there anything I can do to fix this?
@Sjorsa1 and maybe others that see this issue. This error occurs when your token is wrong as the phonetrack API returns an empty list []
when the token does not exist.
You can test this yourself by navigating to the url https://<nextcloud-domain>/index.php/apps/phonetrack/api/getlastpositions/<your token>
and it should return a json object like (I replaced all values of mine with 0):
{
"<token>": {
"<device_name>": {
"useragent": "PhoneTrack/0.0",
"lat": 0.0,
"lon": 0.0,
"timestamp": 0,
"batterylevel": 0,
"satellites": 0,
"accuracy": 0,
"altitude": 0,
"speed": 0.0,
"bearing": 0.0
}
}
}