I tried this config but get stuck on the first login i guess.
2024-05-27 12:57:38.068 INFO (MainThread) [homeassistant.setup] Setting up rest
2024-05-27 12:57:38.075 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from https://www.one2trackgps.com/users/***/devices
2024-05-27 12:57:38.705 INFO (MainThread) [custom_components.hacs] <HacsData restore> Restore done
2024-05-27 12:57:38.857 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.783 seconds (success: True)
2024-05-27 12:57:38.858 INFO (MainThread) [homeassistant.setup] Setup of domain rest took 0.79 seconds
2024-05-27 12:57:38.954 INFO (MainThread) [homeassistant.components.sensor] Setting up rest.sensor
2024-05-27 12:57:38.955 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: {"error":"You need to sign in or sign up before continuing."}
2024-05-27 12:57:38.958 WARNING (MainThread) [homeassistant.components.rest.util] JSON result was not a dictionary or list with 0th element a dictionary
Very stupid response but: did you login on the online dashboard first? I think I had the same first (but while trying scrape). Then update the cookie value after if it’s changed.
Another stupid thing might be that the resource link isn’t right if you have a space in the username. Change spaces to %20. Or check what the link to the dashboard is in the browser while logged in.
You could also change the link to just the base link and see where that gets you.
Apparently your response is not stupid at all:
After checking on typing errors (there where none) i logged in with chrome on one2trackgps.com.
Toggled both options:
agree to terms
remember me
When logged in (chrome only) F12 > application > storage > cookies > one2track… > _iadmin, copy value.
I pasted that value in configuration.yaml rebooted hass it started working and after i set the right device id (reboot) i was able to see the attributes of the entity.
Update: to make sure it will keep working login with an incognito window and close that window after copy of values without login out.
It almost the same as on this page only with other values.
Thank you! I am very glad to read it seems possible to integrate the One2Track watches into HA. However I’m stucked following your steps.
I do have 2 sensors after pasting the YAML-code into configuration.yaml (and rebooting) - I do see two entities in Developer tools > States. I’ve replaced all uppercase parts except ‘ONE2TRACK_DEVICEID’.
The only line containing ‘one2track’ is this one:
2024-07-07 21:07:51.454 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from One2Track (with my username not containing spaces instead of ‘USERNAME’)
I have no idea how to find the correct value in log files. Can you enlighten me?
I do own multiple watches. In your YAML snippet it seems to be a generic value and not device specific - is that right?
I am trying to link the one2track device to my HA. Unfortunately it isnt working yet. I got some warning and the sensor is visible but without any attributes
JSON result was not a dictionary or list with 0th element a dictionary
It seems that the data could be fetch when I look at the log:
2024-07-12 13:45:06.974 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from https://www.one2trackgps.com/users/USERNAME/devices
2024-07-12 13:45:07.263 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: [{"device":{"id":ID,"serial_number":"SERIAL","name":"NAME","phone_number":"0031XXXXXXX","status":"WIFI","uuid":"XXXX-XXXX-XXXX","last_location":{"id":XXXX,"last_communication":"2024-07-12T13:40:01.000+02:00","last_location_update":"2024-07-12T09:08:12.000+02:00","address":"XXXXX, XXXXBD XXXXXX","latitude":"51.XXXXXX","longitude":"4.XXXXXX","altitude":"0.0","location_type":"WIFI","signal_strength":48,"satellite_count":0,"speed":"0.0","battery_percentage":60,"meta_data":null,"host":"5.XXX.66.64","port":4000},"simcard":{"balance_cents":XXXXX,"tariff_type":"prepaid"}}}]
2024-07-12 13:45:07.271 WARNING (MainThread) [homeassistant.components.rest.util] JSON result was not a dictionary or list with 0th element a dictionary
The device id is device specific. You should be able to find it in the log, but the line is not labeled One2track. (Which is why you couldn’t find it, I think.) Search for any of the values, latitude maybe? It should be in there. If you look at the log added by the poster below you, you see this line:
2024-07-12 13:45:07.263 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource: [{"device":{"id":ID,"serial_number":"SERIAL","name":"NAME","phone_number":"0031XXXXXXX","status":"WIFI","uuid":"XXXX-XXXX-XXXX","last_location":{"id":XXXX,"last_communication":"2024-07-12T13:40:01.000+02:00","last_location_update":"2024-07-12T09:08:12.000+02:00","address":"XXXXX, XXXXBD XXXXXX","latitude":"51.XXXXXX","longitude":"4.XXXXXX","altitude":"0.0","location_type":"WIFI","signal_strength":48,"satellite_count":0,"speed":"0.0","battery_percentage":60,"meta_data":null,"host":"5.XXX.66.64","port":4000},"simcard":{"balance_cents":XXXXX,"tariff_type":"prepaid"}}}]
I’ve updated the plugin, it seemed to only update on restarts of HA
It now also takes zones into account and changed the icon to a watch-icon.
@one2track in what unit is the “signal_strength” field? HA likes a location accuracy field in meters. Is there any way I can convert it like that? Or is signal_strength the cellular strength? And any change you can add the currency of the balance to the web api?
maybe a stupid question which not belongs in this topic, but how to remove the location from the watch when its not online? the last known location is displayed in the map and is counting for a zone, as zone.home
@onsmam what do you expect exactly? Are you saying that when the watch goes offline you want it to no longer give a location but rather be something like ‘unknown’?
I’m not sure that would be something for in the plugin or something to manage somewhere inside HASS. But I could look into something like that as an option.
yes, ive now managed to do this via an automation.
and an extra device tracker which i can manipulate.
So i can use it in the zone.home count, and see that the kids are home, so when i leave the house does not go into offline mode.
I took the liberty to expand on your codebase, still a little bit in testing mode, but my fork of your repo supports a service send_device_command, which allows to send commands that are available through the web api of One2Track (anyone can research e.g. using chrome dev console).
@jurrienx awesome, would be great to work on this together. Happy to merge any PRs into my repo.
Wouldn’t it be nicer to split out the command we know into different services? So that you can just call a shuwdown-device or force-update-location service on the devices?