Custom_component: PhoneTrack GPS device tracker

Hi

I get the below when trying to add this as a custom respository in HACS

Could not add j1nx/homeassistant-phonetrack at this time, check the log for more details.

I have tried both


j1nx/homeassistant-phonetrack

So not sure why it’s not working. Any advice on how to solve.

Cheers

The structure of the respository is not correct for HACS.

The component has to be in the folder “custom_components”.

Ah, ok, that can be done easily. Hang on …

EDIT: Done!

Thanks - component working but not the sensor

token: <SHARED_VIEW_TOKEN> - Is this the SESSION Token Number?

devices:
- <DEVICE_NAME> - Assume these are the device names given in Phonetrack

and finally which new entities should be create in HA

Sorry about all the questions :slight_smile:

hi. i’ve added the folder inside the custom_components, added the code in device_tracker. Restart homeassistant and this error come up:

Log Details (ERROR)
Thu Jul 11 2019 17:04:23 GMT+0200 (Ora legale dell’Europa centrale)
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
    tracker.see, 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 224, 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

See attached picture (although Dutch);

Click the sharing icon (red square)

You need the API-URL as selected with the black square. It contains all the info you need, including the TOKEN (No it is not the same token as you use for logging)

Device name is the name as selected in the bottom red square.

Hope this helps.

@hangy Could you post the (anonymized) configuration.yaml section you are using. I suspect something is wrong there.

now it’s ok. i was using the Token Session… :wink:

1 Like

Ok, cool!

IT is all quick code without any proper error handling for mis-configurations. Have that on the list though to start learning some Python.

Let me know how it holds up for you.

Brilliant Peter all working - this is a great additional to HA
Really appreciate the help and efforts

1 Like

No problem. Will update the README with above information to help others in advanced.

See https://gitlab.com/eneiluj/phonetrack-oc/issues/271 if you want the other way around, i.e. have phonetrack record a device from HA

SOLVED
Tried it again after some days, now it works adding
j1nx/homeassistant-phonetrack
to HACS.

Tried to add

j1nx/homeassistant-phonetrack

to HACS (tried both Categories Integration and Plugin) , but also got the messages

Could not add ‘j1nx/homeassistant-phonetrack’ with type ‘integration’ at this time.
If you used the correct type, check the log for more details.

But no details in the log.
Do i have to be logged into github during adding the repo to HACS ? Or what did i probably wrong

System: pi3 - HassOS 2.12/Supervisor 192 and (HACS 0.16.3)

Super, works a treat.
only issue is it is only showing me one of two devices i added.
my configuration is below, can someone here confirm this is the correct way of defining it:

- device_tracker:
  - platform: phonetrack
    url: http:/<DOMAIN>/index.php/apps/phonetrack/api/getlastpositions/
    token: <TOKEN_1>
    devices
    - <DEVICE_1>
    
  - platform: phonetrack
    url: http://<DOMAIN>/index.php/apps/phonetrack/api/getlastpositions/
    token: <TOKEN_2>
    
    devices:
    - <DEVICE_2>

I created a group within phonetrack and added both my wife’s and own phone to that group. Then used the link and token of that group. That way you can have just both devices within the same devices section of one integration.

I tried that, not sure if the space in the device name is causing the issue.
will have to check next week on her phone when my wife is back

found the issue :grimacing:
the configuration (even with 2 separate trackers) is fine
the device name had a trailing space !

1 Like

@j1nx Thank you so much!
It works perfectly!
I’m wondering why there aren’t any official Nextcloud integrations/components.
I would imagine there’s a large overlap in Homeassistant/Nextcloud users.

I believe nextcloud is around the corner / i see something in 0.108 release. Haven’t checked it though. To busy with mu other project.

@j1nx - thank you for this component! Are you still using it? I’ve installed it yesterday in my current setup and while it doesn’t throw any error, I cannot see any new entity or sensor or tracker (can I have an example of what the component should create?).

In the logs I cannot only see:
2020-11-18 12:04:08 DEBUG (SyncWorker_0) [custom_components.phonetrack.device_tracker] Updating devices None

during the first connection and then I can see a few
2020-11-18 12:09:08 DEBUG (SyncWorker_10) [custom_components.phonetrack.device_tracker] Updating devices 2020-11-18 11:09:08.860279+00:00

Which looks like it’s getting some information - but I cannot see it anywhere. Maybe it’s just that I do know what to look for? :slight_smile:

Not really using it myself anymore at the moment. My nextcloud crashed and haven’t found the “will” to start from scratch again.

Have a look at the forks, perhaps someone picked up the development.