Read url

Hi,

I want to read an url and put the result into a variable in habpanel. Ex:

Url want to read: http://xxx.xxx.x.x:xxxx/data_request?id=variableget&Variable=Status (that will display 1 or 0)

I then want to use that variable to decide if I want to run
url 2 (http://192.168.1.8:3480/data_request?id=action&output_format=xml&action=SetTarget&newTargetValue=0)
or
url 3 (http://192.168.1.8:3480/data_request?id=action&output_format=xml&action=SetTarget&newTargetValue=1) with and ng-if and a ng-click

Is that possible?

Thanks

/Claus

There is a guide here, on how to monitor WAN ip, and notify when that changes.
I think you can use that.

Try to search for it :slight_smile:

/Robert

That sounds very much like a Switch in OpenHAB terms, with Exec binding inputs and outputs

I would use the http binding to read the first url. You don’t say under what circumstances you want to read it. Do you poll it periodically, read it base on some event?

In a rule I would then use the http actions to call the urls based on the state of the item that got the first url.

Hi Rick,

I want to poll it periodically. So if I can put it in a item.

I have tried with HTTP binding, but I could not get that to work.

Do you have an example on how I could do it?

Thanks

/Claus

In what way do it not work?

http.cfg:

weatherConditions.url=http://api.wunderground.com/api/e9f3c8d72995d1cd/conditions/q/pws:KCOMONUM13.json
weatherConditions.updateInterval=30000

items:

String vWeather_Conditions "Current Conditions [%s]"
    { http="<[weatherConditions:420000:JSONPATH($.current_observation.weather)]" }

In your case, you probably can use default in place of the JSONPATH transform.

How is the default?

This is the url I want to read:

http://xxx.xxx.xxx.xxx:xxxxx/data_request?id=variableget&DeviceNum=xxx&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status

Sorry for all the questions, but I’m a new bee :slight_smile:

/Claus

I dont get the status. Here is how I done it:

http.cfg:
Status.url=http://xxx.xxx.xxx.xxx:xxxx/data_request?id=variableget&DeviceNum=xx&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status
Status.updateInterval=30000

Item:
String vStatus “Current Conditions [%s]” { sendHttpGetRequest(http://xxx.xxx.xxx.xxx:xxxx/data_request?id=variableget&DeviceNum=xx&serviceId=urn:micasaverde-com:serviceId:DoorLock1&Variable=Status) }

Sitemap:
Text item=vStatus

The abobe settings display only a - instead of the the current status

Is that correct?

Please go through the beginners tutorial and read the HTTP binding readme.

Your item makes no sense. Look at the example Item I posted above. The stuff that goes between the {} should look like that. What you have belongs in a rule, not an item definition.