1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED JSON-RPC Request

Discussion in 'Software Support' started by Djal, 17 February 2021.

Tags:
  1. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    Hello All,

    I need your help for a JSON request. I need to know the status of the components "ALL". (image attached)

    I don't manage to do it, i'm stuck with all the array.

    I manage to start/stop an instance with : curl -i -X POST 'http://IP_ADRESS:8090/json-rpc' --data '{"command":"componentstate","componentstate":{"component":"ALL","state":true}}'

    If someone could help.

    Thxs
     

    Attached Files:

  2. Paulchen-Panther

    Paulchen-Panther Moderator Staff Member Developer

    Messages:
    925
    Hardware:
    RPi1/Zero, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
  3. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    Thxs for answering. But in the post it is not specified how to check the status, but only how to start/Stop an instance, what i already manage to do.
    I'd like to check the status
     
  4. davieboy

    davieboy Active Member

    Messages:
    242
    Hardware:
    RPi1/Zero, RPi2, RPi3, RPi4
    heres a curl example for checking the status of the Platform Capture
    Code:
    curl -sS -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"command": "serverinfo"}' http://192.168.1.30:8090/json-rpc | jq '.info.components[] | select(.name == "GRABBER") | .enabled'
    
    I was unable to curl that ALL info and sort it in a way I wanted without having to manually curl each item, ended up using python to get the JSON status of ALL and store them in a dict as they are defined by Hyperion along with their current state.

    Quite sure there are other JSON-rpc examples in a few different threads that may be of use to you

    Good Luck :thumbsup:
     
    • Like Like x 2
  5. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    Thx you. I think this is the right direction to do the request. I still got an error as shown in the image joined

    what is the "| jq" for? (pipe + Json Query ?)
     

    Attached Files:

    Last edited: 17 February 2021
  6. davieboy

    davieboy Active Member

    Messages:
    242
    Hardware:
    RPi1/Zero, RPi2, RPi3, RPi4
    it parses the JSON from the command line, you get that result and error because you do not have it installed try the code below to install it then rerun the command, you should see either true or false depending on the component you select

    Code:
    sudo apt-get install jq
    
     
  7. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    arf... do not have the apt-get command with libreelec :(
     
  8. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    oh..... sorry i run it from a different system, will try ;)
     
  9. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    Ohhhh man, it works like a charm..... thxs for all ;)
     
  10. davieboy

    davieboy Active Member

    Messages:
    242
    Hardware:
    RPi1/Zero, RPi2, RPi3, RPi4
    yeah that's why i went down the Python route with LibreELEC was easier to pull in the Python Libraries than get jq installed and easier to extend.
     
  11. Djal

    Djal New Member

    Messages:
    7
    Hardware:
    RPi3
    I request from another full debian server. So after jq installed, it works. thx again