Http binding things file for shinobi

Hello,
I want to create a things file for the shinobi API. my json output from shinobi api request is:

[
   {
      "mid": "NAME",
      "ke": "KEY",
      "name": "RPI Cam Flur",
      "shto": "[]",
      "shfr": "[]",
      "details": "",
      "type": "mjpeg",
      "ext": "mp4",
      "protocol": "http",
      "host": "192.168.1.202",
      "path": "/stream.mjpg",
      "port": 9000,
      "fps": 1,
      "mode": "start",
      "width": 640,
      "height": 480,
      "currentlyWatching": 0,
      "currentCpuUsage": 0,
      "status": "Watching",
      "streams": [
         "/dfas/mjpeg/5646dasfa/NAME"
      ],
      "streamsSortedByType": {
         "mjpeg": [
            "/df654safd/mjpeg/54s6adfas/NAME"
         ]
      }
   }
]

now i have created the following things file:

Thing http:url:shinobi_cam1 "RPi Cam Flur" [
        baseURL="http://192.168.1.100:PORT/APIKEY/monitor/GROUPKEY/MONID",
        refresh=60,
        timeout=3000,
        bufferSize=2048,
        delay=1,
        authMode="BASIC",
        stateMethod="GET",
        commandMethod="GET",
        ignoreSSLErrors=true] {
   Channels:
      Type string : Mode        [ commandExtension="/%2$s", stateTransformation="JSONPATH:$.mode", mode="READWRITE" ]           //stop = "Disabled", start = "Wa
      Type string : Status        [ stateTransformation="JSONPATH:$.status", mode="READONLY" ]
      Type switch : Host        [ stateTransformation="JSONPATH:$.host", mode="READONLY" ]
}

the first error is that i get “HANDLER_CONFIGURATION_PENDING” on the OH3 Things UI. i know the meaning, but where is my mistake?

my second question is: is my “stateTransformation” right according to the json response i pasted above?

I can’t offer anything on the first but I can on the second. The JSON returned here is an array with one element so your expression needs to be something like: $.[0].mode. I don’t do much with JSONPATH so it could be $[0].mode or some other variation. The key take away though is you need to get the first element of the array first before trying to get at the mode element.

thanks!
the correct thing is as follows:

Thing http:url:shinobi_cam1 "RPi Cam Flur" [
        baseURL="http://192.168.1.100:4564/API/monitor/KEY/NAME",
        refresh=60,
        timeout=3000,
        bufferSize=2048,
        delay=1,
        authMode="BASIC",
        stateMethod="GET",
        commandMethod="GET",
        ignoreSSLErrors=true] {
   Channels:
      Type string : mode "Modus"       [ commandExtension="%2$s", stateTransformation="JSONPATH:$.[0].mode", mode="READWRITE" ]         //stop = "Disabled", start = "Watch-Only", rec$
      Type string : status "Status"    [ stateTransformation="JSONPATH:$.[0].status", mode="READONLY" ]
      Type string : host "Host"        [ stateTransformation="JSONPATH:$.[0].host", mode="READONLY" ]
}

the thing is now online!

I searched for how to integrate shinobi with openhab and I would like to add to create a simply copy paste starting solution:

  1. create a thing for each camera in shinobi. Use the item definition in the post before as the base

  2. create a .items file (e. g. shinobi.items) or add to an eisting one. By adding “shinobi_cameraName” in front of the individual channels of the camera (e. g. “mode” of the camera “HWR”), it is easy to get the right channels in case you have more than one camera

    String shinobi_HWR_Mode “Modus” (Shinobi) {channel=“http:url:shinobi_cam_hwr:mode”}
    String shinobi_HWR_Status “Status” (Shinobi) {channel=“http:url:shinobi_cam_hwr:status”}
    String shinobi_HWR_Host “Host” (Shinobi) {channel=“http:url:shinobi_cam_hwr:host”}

  3. create a sitemap, e. g. “shinobi.sitemap” or add to an existing one. The “mappings” entries correspond to how the camera mode is changed in shinobi (start, stop, record) and what is shown in the sitemap as the text.

    sitemap shinobi label=“Shinobi” {
    Frame label=“HWR” {
    Switch item=shinobi_HWR_Mode label=“HWR Camera” mappings=[“start”=“start”,“stop”=“stop”,“record”=“record”]
    Default item=shinobi_HWR_Status label=“Status [%s]”
    }
    }