HTTP Binding timeout handler

Hello,
i’m using http binding for control my power strips. here are a config example which i’m using:

UID: http:url:PowerStrip3
label: PowerStrip3
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.0.3/?cmd=511
  delay: 0
  stateMethod: GET
  refresh: 5
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: PowerStrip_3_Socket_1_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_1_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[0]
  - id: PowerStrip_3_Socket_2_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_2_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[1]
  - id: PowerStrip_3_Socket_3_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_3_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[2]
  - id: PowerStrip_3_Socket_4_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_4_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[3]
  - id: PowerStrip_3_Socket_5_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_5_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[4]
  - id: PowerStrip_3_Socket_6_Status
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_6_Status
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.switch[5]
  - id: PowerStrip_3_Socket_1_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_1_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[0]
  - id: PowerStrip_3_Socket_2_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_2_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[1]
  - id: PowerStrip_3_Socket_3_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_3_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[2]
  - id: PowerStrip_3_Socket_4_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_4_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[4]
  - id: PowerStrip_3_Socket_5_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_5_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[4]
  - id: PowerStrip_3_Socket_6_Watt_Org
    channelTypeUID: http:number
    label: PowerStrip_3_Socket_6_Watt_Org
    description: null
    configuration:
      mode: READONLY
      stateTransformation: JSONPATH:$.data.watt[5]

Sometimes this powerstrip don’t react on requests and it will showing up an error in openhab logs like this:

2023-10-03 19:25:16.133 [WARN ] [p.internal.http.HttpResponseListener] - Requesting ‘http://192.168.0.3/?cmd=511’ (method=‘GET’, content=‘null’) failed: java.util.concurrent.TimeoutException: Total timeout 3000 ms elapsed

Is there an option to handle this timeout? I want to use the the request result as an item

It’s the third option on the Thing.

?? Do u mean the timeout setting in seconds? I‘m looking for a way to handle the timeout result or the result of the http request.

Oh, you can change how long it takes to timeout.

But if it times out all you get is the error in the log. There is no separate event you can catch to drive the state of an Item or trigger a rule. Either it works and you get a String to process and populate the Channels or you get nothing.

Hm that means i only can get the timestamp of a successful request and if there are no updates after the defined interval, there must be a request error or timeout

There are a method to monitor the error log instead?

Great, thanks!
i will check out both ways

An alternative is to not use http binding, and write your own http request code yourself in your preferred scripting language.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.