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

2,975 vistas
Ir al primer mensaje no leído

Tommy Sharp

no leída,
17 feb 2015, 2:34:03 a.m.17/2/2015
para 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

no leída,
17 feb 2015, 2:41:45 a.m.17/2/2015
para 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

no leída,
17 feb 2015, 3:24:20 a.m.17/2/2015
para ope...@googlegroups.com

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

specifically the curl examples.

Ben Jones

no leída,
17 feb 2015, 3:25:05 a.m.17/2/2015
para ope...@googlegroups.com
Have you seen the WIKI page about the REST API?

Christoph Wempe

no leída,
17 feb 2015, 4:03:57 a.m.17/2/2015
para 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

no leída,
17 feb 2015, 2:03:18 p.m.17/2/2015
para
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

no leída,
23 feb 2015, 7:08:40 p.m.23/2/2015
para 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)


Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos