HTTP-Binding und YI Kamera (YI-Hack)

No worries, here’s the English translation of your text:


I’d like to control my YI Camera with YI-Hack via the HTTP binding in openHAB 5. Controlling the camera directly through the browser’s address bar works perfectly.

Camera ON/OFF: http://username:password@192.168.179.108/cgi-bin/camera_settings.sh?switch_on="yes/no"
Camera Status: http://username:password@192.168.179.29/cgi-bin/get_configs.sh?conf=camera

The output is:

{
"SWITCH_ON":"yes",
"SAVE_VIDEO_ON_MOTION":"yes",
"MOTION_DETECTION":"no",
"SENSITIVITY":"medium",
"AI_HUMAN_DETECTION":"no",
"AI_VEHICLE_DETECTION":"no",
"AI_ANIMAL_DETECTION":"no",
"FACE_DETECTION":"no",
"MOTION_TRACKING":"no",
"SOUND_DETECTION":"no",
"SOUND_SENSITIVITY":"80",
"LED":"no",
"ROTATE":"no",
"IR":"yes",
"CRUISE":"no",
"HOMEVER":"12.1.37.3_202411121025",
"NULL":"NULL"
}

I created an HTTP thing via the GUI and added a Switch channel. The code for it looks like this:

UID: http:url:575d11272c
label: Living Room Camera
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.179.29/cgi-bin/
  password: xxx
  delay: 30
  stateMethod: GET
  refresh: 5
  commandMethod: POST
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
  username: xxx
channels:
  - id: last-failure
    channelTypeUID: http:request-date-time
    label: Last Failure
    configuration: {}
  - id: last-success
    channelTypeUID: http:request-date-time
    label: Last Success
    configuration: {}
  - id: ON_OFF_LivingRoomCamera
    channelTypeUID: http:switch
    label: ON_OFF_LivingRoomCamera
    description: ""
    configuration:
      onValue: yes
      offValue: no
      stateExtension: get_configs.sh?conf=camera
      commandExtension: camera_settings.sh?switch_on=
      stateTransformation:
        - JSONPATH:$.SWITCH_ON

However, when I toggle the switch, nothing happens. The debug log doesn’t show anything helpful for me either.


Does anyone have an idea?

ich möchte meine YI Kamera mit YI-Hack gerne über des HTTP-Binding in Openhab 5 steuern. Die Steuerung der Kamera direkt über die Adresszeile des Browsers klappt einwandfrei.
Kamera AN/AUS: http://username:passwort@192.168.179.108/cgi-bin/camera_settings.sh?switch_on=“yes/no“
Kamera Status: http://username:passort@192.168.179.29/cgi-bin/get_configs.sh?conf=camera
Ausgabe ist:

{
"SWITCH_ON":"yes",
"SAVE_VIDEO_ON_MOTION":"yes",
"MOTION_DETECTION":"no",
"SENSITIVITY":"medium",
"AI_HUMAN_DETECTION":"no",
"AI_VEHICLE_DETECTION":"no",
"AI_ANIMAL_DETECTION":"no",
"FACE_DETECTION":"no",
"MOTION_TRACKING":"no",
"SOUND_DETECTION":"no",
"SOUND_SENSITIVITY":"80",
"LED":"no",
"ROTATE":"no",
"IR":"yes",
"CRUISE":"no",
"HOMEVER":"12.1.37.3_202411121025",
"NULL":"NULL"
}

Ich habe über die GUI ein http-Thing erstellt und einen Switch-Channel hinzugefügt. Der Code dazu sieht so aus.

UID: http:url:575d11272c
label: Wohnzimmerkamera
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.179.29/cgi-bin/
  password: xxx
  delay: 30
  stateMethod: GET
  refresh: 5
  commandMethod: POST
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
  username: xxx
channels:
  - id: last-failure
    channelTypeUID: http:request-date-time
    label: Last Failure
    configuration: {}
  - id: last-success
    channelTypeUID: http:request-date-time
    label: Last Success
    configuration: {}
  - id: ON_OFF_Wohnzimmerkamera
    channelTypeUID: http:switch
    label: ON_OFF_Wohnzimmerkamera
    description: ""
    configuration:
      onValue: yes
      offValue: no
      stateExtension: get_configs.sh?conf=camera
      commandExtension: camera_settings.sh?switch_on=
      stateTransformation:
        - JSONPATH:$.SWITCH_ON

Wenn ich den Schalter aber betätige passiert nichts. Das debug-Log ergibt für mich auch nichts.
Hat jemand eine Idee?

If these work through the browser it means that both commands are HTTP GET requests. You’ve configured your Thing to use an HTTP POST for commands.

Furthermore, you need to include the command from the Item in the commandExtension.

commandExtension: camera_settings.sh?switch_on=%2$

See HTTP - Bindings | openHAB.

Thanks, that was (almost) the solution.

UID: http:url:ee64898c0f
label: Küchenkamera
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.179.42/cgi-bin/
  password: xxx
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  contentType: application/json
  timeout: 3000
  bufferSize: 2048
  username: xxx
channels:
  - id: last-failure
    channelTypeUID: http:request-date-time
    label: Last Failure
    configuration: {}
  - id: last-success
    channelTypeUID: http:request-date-time
    label: Last Success
    configuration: {}
  - id: ON_OFF_Kuechenkamera
    channelTypeUID: http:switch
    label: ON_OFF_Küchenkamera
    configuration:
      onValue: yes
      offValue: no
      stateExtension: get_configs.sh?conf=camera
      commandExtension: camera_settings.sh?switch_on=%2$s
      stateTransformation:
        - JSONPATH:$.SWITCH_ON

Copy and paste error. It’s why I always provide the link to the docs. :wink: Glad you figured it out and were able to get past my mistake.

1 Like