HTTP binding - openHAB 3 version

LOL. Thanks for pointing that out. yes this is the correct solution :slight_smile:
also did content-type as ā€œapplication/jsonā€

1 Like

Links in 1st post do not work.

If you are using OH3, the binding is now included in the snapshots

Hi,
Iā€™m currently testing the HTTP binding on OH 3 (Build 2017). But the site iā€™m running the test against doesnā€™t seem to be using any authentication except for a ā€œAPIā€ Key they call ā€œAppKeyā€.

Please note that i have changed the AppKey, and address in this post. This is just for showing an example.
Iā€™m getting this current error:

[WARN ] [p.internal.http.HttpResponseListener] - Requesting ā€˜https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?gatenavn=Address&gatekode=1006&husnr=150ā€™ (method=ā€˜GETā€™, content=ā€˜nullā€™) failed: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

I have setup the thiing with this Header: Kommunenr=0000&RenovasjonAppKey=11-22-33-44&OS=Android&Connection=Keep-Alive&Accept-Encoding=gzip

I can get it to work with a curl like this:
curl -H ā€œKommunenr: 0000ā€ -H ā€œRenovasjonAppKey: 11-22-33-44ā€ -H ā€œOS: Androidā€ -H ā€œConnection: Keep-Aliveā€ -H ā€œAccept-Encoding: gzipā€ -X GET ā€œhttps:/komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?gatenavn=Address&gatekode=1006&husnr=150ā€

Does anyone have any suggestion on what could be wrong?

1 Like

Please enable TRACE or DEBUG logging and show what exactly is sent. Did you configure authentication? Did you really set the headers as above? Thatā€™ll probably not work. Add a new entry for each header key-value-pair.

Hi,

im using one of the last 2.5.8 version of the binding.
I want to use a switch channel, but im having problems with that.
The switch item is not showing the right state. Only UNDEFā€¦
Switching on or off is working fine.

The trace log looks like this:

2020-11-21 13:44:19.828 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending to ā€˜https://openhab.home/waschmaschine/sp2101w_waschmaschine_status.phpā€™: Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.20.v20190813}, Content = {null}
220-11-21 13:44:20.943 [TRACE] [p.internal.http.HttpResponseListener] - Received from ā€˜https://openhab.home/waschmaschine/sp2101w_waschmaschine_status.phpā€™: Code = {200}, Headers = {Date: Sat, 21 Nov 2020 12:44:19 GMT, Server: Apache/2.4.18 (Ubuntu), Content-Length: 2, Content-Type: text/html; charset=UTF-8}, Content = {ON}*

I looks like the response is right, but the switch is not updating to this state:

2020-11-21 13:46:39.043 [ome.event.ItemCommandEvent] - Item ā€˜EdimaxWaschmaschinePowerSwitchā€™ received command ON
2020-11-21 13:46:39.045 [nt.ItemStatePredictedEvent] - EdimaxWaschmaschinePowerSwitch predicted to become ON
2020-11-21 13:46:39.054 [vent.ItemStateChangedEvent] - EdimaxWaschmaschinePowerSwitch changed from UNDEF to ON
2020-11-21 13:46:51.033 [vent.ItemStateChangedEvent] - EdimaxWaschmaschinePowerSwitch changed from ON to UNDEF

Am I doing something wrong?

Hi,
I thing you need to use a transformation map
you used your command values as Onvalue and Offvalue while you should use for your state value.
Therefore you should use a transformation map

So you can use:
OnValue:ā€œONā€ OffValue: ā€œOFFā€
Command Trasformation : ā€œMAP:yourmap.mapā€

and in yourmap.map file
on=sp2101w_waschmachine_an.php
off=sp2101w_waschmachine_aus.php
or viceversa (I always forgot the right order)
Letā€™s try
Regards
Lorenzo

Yes. See my post #76 for a complete example how to use transformations.

Hi mstormi and foxejoe,

I ve read the whole thread :wink:

But the response for the state is still on or off like you can see in the trance log, so I thought i dont need a transformā€¦

Or maybe i understand you wrong :smiley:

But nevertheless I will try it :+1:

