[SOLVED] Device states updates: Fibaro HC2 and openhab (and maybe ha-bridge) - without z-wave stick


I am running openhab2.3 on a raspberry pi3 B+. I have got a fibaro HC2. Both work fine separetly.
Now I connected them using the ha-bridge for raspberry which emulates a hue bridge. Even this works fine.

The only thing missing is the device state update in openhab if I use a wall switch or fibaro itself.
The reason is, that the ha-bridge does not support this response automatically.

In my opinion there are 3 opportunities which I would like to discuss with you or where I need some help:
1) Direct communication between fibaro and openhab
2) Communication between fibaro and ha-bridge
3) Buying a z-wave stick

1.a) Is there a possibility to connect Fibaro and openhab without using z-wave? Maybe with HTTP oder REST API. Fibaro supports both, but I guess, there will be no device update as well, right?
1.b) When somebody uses a wall switch I could start a scene on fibaro to change the state on openhab automatically. The openhab REST API says that the code looks like this:

curl -X PUT --header “Content-Type: text/plain” --header “Accept: application/json” -d “on” “http://myIP:8080/rest/items/myName/state

But I don´t know how to send a curl-command on fibaro (which uses LUA coding). Maybe you can help here or know how to change the curl in a HTTP PUT which I can use in Fibaro as well.

2) Same as 1b but sending a command to the hA-bridge. The command is:

GET http://host:port/api//lights//bridgeupdatestate

However I didnt get it running yet. If you think, this is a good solution I would spend more time on it trying.
Here is the documentation: https://github.com/bwssytems/ha-bridge#hue-rest-api-usage

3) Yes. I guess this would be the easy way:-) But without using a z-wave stick I can still use my unsoldered raspberry. (USB and GPIO are missing; USB is broken as well). Thats why I would prefer the workaround from 1) or 2).
Even if I would by a z-wave stick, I would keep my fibaro HC2 because I have already got to many scenes running in LUA.

Any hint or help would be great.

Thank you.

One more Idee.
I have got a apache webserver running on my pi and know how to start php-scripts from my fibaro HC2.
I just tried to start myscript.php from my fibaro HC2. Unfortunately with no luck.
Maybe you might have a look at:

<?PHP exec ("curl -X PUT --header “Content-Type: text/plain” --header “Accept: application/json” -d “ON” “http://myIP:8080/rest/items/myName/state”"); ?>

Thank you.

seems like I got it on my own. Method 4, the php script, works fine.
If somebody uses a wall switch, my fibaro hc2 starts a scene, which starts a php-script on my raspberry which sets the new status on openhab.
It sounds a bit complicated, but I guess it is not much more work than genereating the .items-files.
The delay is really low.

If somebody tries to imitate. The php code for turning the state “ON” is (sorry I dont know how to break lines):

<?PHP $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://yourIP:8080/rest/items/yourName/state"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "ON"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); $headers = array(); $headers[] = "Content-Type: text/plain"; $headers[] = "Accept: application/json"; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); ?>

I used a converter to generate the code:

After you have got the script, you have to install curl support for php:

sudo apt-get install php5-curl

and restart the apache:

sudo /etc/init.d/apache2 restart