Command Line switch & Curl : How to pretty print response?

Hi all,

This is probably an easy one for many of you guys, but I’m not skilled enough to figure it out :slight_smile:

I’m trying to move my HomeAssistant setup to, but have problems with my command line switches for my B&O products.

In my existing and working setup I have a Command_state that looks something like this (from memory):
curl -X GET ‘’ -H ‘content-type: application/json’ | python -mjson | grep ‘inUse’

The response I get from that command (without the mjson and grep command) is a quite long json string, but the main thing is that the word ‘inUse’ is only there when the TV is on, and therefor I can use it for status.

Is there any way I can do the same in hassio?


Try use jq instead of python -mjson. It would be something like:
curl -X GET ‘’ -H ‘content-type: application/json’ | jq ‘.inUse’

Or have a look on this post to try fix the use of python on the command line switch:

Hope it hepls

Thanks! I’ll give it a try tonight and post the result :slight_smile:

Couldn’t wait :wink: I’ve tried jq now and it works like a charm - and it’s easier to understand for me, so it’s a win-win :stuck_out_tongue:

The final command ended up being: curl -X GET -H “Content-Type: application/json” “http://192.16” | jq “.primaryExperience.source.inUse”

which just gives me true back.
Thanks again :slight_smile:

1 Like