Hi. Migrating to OH3.2 from 2.4 and are totally lost in a simple (embarrassing) issue…
I am trying to send simple GET commands to an Arduino triggered by switches
Requests I am trying to create is:
http://10.0.1.222?OUT6=true/false
http://10.0.1.222?OUT7=true/false
http://10.0.1.222?OUT8=true/false
So how should I configurate? Should I use string switch or contact as Item?
Just confused right now
this is my starting point:
UID: http:url:arduinopool
label: Pool Arduino
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://10.0.1.222
delay: 0
stateMethod: GET
refresh: 30
commandMethod: GET
contentType: text/html
timeout: 3000
bufferSize: 2048
channels:
id: Channel6
channelTypeUID: http:string
label: Channel6
description: “”
configuration: {}
id: Channel7
channelTypeUID: http:string
label: Channel7
description: “”
configuration: {}
id: Channel8
channelTypeUID: http:string
label: Channel8
description: “”
configuration: {}
Any help is appreciated !
Best Regs
Taisto
Try a switch channel like
- id: Channel6
channelTypeUID: http:switch
label: Channel6 label
description: ""
configuration:
onValue: "true"
offValue: "false"
stateExtension: ?OUT6=
Hi and tnx for answer.
Added as you suggested and linked a switch Item.
In my log i can see:
[TRACE] [nding.http.internal.HttpThingHandler] - Sending to ‘http://10.0.1.222?OUT8= ’ : Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.43.v20210629}, Content = {null}
And Arduino is responding 200
but the OUT8=true/false value is missing in the URL.
What have I missed?
UID: http:url:arduinopool
label: Arduino Pool
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://10.0.1.222
delay: 0
stateMethod: GET
refresh: 300
commandMethod: GET
contentType: text/html
timeout: 3000
bufferSize: 2048
channels:
id: Channel6
channelTypeUID: http:switch
label: LabelChannel6
description: “”
configuration:
onValue: “true”
mode: READWRITE
offValue: “false”
stateExtension: ?OUT6=
id: Channel7
channelTypeUID: http:switch
label: LabelChannel7
description: “”
configuration:
onValue: “true”
mode: READWRITE
offValue: “false”
stateExtension: ?URL7=
id: Channel8
channelTypeUID: http:switch
label: LabelChannel8
description: “”
configuration:
onValue: “true”
mode: READWRITE
offValue: “false”
stateExtension: ?OUT8=
rossko57
(Rossko57)
February 23, 2022, 10:40am
4
taisto_onnela:
refresh: 300
Remember this is a bi-directional binding. It will automatically send to a URL and try to use the returned data from the remote service to update your channels/Items
You don’t want that, if you want to send HTTP to remote service in response to commands to your Items/channels.
So set refresh to zero, ignore stuff to do with statexxx, and look at commandxxx parameters like commandExtension
rossko57:
So set refresh to zero
Huh, is this valid? If so it’s a feature that could do with documenting on the binding page.
At the moment I’d assumed command-only HTTP Things were defined if all their Channel mode
was set to WRITEONLY
rossko57
(Rossko57)
February 23, 2022, 1:09pm
6
Setting any channels to write only does not stop the Thing read polling at the requested intervals - you might have a mix of channels, for example.
Right, but that’s why I mentioned
i.e. no mix.
OK tried stateExtension and commandExtension “?OUT8=” with same result.
‘http://10.0.1.222?OUT8= ’ here I want to add true or false
So what is the trick to get the value from switch Item into the url?
Can not find anything about that in docs.
regs
Taisto
It’s there, at the bottom of the docs .
Combine that with an onValue: true
and offValue: false
1 Like
rossko57
(Rossko57)
February 23, 2022, 2:30pm
10
Off topic
hafniumzinc:
I.e. no mix
Don’t care, you are allowed to have a mix is the point. So channel read/write settings do not control the HTTP Thing to read-poll or not. That’s the refresh parameter’s job.
So it’s a fact that refresh: 0
means disabling polling?
Oliver2
(Oliver)
February 23, 2022, 2:30pm
12
just to broaden your options: you could create a rule and pass over the value to your get request. It is a one-liner
sendHttpGetRequest("http://10.0.1.222/?OUT8=" + variable)
no ‘0’ is not allowed, but I think ‘’ blank stops…
Cool Oliver will try, but I prefer doing it in channel (if possible)
/taisto
I have done that from start …hmm frustrating
My Code
UID: http:url:arduinopool
label: Arduino Pool
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://10.0.1.222
delay: 0
stateMethod: GET
refresh: 300
commandMethod: GET
contentType: text/html
timeout: 3000
bufferSize: 2048
channels:
id: Channel8
channelTypeUID: http:switch
label: LabelChannel8
description: “”
configuration:
onValue: “true”
offValue: “false”
commandExtension: /?OUT8=
Right, except this snippet still doesn’t show the correct use of the URL formatter linked previously.
You need to use %2$
at the end of your commandExtension
system
(system)
Closed
April 6, 2022, 11:58am
17
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.