I had cobbled together a small Python script to return some stats from my NTP server, that an iOS app I have called RaspController which displays them in a widget.
So I had the bright idea it wouldn’t be too difficult to import those stats in to Homey and display them in an AVD device card (Device Capabilities app).
I created a copy of the Python script on my Raspberry Pi and modified it’s output from XML format to JSON format, thinking the in-built Logic cards for JSON would be the best option (although I’ve never touched JSON or Java Script before). The output line in the script is:
print(‘{“ntp_data”:{“results”:[%(sats)s,%(clients)s,%(adjoffset)d,%(esterr)d]}}’ %{‘sats’: nosats, ‘clients’: noclients, ‘adjoffset’: result_adjoffset, ‘esterr’: result_esterr})
and this returns:
{“ntp_data”:{“results”:[9,77,-83,206]}}

After some time banging my head against the desk, with the Then Logic card Parse as JSON bombing out, no matter how I tried to adjust the script output format or the select path. I eventually tried copying and pasting the script output in to a Then Logic card Create as Text-tag. And that works fine.
My test Flow:
It’s output to the Timeline:
My question, what the dickens am I missing here, why won’t it parse the JSON output by the script, but if I copy and paste that exact same JSON it parses fine? 
(sorry if I’m missing something stupid… I’m a total newbie to JSON)
Also, anyone know a simple way to import/parse XML formatted values?
I suspect the issue is your json is typed using smart quote marks instead of straight ones. On a Mac in particular when you type quotes it helpfully uses smart (curly) quotes which break json. Google how to type straight quotes and replace them in your JSON and I suspect that will fix it
The screenshot of the script output is showing regular quotes.
Looks like this might be a bug in the Raspberry Pi app, where it’s JSON-stringifying the JSON output of your command (@Gruijter).
To avoid discussions about fancy quotes and straight quotes, you preferrably format code as < preformatted text >
Just tap the + sign at the top right, and paste the code.
Or when already pasted, just add three backtics on top and below the code block, like
Na. Dont think so. The rpi app is not intended to run large script responses/json from a flow. Homey itself caps the length of any string in a flow card anyway. I think the cap is 250 characters or so..
The response fits just fine:
The error is caused by Logic trying to parse the string as a JSON object, when it’s just a string. In other words, the response token contains this:
"{\"ntp_data\":{\"results\":[8,77,435,329]}}"
And not this:
{"ntp_data":{"results":[8,77,435,329]}}
The only reason I can find why this would happen is because of the JSON.stringify() call that I linked to.
That was my only thought, that for some reason, some how, the Raspberry Pi app was adding the outer " " around the JSON which the Homey JSON Parse card was spitting out. But I have no idea how I can solve that? Is it just a bug with the Raspberry Pi app?
I’m not trying to exceed any Homey caps on length I don’t think. I’m only trying to return that shot JSON of no more than 50 characters. I could shorten the path in CLI call, but that doesn’t seem to be having an issue executing, as it is returning the response, just with an extra pair of " " quotation marks around the JSON the Python script returns. @Gruijter why does the Raspberry Pi app add these " "?
Do you know of any way I can un-stringify the response, so that the JSON parser will accept it?
You can use a HomeyScript for that:
(in the last card you have to choose between two Result tags and it’s completely unclear which one belongs to which previous card, so make sure you pick the right one)
@robertklep I’m unclear on the Homey Script part, as I haven’t used that yet. Is it just that card after installing the app, or is that card calling something else, like another script?
(Apologies if I being a dummy, I’m still fairly new to Homey… but even so wishing I had waited a little longer until SHS was released, as my Homey Pro 2026 is already creaking with low RAM and high CPU… I have it sat on top of 120mm fan to keep temps down ha ha)
Your assistance and knowledge are greatly appreciated.
@Gruijter on a complete tangent, can I ask you why this When trigger card doesn’t seem to work with any on my Raspberry Pi 5’s?
I can SSH as many sessions as I like, but not get a single trigger from this card. And if I go to the RPi’s device card and look at the stats, all logged in sessions are accounted for in the number under the User icon. And if I log in again, that number increases within a few seconds. It’s frustrating me no end, as mostly the app is awesome.
@robertklep hugely appreciate your assistance and knowledge with this. A bunch of tinkering later I have it working exactly as I had hoped… it’s bleeding marvellous
thank you dude.
The finished article:
Now to tackle those pesky Login triggers that don’t seem to work at all… @Gruijter please help
Havent looked at the rpi app for a while. Probably mismatch in os version. When time and energy I will check it out.
So many apps, so little time
Thank you @Gruijter, it would be massively appreciated.
EDIT: there have been a few updates to Pi OS recently. I’m currently running the most up to date version of Bookworm (Debian 12), which I do intend to update on all my Pi’s to Trixie (Debian 13). I have a few Pi’s to update, but I’ll get there.
I don’t know if that helps at all.
When you “hover” the [Result] tag, the tag icon in the 'source" card starts to wave
, and that card starts to “glow” veeeeery subtle blue-ish (on top of that, it can take a while for this effect to show on a slower machine like a tablet).
And it’s just bad luck design if that ‘source’ card is outside of your (zoomed) view; you’re on your own then.
Luckily Athom made sure it’s very hard to notice 
I always temporary remove the input line of the predecessing card, then you’d have only one [Result] to select. Shouldn’t be necessary.
Also, if when in the Advanced Flow editor you start the flow, when you hover over the tag in a card the tool tip pops up showing the data contents.
I didn’t have a problem with this, if you notice in my screenshot above, the first flow tag is named Response, the following 2 although both being called Result are different colours due to the first (green) being text, and the second (blue) being a number.
There are numerous subtle signs, almost like Athom wanted to keep us all guessing… like breadcrumbs on a trail 
OMG that’s very subtle. At least so much so that I never noticed this… 