Hi, this is not the problemā€¦ the problem is the command :wink:
In your configuration you set as status the command and as command you send the status therefore your command works but your status doesnā€™t.
You have to set the status on OnValue and Offvalue NOT the command !!
Read the example as mstormi wrote that explain better my point above.
Regards
Lorenzo

Hey Guys,

I got it!
It is working now :slight_smile:

But I do not really understand it!
But maybe the documentation at this point is not specific enoughā€¦

Next Question, maye also a documentation thing, but is it possible to call a url and send a xml after connection to get a status?
Background: Im ussing Edimax smarplugs and they work with xml playload. To get or set a state you have to connect to the plug by url and send a xml payload to it. After that, yout get the actual state or change the stateā€¦

<?xml version="1.0" encoding="UTF8"?>
<SMARTPLUG id="edimax">
	<CMD id="get">
		<Device.System.Power.State></Device.System.Power.State>
	</CMD>
</SMARTPLUG>

This is one king of the xml.

Thanks for your help :slight_smile:

Hi all
Iā€™m acutally struggeling with the new binding on OH3. To make that clear : I have no clue what iā€™m doing here, iā€™m doing my best to understand these programming topics but its a far way unitl i really understand the basics. Mainly iā€™m trying and following examples i find in the wide web.
My actual problem is my PV inverter which i need to bring back into OH. WIth the old HTTP binding i had the following setup which worked perfect on my Kostal Piko BA8.

Under Services i had http.config file with the following path :
kostalCache1.url=http://192.168.3.90/api/dxs.json?dxsEntries=33556736&dxsEntries=83888128&dxsEntries=16780032&dxsEntries=33555202&dxsEntries=33555201&dxsEntries=33555203&dxsEntries=33555458&dxsEntries=33555457&dxsEntries=33555459&dxsEntries=33556226&dxsEntries=33556229&dxsEntries=33556238&dxsEntries=33556230&dxsEntries=33556228&dxsEntries=33556227&dxsEntries=83886336&dxsEntries=83886592&dxsEntries=83886848&dxsEntries=83887106&dxsEntries=83887362&dxsEntries=83887618&dxsEntries=67109120&dxsEntries=67110400&dxsEntries=67110656&dxsEntries=67110144

THe item files lokked like that :
//Home - Zusammenfassung
Number Kostal_0 ā€œDC Eingang gesamt [%d W]ā€ { http="<[kostalCache1:30000:JSONPATH($.dxsEntries[0].value)]" , autoupdate=ā€œfalseā€ }
Number Kostal_1 ā€œEigenverbrauch [%d W]ā€ { http="<[kostalCache1:30000:JSONPATH($.dxsEntries[1].value)]" , autoupdate=ā€œfalseā€ }
Number Kostal_2 ā€œBetriebsstatus [MAP(kostal_status.map):%s]ā€ { http="<[kostalCache1:30000:JSONPATH($.dxsEntries[2].value)]" , autoupdate=ā€œfalseā€ }

With the new binding i have included the following thing :

The channels look like that ;

