Rest API : Simple url to turn a switch on/off?

3,065 views
Skip to first unread message

Tommy Sharp

unread,
Feb 17, 2015, 2:34:03 AM2/17/15
to ope...@googlegroups.com
One thing I'm struggling on with OpenHAB is the availability of some of the more simple documentation....

What I'm trying to achieve today is have my old home automation system (Domoticz) call a simple URL that turns a basic switch in OpenHAB to ON or OFF. I've seen some stuff about specifying HTTP headers and all sorts of stuff, what I really need is just a simple URL that I can even type into a desktop browser that when accessed will turn the switch in OpenHAB on or off....

This has to be possible I'm sure, I guess I just don't have enough experience yet....

This is possible in Domoticz and and example URL would be....

Thanks in advance...

Tommy Sharp

unread,
Feb 17, 2015, 2:41:45 AM2/17/15
to ope...@googlegroups.com
As an example..... So far I can use this URL on my server and it will return some detail about the switch telling me it's off.... How do I set it to ON?


Holger Hees

unread,
Feb 17, 2015, 3:24:20 AM2/17/15
to ope...@googlegroups.com

take a look at https://github.com/openhab/openhab/wiki/Samples-REST

specifically the curl examples.

Ben Jones

unread,
Feb 17, 2015, 3:25:05 AM2/17/15
to ope...@googlegroups.com
Have you seen the WIKI page about the REST API?

Christoph Wempe

unread,
Feb 17, 2015, 4:03:57 AM2/17/15
to ope...@googlegroups.com
Try this:
http://localhost:8080/CMD?Light_GF_Corridor_Ceiling=ON

https://github.com/openhab/openhab/wiki/Samples-Tricks#use-url-to-manipulate-items

Tommy Sharp

unread,
Feb 17, 2015, 2:03:18 PM2/17/15
to
Thanks Christoph, that worked a treat! Do you know the right command to use for setting contacts? I've tried OPEN and CLOSED, ON and OFF, 1 and 0 but OpenHAB keeps saying "Unknown Command"...

If I query the rest items I get the following..... Do I need to initialise contacts somehow on startup?

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<item>
     <type>ContactItem</type>
     <name>Contact_B_GarageDoor1</name>
     <state>Uninitialized</state>
     <link>http://localhost:8080/rest/items/Contact_B_GarageDoor1</link>
</item>

This is what I'm using to try set the contact state...

Tommy Sharp

unread,
Feb 23, 2015, 7:08:40 PM2/23/15
to ope...@googlegroups.com
I'm still struggling to update "Contact" items with this.... Anyone got any ideas why this wouldn't work?

http://localhost:8080/CMD?Contact_B_GarageDoor1=OPEN

Received unknown command 'OPEN' for item 'Contact_B_GarageDoor1'

Seems to work fine for lights and switches, but not contacts...

I tested further by creating a switch and then a rule that uses that switch to manipulate my contact. In the rule, this command works perfectly and updates the contact state.

sendCommand(Contact_B_GarageDoor1, OPEN)


Reply all
Reply to author
Forward
0 new messages