Wireless Tag Custom URL Calling

Hi,

I’ve had some wireless tag sensors for several years and have been using them to provide email notifications based on movement. I’ve recently put one in my fridge and would like to configure the URL calling feature to post the sensor temperature to an item in OH. However, I can’t seem to get it to work.

Executing the following command on the command line updates the item:

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "12" "http://192.168.0.20:8080/rest/items/wirelessTagFridge"

The item in OH is a string item.

I’ve logged into the wireless tag manager at my.wirelesstag.net and set it up like this:

With the further HTTP option set to:

No joy though. I must be missing something. I can’t see any errors in openhab.log.

Any ideas?

I don’t know the WirelessTags, but according to their Website you might only need to send {2} as data.


(source: http://wirelesstag.net/webapp.html)

image

That doesn’t seem to work either.

I’ve turned on debug logging for org.eclipse.smarthome.io.rest.core and I can see other items being updated via the REST API but nothing from the wireless tag manager. If I run that curl command I mentioned in the first post then I see this in the log:

26-Jul-2019 21:47:11.819 [DEBUG] [.smarthome.io.rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/wirelessTagFridge' with value '666'.

Very strange. It’s not like the tag manager can’t access the OH server, they’re on the same LAN.

What happens if you send a wrong command via curl?
Just to check if you would get an error message in that case.

Depending on your skills, I would use tcpdump/Wireshark to check if any package is sent from the WirelessTag or is getting to the openhab server.

Thanks for your suggestions.

Executing the following from the shell:

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "666" "http://192.168.0.20:8080/rest/items/asdasdf"

returns:

{"error":{"message":"HTTP 404 Not Found","http-code":404,"exception":{"class":"javax.ws.rs.WebApplicationException","message":"HTTP 404 Not Found","localized-message":"HTTP 404 Not Found"}}}

and the following appears in the debug log for org.eclipse.smarthome.io.rest.core:

26-Jul-2019 22:10:40.444 [INFO ] [.smarthome.io.rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/asdasdf' for the unknown item 'asdasdf'.

I’ve found a calling URL log within the wireless tag manager which lists several entries like this:

07/26-21:02:07Z:Did URL Call from Tag Manager: PRIVMSG xyz :@192.168.0.20:8080/rest/items/wirelessTagFridge^POST|--header "Content-Type: text/plain" --header "Accept: application/json" -d "9.62836456298828"

It just looks like the URL call isn’t reaching the OH server, very strange.

I finally got an answer from the support team:

"The URL calling supports only application/json or application/x-www-form-urlencoded content type (determined by if the content starts with { )
Please configure your URL end point so it accepts either format. "

I’ve tried simply setting the content to “{2}” before and it still didn’t work. I’m not sure what to try next.

After a bit more back and forth with support I got this reply:

"The equivalent thing the tag manager is doing is
curl -X POST --header “Content-Type: application/x-www-form-urlencoded” -d “-1.40776121616364” “http://192.168.0.20:8080/rest/items/wirelessTagFridge
Try that and see if your server accept it. "

Running that curl command on the command line gives:

{"error":{"message":"HTTP 415 Unsupported Media Type","http-code":415,"exception":{"class":"javax.ws.rs.NotSupportedException","message":"HTTP 415 Unsupported Media Type","localized-message":"HTTP 415 Unsupported Media Type"}}}

I wish they’d have just told me this in the first place!

After some more googling it looks like I need to implement a reverse proxy to rewrite “application/x-www-form-urlencoded” to “Content-Type: text/plain”.