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

[NG] JSON Server not fully implemented?

Discussion in 'Archive' started by jjuk, 6 July 2020.

Thread Status:
Not open for further replies.
  1. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    I started playing with the Json server yesterday with a view to use it to remote control Hyperion.
    https://docs.hyperion-project.org/en/json/
    Is the Json Server complete and working? I'm getting unexpected results:

    Code:
    {
        "command": "color",
        "color": [
            0,
            255,
            255
        ],
        "duration": 12000,
        "priority": 20,
        "origin": "My Fancy App"
    }
    
    returns:
    
    {
      "command": "color",
      "success": true,
      "tan": 0
    }
    
    but no color is set. Nothing appears to happen.
    
    Code:
    {
        "command" : "authorize",
        "subcommand" : "tokenRequired"
    }
    
    returns:
    
    {
      "command": "",
      "error": "Command not implemented",
      "success": false,
      "tan": 0
    }
    
    Code:
    {
        "command": "componentstate",
        "componentstate": {
            "component": "LEDDEVICE",
            "state": false
        }
    }
    
    returns:
    
    {
      "command": "componentstate",
      "success": true,
      "tan": 0
    }
    
    But the LEDs do not turn off.
    They can be turned off from the "Remote Control" section
    of the web gui successfully.
    
     
  2. Paulchen-Panther

    Paulchen-Panther Moderator Staff Member Developer

    Messages:
    908
    Hardware:
    RPi1/Zero, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Yes, absolute.
    hyperion-remote also uses the JSON API.
    Which tool/prog do you use?
     
  3. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
  4. Paulchen-Panther

    Paulchen-Panther Moderator Staff Member Developer

    Messages:
    908
    Hardware:
    RPi1/Zero, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Multiple hyperion instances?
    What system does insomnia run on? In another network? Via the internet?
     
  5. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    I have "First LED Hardware Instance" and "TV Test 1".

    I have "Selected instance: TV Test 1" in the GUI.

    I'm new to hyperion, so i'm not 100% if that's what you mean by "hyperion instance".

    Sorry for being noob ;) We all start somewhere, some time!
     
  6. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    Ok, i sent this:
    Code:
    {
      "command" : "instance",
      "subcommand" : "switchTo",
      "instance" : 1
    }
    and now it is responding to my commands. :) The docs state that the "It's possible that an instance will stop while you are connected". What does this mean? Why would an instance stop?
     
  7. Paulchen-Panther

    Paulchen-Panther Moderator Staff Member Developer

    Messages:
    908
    Hardware:
    RPi1/Zero, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    It should only be expressed when an instance is stopped (crashed, stopped by another location, etc.) and you try to switch to it, instance 0 is automatically selected.
     
  8. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    Ok, thanks!
     
  9. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    I've created a token and enabled "Local API Authentication", but i am able to control Hyperion via json without passing the token.

    The need for authentication seems to be ignored?
     
  10. Paulchen-Panther

    Paulchen-Panther Moderator Staff Member Developer

    Messages:
    908
    Hardware:
    RPi1/Zero, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Just tested. I can not confirm. If you do feel like this, please create a new issue on GitHub.
     
  11. jjuk

    jjuk New Member

    Messages:
    8
    Hardware:
    RPi1/Zero, RPi3
    I'm still working on this.

    I'm trying to send TCP packets to port 19444 (the port defined in Network settings for JSON Server).

    I can send led device on/off commands to the default instance (instance 0), but cannot control instance 1.

    Select instance 0 in the webgui, then go to dashboard and watch "LED Device"

    Send:
    {"command": "componentstate","componentstate": {"component": "LEDDEVICE", "state": true}}\n

    {"command": "componentstate","componentstate": {"component": "LEDDEVICE", "state": false}}\n

    The LED device turns on then off.

    Now select instance 1 in the GUI and send:

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

    {"command": "componentstate","componentstate": {"component": "LEDDEVICE", "state": true}}\n

    {"command": "componentstate","componentstate": {"component": "LEDDEVICE", "state": false}}\n

    The instance doesn't turn on/off.

    This process works for POST to http://192.168.1.95:8090/json-rpc, but doesn't seem to work for TCP.

    I'm using "packet Sender" to send TCP: https://packetsender.com/#Download
     
    Last edited: 8 July 2020
  12. Sousanator

    Sousanator New Member

    Messages:
    8
    Hardware:
    RPi3
    It's either order or timing. Try sending it all at once. This is what works for me:
    {"command":"instance","instance":1,"subcommand":"switchTo"}\n{"command":"componentstate","componentstate":{"component":"LEDDEVICE","state":true}}\n
     
Thread Status:
Not open for further replies.