owntracks / recorder

Store and access data published by OwnTracks apps
Other
820 stars 120 forks source link

Difficulty creating cards #463

Closed knirirr closed 1 month ago

knirirr commented 2 months ago

Following an installation on a clean Debian installer via quickstart I've been looking at the card documentation here:

https://owntracks.org/booklet/features/card/

Assuming I have a user john with device j-phone I'd expect to be able to generate a card with image2card.sh and then run:

mosquitto_pub -t owntracks/john/j-phone/info -f john-j-phone.json -r -q 2

...which requires sudo. The result of this is to create an additional friend called "John" (the name value I used when creating image2card.sh) which is listed as "not available" in iOS and Android apps and does not exist on the map. The face image I selected is shown for this extra friend.

I've also tried putting cards in the following directory structure (suggested by https://github.com/owntracks/recorder/issues/154#issuecomment-251097178) then reloading mosquitto and nginx:

/var/spool/owntracks/recorder/store/cards/john/j-phone/john-j-phone.json

...and there's a card I didn't create:

/var/spool/owntracks/recorder/store/last/john/j-phone/john-j-phone.json

Would someone be able to point out what I've got wrong here, please?

jpmens commented 2 months ago

The "card you didn't create" you actually did by publishijng the above payload via mosquitto_pub. The card is stored in the file system by the Recorder.

The apps should pick up the card thanks to the retained publish, but it might take a moment or two. Try restarting the apps on the mobile phones.

There's NO need to restart either of Mosquitto or nginx, and placing the cards on the file system yourself has no effect at all.

knirirr commented 2 months ago

Thanks. By "didn't create" I meant didn't place directly in the file system myself.

I've restarted apps on two phones several times and waited about 20 minutes. The cards are indeed picked up, but they don't associate with the intended users and still appear as additional entries in the friends list.

jpmens commented 2 months ago

Cards will associate with the intended users if the topics match. Assuming I am your friend and my MQTT topic is owntracks/jpmens/phone, then the card will assosicate with me only if it's published to owntracks/jpmens/phone/info, and when I publish a location which your phone picks up, then you'll see my location with my name/avatar from the card.

knirirr commented 2 months ago

As far as I can tell I've got matching topics. One thought that occured to me is that I originally created device names with an underscore, e.g. j_phone. Creating another without that underscore, creating a card and doing the mosquitto_pub did produce the desired result, i.e. an image associated with the name. I still have to work out how to delete the extraneous friends entries.

jpmens commented 2 months ago

You can delete published and retained messages by publishing a NUL retained:

mosquitto_pub -t owntracks/user/device -n -r -q 2

If you wish to remove the data (carefully), you can delete the files you've already discovered on the host:

/var/spool/owntracks/recorder/store/rec/user/device/YYYY-MM.rec

and the other subdirectories which contain user / device subdirs.

knirirr commented 2 months ago

Thanks. The mosquitto_pub command you mentioned had no effect, but deleting the relevant files eventually got me to a list of devices/users which look correct at $MY_SERVER/owntracks/table/ The Android and iOS apps are still a mess, though, with additional entries as previously described.

jpmens commented 2 months ago

You ought to be able to swipe out the Friends from the devices.

knirirr commented 2 months ago

On iOS I can swipe them away but they reappear when the app is reopened. On Android I can't.

jpmens commented 2 months ago

On iOS I can swipe them away but they reappear when the app is reopened.

If they reappear it's because there's still a retained message floating around. You mentioned earlier the mosquitto_pub with the null payload didn't do anything, maybe b/c you mistyped the topic?

If you open the Friends list and hit (i) on the particular friend you wish to remove, you should see the topci name in the details. Use that topic to publish a retained null as explained earlier and then swipe out the friend. They should be gone for good.

knirirr commented 2 months ago

I don't think it was a case of mistyping as in a typo, but I think it would be '-' vs. '_'. I originally used underscores when creating device names but they've been converted to minus signs in some places. I'll have to remember not to use any underscores when creating future device names as that might well have been the root of the trouble. Thanks for your assistance. Once I've checked on more app (not possible right now) I can close this if all is well.

jpmens commented 2 months ago

I think you said you set this up with our Quicksetup. I don't see offhand where we would be replacing underscore by dashes...

knirirr commented 2 months ago

Nevertheless, I see topics such as owntracks/john/j_phone, john/j-phone in my server's device table, and files such as /var/spool/owntracks/recorder/store/last/john/j-phone. This certainly confused me. Sorting this out, plus clearing all retained messages from mosquitto, appears to have solved my issue. Thanks again for your help.