This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

[how to] Domoticz to Homey (using httplink)

Because I'm not yet ready to leave my current system, also because of historical data .. but I do want to utilize Homey as much as possible,  I created some scripts to update data/switches in Homey, because I want this to be accurate I opted for a push model,
which I recently tweaked to use the httplink instead , I'll describe the whole thinngjust in case someone was looking for (part of) the information. 

Initially I created a separate folder in the domoticz/scripts/ folder named homey   
and  I added a script to each switch, for example the front door..   
script:///home/pi/domoticz/scripts/homey/setvar.sh  frontdoor open
The script is : 
#!/bin/bash

BEARER="Bearer <YOUR BEARER KEY HERE>" # notice the space between Bearer and the key 
HOMEY_IP="192.168.1.XX"
URL="http://${HOMEY_IP}/api/app/net.i-dev.betterlogic/${1}/${2}"

curl -H "Content-Type: application/json" -H "Authorization: ${BEARER}" -X PUT ${URL}
Do not forget to mark it as executable 
sudo chmod +x ./setvar.sh 

Since I do not want to create and maintain this for all my switches I tried to use the httplink, 
this was unfortunately not working properly in domoticz, but is now fixed in one of the newer builds   
Next I could not get it to work from domoticz to homey>betterlogic directly, i'm getting errors related to variables not being found .. 

Anyway the setvars script worked so i decided to utilize that;
First install a webserver, if you have one already use that, for the Pi I used the lightweight Lighttpd, instructions here :
https://raspberrytips.nl/lighttpd-php-webserver-raspberry-pi/

Drop the following code in a php file and save in the www directory (alternatively in the www/html/ directory)  
(do not forget to update the location of the .sh script )  
<?php
$variable = $_GET['variable'] ;
$val = trim($_GET['val']) ;
$cmd = shell_exec ( '/home/pi/domoticz/scripts/homey/setvar.sh '.$variable.' '. $val.' ' );
echo "200" ;
?>
Now go to Domoticz >Setup>More options>Data push>HTTP 
and add the URL to the proper field under the "General Settings", i'm pretty sure you can use the localhost instead of the IP address,
but i have the IP address of the domoticz server..   
http://192.168.1.XX/httplink.php?variable=%V&amp;val=%v


Next create the "better logic variables" e.g. the ones that are in your homey, it does not matter if you create them before or afterwards 
This is done under the "Edit Link" header on the left, make sure you include or exclude the unit based on the Better Logic variable type!  
Note, personally I try not to use any spaces, but this might work (not tested) 



Comments

  • PauluzPauluz Member
    edited May 2018
    Next 5 comments where created from comments split from: Advanced HTTP Get Request for Homey (::1).
    Eternity said:
    Pauluz said:
    It has the option to create a generic widget that will execute a HTTP request, and that is exactly what I need, but I need some help..
    Not sure if I understand you correctly
    I dont know what to include in the http request to run a flow externaly, so I can run it from within Imperihome or Domoticz. I hope you understand what I mean. Later I will try to explain with more detail with examples and screenshots.
  • In my case, the received http GET can trigger anything, including flows.
  • PauluzPauluz Member
    edited May 2018
    Eternity Thank you very very much!!!!  That was the missing link:

    You’re the best! B)
  • PauluzPauluz Member
    @Eternity If it is not too much trouble, would you be so kind to mention what kind of devices you work with, e.g. Xiaomi, or other Zigbee devices, z-wave, etc. That are compatible with Domoticz.

    I would be very grateful. B)
    Thanks in advance.

    Have a nice one.
  • EternityEternity Member
    edited May 2018
    @Pauluz
    Great that I could be of help.

    Hardware is a mixture of
    - Z-wave => mainly Fibaro relays, Aeotec multi sensors and NEO Powerplugs
     - ZigBee => mainly Xiaomi doorsensors
    - Philips Hue strips/bulbs.
    - and some KlikAanKlikUit that I  hope to replace soon.

    These used to be controlled by Domoticz running on my Synology NAS via a Z-wave usb stick (KaKu was controlled separately).

    I still use Domoticz, but it only logs electricity and gas usage from my  'slimme meter' via a P1 cable into the Synology NAS.
Sign In or Register to comment.