OH3 Http Binding Switch ESP01

Hello Forum,
I programmed a ESP01 with Arduino IDE (no Tamota, connected to my WLAN) to blink in a Lighthouse Sequence .
Now I want to turn the Sequence on and off whit a OH3 Http Binding Switch.
When I manually type 192.168.0.23/whvon in a Browser the Seqence starts and /whvoff it stops.

OH is running on a Raspberry 3.

Here is the Code:

UID: http:url:acd697c3a2
label: Lighthouse
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  refresh: 30
  baseURL: 192.168.0.23/
  commandMethod: GET
  contentType: text/html
channels:
  - id: Whv
    channelTypeUID: http:switch
    label: Whv
    description: ""
    configuration:
      onValue: whvon
      offValue: whvoff
      commandExtension: "%2$s"

I read this Post (Http binding OH3, how to create a switch channel in UI?), but unfortunately it won’t work.

Can you please halp me? What is wrong?

Kind regards and stay healthy, Helmut

Of you Set the Loglevel to TRACE you can see what is sent and what the answer is. Please post that.

Hi Jan,
I tried to set the Loglevel to TRACE with this command in a Terminal:
sudo log:set TRACE org.openhab.binding.http
It said that the command was not found. Writing mistake?
From the “normal log” in Openhab I found this:

2021-04-05 08:21:21.389 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘LskTest_Whv’ received command OFF

2021-04-05 08:21:21.404 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘LskTest_Whv’ predicted to become OFF

2021-04-05 08:21:21.413 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘LskTest_Whv’ changed from ON to OFF

2021-04-05 08:22:09.405 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘LskTest_Whv’ received command ON

2021-04-05 08:22:09.410 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘LskTest_Whv’ predicted to become ON

2021-04-05 08:22:09.414 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘LskTest_Whv’ changed from OFF to ON

2021-04-05 08:23:00.621 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for ‘192.168.0.23/’ failed: Invalid URI host: null (authority: null)

2021-04-05 08:23:08.700 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘localhost’. Next attempt in 60000ms

2021-04-05 08:23:08.708 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘localhost’ with clientid 4d603307-ef57-466b-8538-cb6ddbb35d1e

2021-04-05 08:24:30.629 [WARN ] [ttp.internal.http.RefreshingUrlCache] - Creating request for ‘192.168.0.23/’ failed: Invalid URI host: null (authority: null)

Hmmm…it seems that OH sends the On and Off, but not in /whvon and /whv off? Why does the System start a Mqtt Broker when I’m on http?
I try to switch to TRACE, but wanted to report this to you first.

Kind regards, Helmut

I’m pretty sure you need:

baseURL: http://192.168.0.23/

Hi,
partial solution with http://192.168.0.23 :slight_smile:
I can turn it on and off but after 14 sek off the Sequence starts running again whitout that I do anything. Seems that by changing from OFF to UNDEF it starts again.

2021-04-05 09:29:00.117 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘LskTest_Whv’ received command OFF

2021-04-05 09:29:00.123 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘LskTest_Whv’ predicted to become OFF

2021-04-05 09:29:00.130 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘LskTest_Whv’ changed from ON to OFF

2021-04-05 09:29:14.572 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘LskTest_Whv’ changed from OFF to UNDEF

How can I avoid switching from OFF to UNDEF?

Regards, Helmut

I’ve got it :slight_smile:
It switched to UNDEF after the Refresh time. Setting it to “Write only” made it work.

UID: http:url:fb220b417b
label: Lighthouse
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.0.23/
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048

channels:
  -id: WHV
    channelTypeUID: http:switch
    label: WHV
    description: ""
    configuration:
      mode: WRITEONLY
      onValue: whvon
      offValue: whvoff
      commandExtension: "%2$s"

Stay all healthy, Helmut

1 Like