Trace shows me that values arrive
2020-11-23 12:29:58.463 [TRACE] [p.internal.http.HttpResponseListener] - Received from ā€˜http://192.168.3.90/api/dxs.json?dxsEntries=33555458ā€™: Code = {200}, Headers = {Content-Type: text/plain, Expires: Sun, 02 Jan 2000 11:11:11 GMT}, Content = {{ā€œdxsEntriesā€:[{ā€œdxsIdā€:33555458,ā€œvalueā€:492.231293}],ā€œsessionā€:{ā€œsessionIdā€:0,ā€œroleIdā€:0},ā€œstatusā€:{ā€œcodeā€:0}}}
2020-11-23 12:29:58.471 [TRACE] [p.internal.http.HttpResponseListener] - Received from ā€˜http://192.168.3.90/api/dxs.json?dxsEntries=33555459ā€™: Code = {200}, Headers = {Content-Type: text/plain, Expires: Sun, 02 Jan 2000 11:11:11 GMT}, Content = {{ā€œdxsEntriesā€:[{ā€œdxsIdā€:33555459,ā€œvalueā€:0.000000}],ā€œsessionā€:{ā€œsessionIdā€:0,ā€œroleIdā€:0},ā€œstatusā€:{ā€œcodeā€:0}}}
2020-11-23 12:29:58.472 [TRACE] [p.internal.http.HttpResponseListener] - Received from ā€˜http://192.168.3.90/api/dxs.json?dxsEntries=83886848ā€™: Code = {200}, Headers = {Content-Type: text/plain, Expires: Sun, 02 Jan 2000 11:11:11 GMT}, Content = {{ā€œdxsEntriesā€:[{ā€œdxsIdā€:83886848,ā€œvalueā€:3933.464355}],ā€œsessionā€:{ā€œsessionIdā€:0,ā€œroleIdā€:0},ā€œstatusā€:{ā€œcodeā€:0}}}
2020-11-23 12:29:58.495 [TRACE] [p.internal.http.HttpResponseListener] - Received from ā€˜http://192.168.3.90/api/dxs.json?dxsEntries=33555457ā€™: Code = {200}, Headers = {Content-Type: text/plain, Expires: Sun, 02 Jan 2000 11:11:11 GMT}, Content = {{ā€œdxsEntriesā€:[{ā€œdxsIdā€:33555457,ā€œvalueā€:0.000000}],ā€œsessionā€:{ā€œsessionIdā€:0,ā€œroleIdā€:0},ā€œstatusā€:{ā€œcodeā€:0}}}

Then i link a new Item to the channel


But i always get either NULL or UNDEF as output of the item
image

I assume i need to enter something somewhere to transfer the value to the item but i have no clue what i have to enter and whereā€¦

If i use JSONpath on the link between Channel and item iā€™m asked for a JSONPath Expression. My assumption is that i need to enter something there but what ? :wink:

Most probably thats something very stupid and easy if you know what you doā€¦

Hi all,

Iā€™ve been using the http binding in OH2 for quite a while now and just started migrating to OH3.
Iā€™m using Milestone2 release and struggle to find it.
Does ā€œ(edited; binding included in distribution)ā€ mean, it should be there already?
I canā€™t find a .jar to download neither and am confused :slight_smile:

Can someone enlighten me?
Iā€™d be happy, if I could start to migrate my HTTP items and help testingā€¦

ā€œIf you are using OH3, the binding is now included in the snapshotsā€

=> might be you need a snapshot release instead of the milestone.

Thanks @Matze_R,
Is there still a download available?
Iā€™m using the docker install and would prefer to use the releases.
This is a ā€œsemi-prodā€ environment :wink:
And Iā€™d be happy, if I donā€™t have to upgrade too oftenā€¦

Thanks!

I just updated from milestone2 to M3 and itā€™s now available.
Thanks for your efforts!
Iā€™ll give it a try now and provide feedback, if I find anything unusual :slight_smile:

Thank you Jan.

Changing from defining headers on one line with ā€œ&ā€ between, to one per line did the trick. I guess i misread the old http readme, where you apparently included the header in the URL: https://www.openhab.org/addons/bindings/http1/#http-headers

1 Like

Hi,

Iā€™ve got the binding working and enabled a channel that is successfully reading the state of my switches.
Unfortunately I struggle with getting the command part working.
The HTTP page displays the status of a couple of switches like:

Switch A1 is: 1
Switch A2 is: 0
...

To control a switch a link like http://<ip>/rcOn=1 or http://<ip>/rcOff=1 where 1 is the ID of the switch can be used.
To read the state I use the following State Transformation REGEX:.*?A1 is: (.*?) .* and Open/Close Value as 1 / 0.
This works fine and the state of the Channel/Item follows the switch state correctly.

For the command extension I would probably need something like:

/rcXXX=1

Can anyone help to find the correct substitution for XXX?
I assume that I would need to replace the transformed on/off value of 1 with On and 0 with Off somehow, but am unable to find out how :slight_smile:

Thanks a lot!

Hi,
when status and commands are completly different as in your case, I use a map transformation file for the command as described above on post #76

Hi @Foxejoe,
I saw this, but was unsure on what I need to map exactly.
When I tried I first didnā€™t see any HTTP calls when I flipped the switch.
Turned out, I added the Channel with type Contactā€¦
Anyway, after a few more corrections here and there itā€™s finally workingā€¦

Thanks!