Struggling with using the NG API

  • My setup:

    instance 0 - APA102 strips behind the tv

    instance 1 - nanoleaf

    instance 2 - nanoleaf panels

    USB capture device from Roku running plex.

    Everything works great.

    What I am trying to do is turn the leds on when media plays and off when media stops by using a plex webhook. I am catching the webhook, looking for the play uuid (so it only turns the lights on/off for that player) and the media.start and media.stop events.

    Every request call I make gives an error from hyperion. Python error:

    ConnectionError: ('Connection aborted.', BadStatusLine('{"command":"","error":"Errors during message parsing, please consult the Hyperion Log.","success":false,"tan":0}\n',))

    Error from hyperion log:

    2021-10-20T11:47:17.838Z [hyperiond JSONCLIENTCONNECTION] (ERROR) Failed to parse json data from JsonRpc@::ffff: Error: illegal value at Line: 0, Column: 1

    The curl version of the commands all work:

    curl -X POST -i '' --data '{"command":"componentstate","componentstate":{"component":"LEDDEVICE","state":false}}'

    curl -X POST -i '' --data '{"command" : "instance","subcommand" : "stopInstance","instance" : 1}'

    curl -X POST -i '' --data '{"command" : "instance","subcommand" : "stopInstance","instance" : 2}'

    curl -X POST -i '' --data '{"command":"componentstate","componentstate":{"component":"LEDDEVICE","state":true}}'

    curl -X POST -i '' --data '{"command" : "instance","subcommand" : "startInstance","instance" : 1}'

    curl -X POST -i '' --data '{"command" : "instance","subcommand" : "startInstance","instance" : 2}'

    Any clue why the python request isn't working the same way as the curl version?

    And as an aside, is there a better way to turn the leds on and off? Seems that instance 0 as the default behaves differently from instances 1 and 2. I would need to change the connected instance and then turn the LEDDEVICE off, but I can't figure out how to pass multiple commands, either. I would need to, in a single call

    {  "command" : "instance",  "subcommand" : "switchTo",  "instance" : 1 }

    Thanks in advance for any pointers.


    Got it! The http port 8090 worked better than the json-rpc port. This code works:

Participate now!

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