I’m not sure what that is, but if you expect those to be variables, what is loading the variables, and 2 that is not a template so that would be sent up as literally what you type if it is accepted at all.
The topic appears to have been set-up by Owntracks. Pushing data to that topic would be confusing things. Is there something telling you to do this? I smell an LLM hallucination suggestion coming on here…
Once you figure out what is the right topic and you have your data, IO suggest looking here for format suggestions:
Not sure what a “LLM hallucination” is, I do know I am a hacker playing in water over his head and beyond his understanding. I am trying to utilize Owntracks. and trying obtain the steps recorded by mu iPhone. The gibberish I posted was supposed to be out put by a python program I was provided under GitHub
#!/usr/bin/env python3
import datetime
import time
import json
import sys
days = -1 # yesterday
days = 0 # only 0 or negative values make sense
def unix_epoch(t, delta):
dt = t + delta
return int(time.mktime(dt.timetuple()))
now = datetime.datetime.today()
f = now.replace(now.year, now.month, now.day, 0, 0, 1, 0)
t = now.replace(now.year, now.month, now.day, 23, 59, 59, 0)
delta = datetime.timedelta(days=days)
payload = {
'_type' : 'cmd',
'action' : 'reportSteps',
'from' : unix_epoch(f, delta),
'to' : unix_epoch(t, delta),
}
print(json.dumps(payload))
I can’t seem to get that program to run. (I guess I am supposed to to create an action) and can’t figure out how to access the steps that the iPhone pedometer is suppose to have recorded. Like I said I shouldn’t be playing with matches. Thank you for your time
Try something way simpler than trying to run a Python script to generate a JSON payload that you then paste into a Home Assistant script, especially since you recognize you’re in over your head. Break the problem up into pieces.
First, try to successfully run mqtt.publishwithout a JSON payload, on a clear topic that somebody else isn’t posting to. That way you know that you’ve got at least the basic building block you need before trying to build with it.
Go to Developer tools → Actions and run this while listening on the topic my_test/test:
action: mqtt.publish
data:
topic: "my_test/test"
payload: "FROM HA DEVELOPER TOOLS"
Thanks for your response. Yes your sample went through. I think I have a workable understanding of the mqtt.publish, I know where all the topics show on my broker are coming from. The core of my issue I think is how can I access the steps that the iPhone pedometer is suppose to have recorded. I think it is in a JSON file (database?). somewhere. The payload I showed with real content was was published by owntracks “send locatiion” which is suppopsedly built into home assistant.
looking at the Owmtracks documentation is built this action
I don’t know anything about OwnTracks, but the front of its documentation (“What it does”) makes me think that you cannot publish commands yourself. Instead, OwnTracks probably simply pushes data from the phone as it receives it. This makes sense; to respond to commands that you push to OwnTracks, the service would need to run something much more sophisticated in the cloud than what is required if the OwnTracks app is just pushing MQTT payloads from the phone to the cloud.
I’m guessing you should be listening on the topic owntracks/jason/iphone/step for an MQTT message with _type set to steps.
If you’re listening to owntracks/jason/iphone/, which is where you’ve also been trying to publish messages (probably to no avail, as noted above), all you’re getting is type: location messages because you’re only listening to that specific topic, not to subtopics. Per the Topics section in the JSON API documentation from OwnTracks:
In MQTT mode the apps publish to:
owntracks/user/device with _type=location for location updates, and with _type=lwt
. . .
owntracks/user/device/step to report step counter
If you listen to owntracks/jason/iphone/#, you will get messages published to subtopics, too, like owntracks/jason/iphone/steps. Or if what you want to be getting is just the steps messages, then listen on owntracks/jason/iphone/steps.
Hopefully this gets you started enough to where you can understand the rest of the OwnTracks documentation.
we crossed each other in messages
(as you can see below). I understand what you are saying and the bottom line maybe is that what I am trying to do , record steps, can not be force by publishing I will subscribe at the device level and see what happens
owntracks
jason
iphone = {"_type":"location","acc":42,"alt":0,"batt":0,"bs":1,"conn":"w","inregions":[],"inrids":[],"lat":45.407425,"lon":-122.665351,"m":1,"tid":"jh","tst":1760759836}
Nothing seems to publish steps. That is publishsed when I send my location using owntracks. I think I have an issue with owntracks. and like you said you aren’t familiar heck neither am I obviousily. Looking at the owntracks booklet. and corresponding GitHub repository. I’m back to the mosquitto_pub -q 2 -t owntracks/jj/5s/cmd -m '{"_type" : "cmd", "action": "reportSteps"}'