I am working HTTP binding to control(on/off) light from http link. I have added switch item in openhab and able to control light successfully. But if I put same link (127.0.0.1/cgi-bin/test.cgi?on) in browser, I am getting some success message like "Status OFF\ON". I want the same status to displayed on Openhab web page. How can I do this?
Can anyone help me.
If you want to show on your sitemap the results from calling the URL you will need to use two Items and a rule to process the call to the URL.
Create a Switch Item to trigger the call. Don’t bind this Item to anything.
Create a String Item to store the result from the URL call.
Create a rule that triggers when the Switch Item is triggered. This rule will call the URL using the sendHttpGetRequest(url) action and store the string that comes back in the String Item.
Put both items on your sitemap.
If you want to just get some sort of feedback that your request was successful (or more importantly failed), instead of storing the result of the sendHttpGet action call in a String Item, check it within your rule and generate an alert with the status. If you are using my.openhab you can use the sendNotification action. Otherwise use your alerting mechanism of choice (e.g. Notify My Android, email, Twitter, etc).
Can you give example using rule and items. I am confused.
Switch MyLight "My Light"
String MyLightResult "Last call to My Light returned [%s]"
rule "Trigger light"
Item MyLight received command
val result = sendHttpGetRequest("url")
You may have to do some parsing and manipulation of result to extract just the string you want. If the call to postUpdate doesn’t work, change it to
Is there anyway I can create a rule to refresh particular link for every specific time(1 hour or 1 min).
if possible please help me
sure - include a cron timer into your rule:
//when its 1900
Time cron “0 0 19 * * ?”
examples could be found here: