Duplicate contacts in Friends view
Client
iOS app
Server
Homeassistant
Precondition
I have set up the Owntracks app in two iOS devices which report location via HTTP. Let's assume that tracker ids are i1 and i2 for user1 and user2
Expected result
In the friends view I should see 2 circles one for each device.
Actual result
Whenever I select the Friends view on each device I see 2 green circles (filled in yellow) and another blue one (also filled in yellow). Clicking over the circles I see that they are identified as (in the 1st device)
-
owntracks/user1/XXX(blue circle for user1) -
owntracks/http/i1(green circle for user1) -
owntracks/http/i2(green circle for user2)
as you can see there are 3 "entities", 2 of them for the same device.
Similar to this in the other device I see
-
owntracks/user2/XXX(blue circle for user2) -
owntracks/http/i2(green circle for user2) -
owntracks/http/i1(green circle for user1)
Maybe this is expected, but I haven't found any piece of documentation describing this situation. I'd love to know the rationale of this behaviour in case it isn't a bug.
Note: in both devices the location shown in the map for the duplicated entry is not the same as the location for the other two ones, it's slightly different.
@svilar this is an issue for home assistant because the integration with OwnTracks is not complete or the home assistant documentations. Please open an issue there if you are looking for a decent fix.
The blue circle is the device OwnTracks knows. The devices with a green circle are other devices returned by homeassistant.
The unique ID OwnTracks uses to identify a device is the topic. As a default it constructs the topic as owntracks/<UserID>/<DeviceId> e.g. owntracks/user1/XXX.
homeassistant uses the UserID and DeviceID OwnTracks sends to construct an entry in it's database device_tracker.<UserID>_<DeviceID> e.g. device_tracker.user1_XXX.
In homeassistant you define Persons and link them to trackers. When homeassistant returns the positions of friends back to OwnTracks, it does not deliver a full topic, but only a TrackerID (TID), which it constructs from the initials of the Person. If topic is missing in the message returned, OwnTracks makes a guess and constructs a topic as owntracks/http/<TID> e.g. owntracks/http/i1. As you can see the local topic does not match the topic guessed from homeassistant's message.
As a workaround you may change your setup as follows:
User1 is now:
- OwnTracks UserID: user1
- OwnTracks DeviceID: XXX
- homeassistant Tracker: device_tracker.user1_XXX
- homeassistant Person: iPhone 1
User2 is now:
- OwnTracks UserID: user2
- OwnTracks DeviceID: XXX
- homeassistant Tracker: device_tracker.user2_XXX
- homeassistant Person: iPhone 2
User1 workaround:
- OwnTracks UserID: http
- OwnTracks DeviceID: i1
- homeassistant Tracker: device_tracker.http_i1
- homeassistant Person: iPhone 1
User2 workaround:
- OwnTracks UserID: http
- OwnTracks DeviceID: i2
- homeassistant Tracker: device_tracker.http_i2
- homeassistant Person: iPhone 2
Reported in HomeAssistant's repo