Closed whmoorejr closed 8 months ago
This is an example: You can later edit the waypoints if you use the same "rid" (region identifiers). You delete one waypoint/region by sending an invalid lat/lon e.g. (100.0,500.0)
{
"_type": "cmd",
"action": "setWaypoints",
"waypoints": {
"_type": "waypoints",
"waypoints": [
{
"_type": "waypoint",
"tst": 1708625557,
"rid": "my-region-id-1",
"desc": "home",
"rad": 100,
"lat": 30.0,
"lon": 40.0
},
{
"_type": "waypoint",
"tst": 1708625558,
"rid": "my-region-id-2",
"desc": "work",
"rad": 100,
"lat": 30.1,
"lon": 40.1
}
]
}
}
Waypoints / regions cannot be published from the device to other users, but in Settings you can export waypoints or publish them to the server.
The latter are then stored in <STOREDIR>/waypoints/user/device/
as individual waypoints (*.json
) and as all waypoints from a device (*.otrw
) and can then, for example, be published as @ckrey just showed, to other users. You might need to adjust the JSON itself.
The *.otrw
file can be imported into iOS.
I'm making progress. I'm testing a lot between replies to hopefully have a better understanding of where I'm at...
Outside of a device, (i.e., another computer on your network) what is the best way to publish or subscribe to events? I'm not sure if what I'm seeing is accurate, but it looks like there is a layer of screening maybe.
I have to use an owntracks username / password to log into the MQTT to subscribe or publish. That seems to work and I can see some topics (user, device and info for all devices) I was able to publish a card. Then I noticed I was logged in as the user "indigo" when I published a card to the "indigo" phone. (One of the phones running an older version that doesn't have a "card" creation option on it.) Trying to publish a card to any other device did nothing. Similarly with any cmd topic. I can publish a cmd topic to the Indigo device, but only to that one. If I adjust publish settings to owntracks/anything_besides_Indigo/myphone/cmd I don't even see any traffic on the MQTT in terminal when I'm watching sudo mosquitto_sub -v -t 'owntracks/#'
Then I realized that all the things I'm not seeing are all the things that don't publish from device to device. If on my device (owntracks/bill/myphone) I publish my waypoints, I will see it on the terminal (rPi), but I can't see it from any other application (MQTT Explorer, or from my Indigo home automation platform)
Previously, I had user names and passwords for each device and a separate login I used for my local network connections for the MQTT broker, which allowed me to publish a cmd topic to any device from another computer on my network (mainly from my home automation computer). Is this still doable? Is the behavior I'm seeing accurate?
Previously, I had user names and passwords for each device
with quicksetup you still do: you specified users in configuration.yaml
and their passwords where generated into files in /usr/local/owntracks/userdata/*.pass
and a separate login I used for my local network connections for the MQTT broker
You have this as well; it's the _lr
user, documented here
Interesting. So I have the password now for the _lr user. A couple things...
FYI: These are some of my goals for OT implementation (so you know why I'm trying to get access in different ways)
EDIT: Last question...for now :-) Is there a publish wildcard option: Can I publish a command to all devices? /owntracks/++/myphone/cmd (where "myphone" is the same for everyone's primary device)
OK, I think this is going way off-topic for this issue, so I'm closing here.
Feel free to open new issues at Quicksetup.
Can I publish a command to all devices?
MQTT doesn't know how to wildcard-publish, so no. You'd have to do that individually.
Sorry, I know this should be closed. I can now sucessfully publish a cmd to any device... that's a huge win... I think my formatting for a waypoint is still off. I did verify that the cmd toggle on the device is selected. I published a waypoint, but it didn't populate on the device. This is traffic from the broker, am I missing something?
owntracks/bill/myphone/cmd { "_type": "cmd", "action": "setWaypoints", "waypoints": { "_type": "waypoints", "waypoints": [ { "_type": "waypoint", "tst": 010, "rid": "my-region-id-010", "desc": "Woodlands|1|2", "rad": 250, "lat": 30.14447, "lon": -95.51607 } ] } }
Are you publishing with a qos>0 ?
No and yes. I'm publishing with qos 1, but when I look at the message on MQTT Explorer, it shows qos 0.
That happens if I publish from within MQTT Explorer or from within my home automation system... both logged in as user "_lr"
Your problem is that 010
is not a JSON number (https://www.json.org/json-en.html)
tst
here means timestamp of creation, but if you want to use the value ten (10), write 10, not 010.
log on the iPhone:
2024-02-23T15:28:45.677Z Validation error: Error Domain=NSCocoaErrorDomain
Code=3840 "Number with leading zero around line 1, column 127."
UserInfo={NSDebugDescription=Number with leading zero around line 1, column 127., NSJSONSerializationErrorIndex=127}
with
{ "_type": "cmd", "action": "setWaypoints", "waypoints": { "_type": "waypoints", "waypoints": [ { "_type": "waypoint", "tst": 010, "rid": "my-region-id-010", "desc": "Woodlands|1|2", "rad": 250, "lat": 30.14447, "lon": -95.51607 } ] } }
That worked. Thank you Mr. Krey! It doesn't need to be "10". I just wanted to fill in the blank and make it work. I don't have a need (at the moment) to know exactly when a waypoint was created.
log on the iPhone:
Holly crap! I just now realized those were log files not logs. A quck glance after looking at the "Logs" screen, I thought, nothing much to see here, move along. Airdrop the file to my mac and presto. I'm an idiot.
Did I at least put the "|1|2" in the right spot? Documentation says to write it with the name... on the device it's "Name" on publish it's "desc".... but that should switch the phone to significant on enter and move on exit.
I'm not sure if this is a possibility or not. I fully understand how to create and use a waypoint / region / geofence from a device and how enter/leave notices are published from that device and subscribed to from other devices.
Question... can the waypoint / region / geofence from one device or from the server side be published out to user devices so everyone has the same geofence?
My assumption would be the
{"_type":"cmd", "action":"setWaypoints", "waypoints":{"_type":"waypoints","waypoints":[...]}
and publish that json message to each device individually? If so, can you provide an example of that json filled out?