#Yep I put OK or the retrieval datetime
1 messages · Page 1 of 1 (latest)
I am actively trying to do this with this output and I can NOT get it to play nicely.
Can you take a look at the pastebin I posted a few lines up?
If you set the attribute to just value_json do you get anything back or just the invalid json? I wonder if the command is perhaps adding something around the json may be file encoding characters or something similar.
No, I don't get anything with value_json
The command appears fine. Every now and again I can change something around to get an output that HA says isn't valid
But shows up as JSON in the error
I might be tempted to write a test script to use the json directly from a file on the HA server. That way you can play around with a simple json first, then add in the [] wrapper which yours has and see if HA is un happy with that. Once you have that working you can build up to the other. I mostly use json with the rest sensor and mqtt so have not needed to use command line.
I normally dont have a wrapper
I did get stuck with an odd one, but ended up writing a small php script on one of my servers to pull the data and clean it up for HA
But the majority of the command line sensors that grab json data don't have multiple dicts
I was thinking about doing that a moment ago but I figured JQ should be able to do that for me
Wrap it all in a dict with a key at the front like {items:[]}
But... can't find a simple solution for that either
I would be tempted to see if JQ can split out one dict or write a bash script to grab the data, tweak it and then return that to HA.
The doc https://www.baeldung.com/linux/jq-command-json suggest you can pull out specifc sections
So if you have 3 entries just use 3 sensors one for each.
I don't, it gets more complicated than that
I have to individually pull lat/long and then write automations to convert that data in a device tracker after the fact
If you only want the lat/long. JQ looks like it can pull that data directly out of the received json, then you can might be able to use a template sensor of the device tracker?
I would certainly look at using a script to extract and reformat what you need from the json and then pass that in perhaps even via MQTT. https://www.home-assistant.io/integrations/device_tracker.mqtt/
I might
I assume you have seen this one https://community.home-assistant.io/t/apple-airtag/557862/4
Hmm no, I hadn't seen that