Http binding - openHAB 3 (solved)

Httpbinding with openHAB version: 3.0

I try to turn on/off the schedule of my shellys by OpenHab. Unfortunately, this is not possible via MQTT so I wanted to realize this by the use of the http binding. The schedule can be turned on/off by these two http addresses:
Schedule Off:
http://172.16.1.14/settings/roller/0?schedule=false

Schedule On:
http://172.16.1.14/settings/roller/0?schedule=true

The actual state can be get via JSON (JSONPATH:$.schedule) from the following adress:
http://172.16.1.14/settings/roller/0

httpThings Code:
UID: http:url:Rollo_Schedule
label: HTTP URL Thing
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://172.16.1.14
  refresh: 30
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
    id: Schedule
    channelTypeUID: http:switch
    label: Schedule
    description: ""
    configuration:
      onValue: "true"
      offValue: "false"
      stateExtension: /settings/roller/0
      commandExtension: /settings/roller/0?schedule=%2$s
      stateTransformation: JSONPATH:$.schedule

If I turn off the schedule manually I can activate it with openhab but it is not possible to switch it off.
Here a part of my log file (starts with a deactivated schedule):

2021-05-07 19:36:10.047 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Requesting refresh (retry=false) from 'http://172.16.1.14/settings/roller/0' with timeout 3000ms
2021-05-07 19:36:10.049 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending to 'http://172.16.1.14/settings/roller/0': Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.20.v20190813}, Content = {null}
2021-05-07 19:36:10.079 [TRACE] [p.internal.http.HttpResponseListener] - Received from 'http://172.16.1.14/settings/roller/0': Code = {200}, Headers = {Server: Mongoose/6.18, Connection: close, Content-Type: application/json, Content-Length: 549}, Content = {{"maxtime":20.00,"maxtime_open":20.00,"maxtime_close":20.00,"default_state":"stop","swap":false,"swap_inputs":false,"input_mode":"openclose","button_type":"toggle","btn_reverse":0,"state":"stop","power":0.00,"is_valid":true,"safety_switch":false,"schedule":false,"schedule_rules":["2100-0123456-close","0600-01234-open","0700-56-open"],"obstacle_mode":"disabled","obstacle_action":"stop","obstacle_power":200,"obstacle_delay":1,"safety_mode":"while_opening","safety_action":"stop","safety_allowed_on_trigger":"none","off_power":2,"positioning":true}}
2021-05-07 19:36:16.531 [TRACE] [nding.http.internal.HttpThingHandler] - Sending to 'http://172.16.1.14/settings/roller/0?schedule=true': Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.20.v20190813}, Content = {null}
2021-05-07 19:36:16.733 [TRACE] [p.internal.http.HttpResponseListener] - Received from 'http://172.16.1.14/settings/roller/0?schedule=true': Code = {200}, Headers = {Server: Mongoose/6.18, Connection: close, Content-Type: application/json, Content-Length: 548}, Content = {{"maxtime":20.00,"maxtime_open":20.00,"maxtime_close":20.00,"default_state":"stop","swap":false,"swap_inputs":false,"input_mode":"openclose","button_type":"toggle","btn_reverse":0,"state":"stop","power":0.00,"is_valid":true,"safety_switch":false,"schedule":true,"schedule_rules":["2100-0123456-close","0600-01234-open","0700-56-open"],"obstacle_mode":"disabled","obstacle_action":"stop","obstacle_power":200,"obstacle_delay":1,"safety_mode":"while_opening","safety_action":"stop","safety_allowed_on_trigger":"none","off_power":2,"positioning":true}}

I just see the command in case that I turn the switch on but nothing happens if I turn the switch off. I don´t even see a entry in my log file. After I turned the switch off and on again the last two lines repeated. If I swap the onValue and offValue I just can turn the schedule off but not on again.

Have you tried to use the Shelly binding.

Yes, but there is no Channel in the Shelly binding to turn the schedule on/off.

Shelly 2.5 in roller mode got the following channels:

Group Channel Type read-only Description
roller control Rollershutter r/w can be open (0%), stop, or close (100%); could also handle ON (open) and OFF (close)
rollerpos Dimmer r/w Roller position: 100%=open…0%=closed; gets updated when the roller stopped
input Switch yes ON: Input/Button is powered, see General Notes on Channels
state String yes Roller state: open/close/stop
stopReason String yes Last stop reasons: normal, safety_switch or obstacle
safety Switch yes Indicates status of the Safety Switch, ON=problem detected, powered off
event Trigger yes Roller event/trigger with payload ROLLER_OPEN / ROLLER_CLOSE / ROLLER_STOP
meter1 See group meter1 for Shelly 2
meter2 See group meter1 for Shelly 2

I wouldn’t be using in-actuator scheduling logic but always determine in openHAB. More control, and eliminates your problem, too.

I want to use the schedule function from the shelly so that in case of a problem from my openhab system the function is still given. Furthermore I hope that this will also help me with future problems

But then it’s a one time action, isn’t it so you can do it manually, once.

How are you doing that, does your Item actually get a command (visible in your events.log) ?
I ask because there was a UI bug for switch widgets.

2 Likes

Yes I could do it manually once but I got 8 of them. I want be able to turn the schedule easily on/off in case of public holiday, holiday, illness or something like that. Main thing is that I just want to understand how it works so that I can use this in the future for other tasks.

You are right. I just see a

received command ON
predicted to become ON

Than I have to start to read about this bug and how to fix it.

Got it:

Opened OpenHab → Settings → API Security and switched (show advanced)
Implicit user role for unauthenticated requests to ON

Now I see both commands and the schedule turns on and off correctly.