JSON API Request Status

  • Hi all, I'm controlling my Hyperion server using JSON commands via Node-Red, and need to have 'feedback' from Hyperion so that I can change the color of the button.

    As an example I have a button on my Node-Red dashboard with a dark red background colour that when pressed sends a Json Rpc command that sets the LEDs to Red, I then need the button colour to change to a bright red when the response from the Hyperion server reports back that the LED's are Red.

    If the status is anything other than 'Red' then I want the button colour to change back to dark red.

    I've tried looking at the json response sent back from Hyperion after I send a command, but can't see how I can filter that to only relate to a specific request, as I only see a response such as:

    Code
    {    "command": "clear",    "instance": 0,    "success": true,    "tan": 0
    }



    Thanks in advance for any help.

  • Quote

    but can't see how I can filter that to only relate to a specific request, as I only see a response such as:

    Use the "tan" when sending the request and you can match the response via the given tan.

    In addition, you might want to look at using the API via a Websocket/TcpSocket connection.

    There you can subscribe to updates happening in Hyperion.

    Assume one changes the color to green via the browser then updates would be published and you can change your button too.
    That would be a more reactive solution design...

  • Thank you Lord-Grey this is very helpful, I think just adding a tan argument into my requests to be able to identify/filter responses should be enough, as I can use node red to match the contents of the response payload and control the button colours.

    So if any response contains a tan value of something other than the one designated for that button then a command will be sent to turn the button 'off' and change the colour back to dim red.

    The idea is to only allow control of the Hyperion server via Node-Red, and not use the browser interface at all.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!