<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Domotics on OiePoie!</title>
    <link>https://www.oiepoie.nl/tags/domotics/</link>
    <description>Recent content in Domotics on OiePoie!</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 23 Aug 2014 20:05:09 +0200</lastBuildDate><atom:link href="https://www.oiepoie.nl/tags/domotics/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Philips Hue Lights into Domoticz and IFTTT functionality</title>
      <link>https://www.oiepoie.nl/2014/08/23/philips-hue-domoticz/</link>
      <pubDate>Sat, 23 Aug 2014 20:05:09 +0200</pubDate>
      
      <guid>https://www.oiepoie.nl/2014/08/23/philips-hue-domoticz/</guid>
      <description>&lt;h2&gt;&lt;a class=&#34;extlink&#34; href=&#34;http://www.domoticz.com&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;Domoticz&#34;&gt;Domoticz&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt; is a great open source domotica solution. &lt;a href=&#34;http://www.domoticz.com&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34;&gt;&lt;img alt=&#34;Domoticz&#34; class=&#34;alignright size-medium wp-image-138&#34; height=&#34;119&#34; sizes=&#34;(max-width: 300px) 85vw, 300px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.31.30-300x119.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.31.30-300x119.png 300w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.31.30-500x199.png 500w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.31.30.png 961w&#34; width=&#34;300&#34;/&gt;&lt;/a&gt;&lt;br/&gt;
If you have a &lt;a class=&#34;extlink&#34; href=&#34;http://www.raspberrypi.org/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;Raspberry Pi&#34;&gt;Raspberry Pi&lt;/a&gt; lying around, it’s just a matter of &lt;a class=&#34;extlink&#34; href=&#34;http://sourceforge.net/projects/domoticz/files/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;download domoticz&#34;&gt;downloading the SD-Card image&lt;/a&gt; from the site and there you go!&lt;br/&gt;
If you don’t have a Pi, buy one, it’s only thirty-some euro’s which is next to nothing for the versatility you get. Oh, and if you buy one, buy the Raspberry Pi B+ version since it has 4 USB ports and a 40 pin I/O header and it uses less energy.&lt;/p&gt;
&lt;p&gt;Allthough Domoticz supports a lot of hardware out of the box (check the &lt;a class=&#34;extlink&#34; href=&#34;http://www.domoticz.com/wiki/Main_Page&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;domoticz wiki&#34;&gt;Wiki&lt;/a&gt;), the fabulous Philips Hue lights are not among them, but it’s dead easy to integrate these using the standard functionality available.&lt;br/&gt;
So how is it done?&lt;/p&gt;
&lt;h6&gt;Step 1&lt;/h6&gt;
&lt;p&gt;The Hue Lights come with a &lt;strong&gt;Hue Bridge&lt;/strong&gt;&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/hue-bridge.jpg&#34;&gt;&lt;img alt=&#34;hue-bridge&#34; class=&#34;alignright border=&#34; height=&#34;150&#34; size-thumbnail=&#34;&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/hue-bridge-150x150.jpg&#34; width=&#34;150&#34; wp-image-110=&#34;&#34;/&gt;&lt;/a&gt;&lt;br/&gt;
which interfaces between your (wireless) network and the Zigbee protocol that the lights use. You need to find the ip-adres of the bridge, you can do that by looking into your router for the connected devices. The MAC address of your bridge is shown inside the Smartphone App (mine starts with &lt;code&gt;00:17:88&lt;/code&gt;, yours probably does too). While you’re in the router, make sure that the bridge gets a static IP address, that means coupling the bridge MAC address with a fixed IP address. Why? Because we’ll be using that IP address in our scripts and if it changes the scripts wont work 🙁&lt;br/&gt;
And, since you are here, be sure to do the same for the IP address of your Raspberry Pi!&lt;/p&gt;
&lt;p&gt;Ok, if you found the bridge IP address and you made it fixed, it’s now time to add an user to the bridge so we can use that to control the lights. This can be done by following the tutorial from Philips about the &lt;a class=&#34;extlink&#34; href=&#34;http://www.developers.meethue.com/documentation/getting-started&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;Philips Hue Bridge API&#34;&gt;Bridge API&lt;/a&gt; (API stands for Application Programming Interface).&lt;br/&gt;
Basically you fire up a browser (on the same network as the bridge lives) and go to:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;http://&amp;lt;bridge ip address&amp;gt;/debug/clip.html&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;From there you can use the API GUI to execute the command to create a new user:&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.43.17.png&#34;&gt;&lt;img alt=&#34;Hue API create new user&#34; class=&#34;alignright size-medium wp-image-145&#34; height=&#34;272&#34; sizes=&#34;(max-width: 300px) 85vw, 300px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.43.17-300x272.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.43.17-300x272.png 300w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.43.17-330x300.png 330w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.43.17.png 550w&#34; width=&#34;300&#34;/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and as a matter of security you have to press the link button on the Bridge before the command is executed.&lt;br/&gt;
When all went well you should now be able to control the lights through the CLIP API Debugger webpage.&lt;/p&gt;
&lt;p&gt;And also when you connect to your Pi from the command-line (ssh to the IP addres with user: pi and password: raspberry) you can set the lights with this command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;curl -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true}&#39; http://ip-address/api/newdeveloper/lights/1/state&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;which turns the light on, and&lt;/p&gt;
&lt;p&gt;&lt;code&gt;curl -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://ip-address/api/newdeveloper/lights/1/state&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;which turns it off again.&lt;br/&gt;
If you get an error message about curl not being available, you might need to install it first with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo apt-get install curl&lt;/code&gt;&lt;br/&gt;
&lt;/p&gt;
&lt;h6&gt;Step 2&lt;/h6&gt;
&lt;p&gt;This is about integrating Hue into Domoticz. After you fired up your Pi with the Domoticz SD-Card you should be able to access the web-interface on port 8080 of your P1: http://ip-address-of-Pi:8080&lt;br/&gt;
Goto &lt;b&gt;Setup -&amp;gt; Hardware&lt;/b&gt; and add a &lt;b&gt;Dummy&lt;/b&gt; device as shown in the screenshot. &lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.34.42.png&#34;&gt;&lt;img alt=&#34;Domoticz add Dummy Device&#34; class=&#34;alignright size-medium wp-image-119&#34; height=&#34;185&#34; sizes=&#34;(max-width: 300px) 85vw, 300px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.34.42-300x185.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.34.42-300x185.png 300w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.34.42-485x300.png 485w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.34.42.png 789w&#34; width=&#34;300&#34;/&gt;&lt;/a&gt;, give it a name, and keep the state on &lt;b&gt;enabled&lt;/b&gt;&lt;br/&gt;
Next go to the &lt;b&gt;Switches&lt;/b&gt; TAB and click the button on the left to add a &lt;b&gt;Manual Light/Switch&lt;/b&gt;&lt;br/&gt;
Select the name from the virtual hardware device you just added and give this new switch some meaningful name. &lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.41.31.png&#34;&gt;&lt;img alt=&#34;Screen Shot 2014-08-23 at 16.41.31&#34; class=&#34;alignleft size-medium wp-image-121&#34; height=&#34;300&#34; sizes=&#34;(max-width: 279px) 85vw, 279px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.41.31-279x300.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.41.31-279x300.png 279w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.41.31.png 453w&#34; width=&#34;279&#34;/&gt;&lt;/a&gt;You can keep the type on X10, since that doesn’t matter; and also don’t worry about changing the X10 channel settings.&lt;br/&gt;
The new Light/Switch should now show up in the Domoticz Switches TAB.&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h6&gt;Step 3&lt;/h6&gt;
&lt;p&gt;Now are we going to add the functionality to the new switch. Click the &lt;b&gt;Edit&lt;/b&gt; button on the switch and that will give you a window like this:&lt;br/&gt;
&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14.png&#34;&gt;&lt;img alt=&#34;Domoticz edit Light/Switch&#34; class=&#34;aligncenter size-large wp-image-128&#34; height=&#34;298&#34; sizes=&#34;(max-width: 584px) 85vw, 584px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14-1024x524.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14-1024x524.png 1024w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14-300x153.png 300w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14-500x255.png 500w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-16.49.14.png 1235w&#34; width=&#34;584&#34;/&gt;&lt;/a&gt;&lt;br/&gt;
Now for the &lt;b&gt;On Action&lt;/b&gt; we are going to use a very simple script; ssh into your Pi with the pi user (password = raspberry) and change to the scripts directory:&lt;br/&gt;
&lt;code&gt;cd domoticz/scripts/&lt;/code&gt;&lt;br/&gt;
Copy the contents of the script below and don’t forget to fill in the right IP address of the Hue Bridge.&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
#!/bin/bash&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true}&#39; http://your-bridge-IP-Address/api/newdeveloper/lights/1/state&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
Save the &lt;b&gt;On&lt;/b&gt; script:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
cat &amp;gt; hue_light_1_on.sh&lt;br/&gt;
#!/bin/bash&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true}&#39; http://your-bridge-IP-Address/api/newdeveloper/lights/1/state&lt;br/&gt;
CTRL-D&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
And repeat this for the &lt;b&gt;Off&lt;/b&gt; script.&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
cat &amp;gt; hue_light_1_off.sh&lt;br/&gt;
#!/bin/bash&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://your-bridge-IP-Address/api/newdeveloper/lights/1/state&lt;br/&gt;
CTRL-D&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
Make both scripts executable:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
chmod 0755 hue_light*&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
And now fill in the reference to both scripts in de Domoticz webpage:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
ON:  script:///home/pi/domoticz/scripts/hue_light_1_on.sh&lt;br/&gt;
OFF: script:///home/pi/domoticz/scripts/hue_light_1_off.sh&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
Save is and test the switch by clicking on the lights. If it doesn’t do what you expect try running the scripts from within the ssh session, turning the light on:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
./hue_light_1_on.sh&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
and off:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
./hue_light_1_off.sh&lt;br/&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h6&gt;Step 4&lt;/h6&gt;
&lt;p&gt;Apart from making a switch for a single Hue Light it’s just as easy to make a scene switch where you control a couple off lights and their brightness and/or color. It’s just a matter of combining the various commands into that on and off script.&lt;br/&gt;
For instance:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
#! /bin/bash&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true,&#34;bri&#34;:203}&#39; http://IP-Address/api/newdeveloper/lights/1/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true,&#34;bri&#34;:205}&#39; http://IP-Address/api/newdeveloper/lights/2/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true,&#34;bri&#34;:91}&#39; http://IP-Address/api/newdeveloper/lights/3/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true,&#34;bri&#34;:136}&#39; http://IP-Address/api/newdeveloper/lights/4/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true,&#34;bri&#34;:255}&#39; http://IP-Address/api/newdeveloper/lights/5/state ;&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
and the accompanying off script:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
#! /bin/bash&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://IP-Address/api/newdeveloper/lights/1/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://IP-Address/api/newdeveloper/lights/2/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://IP-Address/api/newdeveloper/lights/3/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://IP-Address/api/newdeveloper/lights/4/state ; \&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:false}&#39; http://IP-Address/api/newdeveloper/lights/5/state ;&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
Setting the Hue Lights Color is controlled this way:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X PUT --data &#39;{&#34;on&#34;:true, &#34;sat&#34;:255, &#34;bri&#34;:255,&#34;hue&#34;:10000}&#39; http://IP-Address/api/newdeveloper/lights/1/state&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
An easy way to set the right scene is to use your smartphone app until you are satisfied with the result and than request the parameters of all the lights to see how the are configured:&lt;br/&gt;
&lt;code&gt;&lt;br/&gt;
curl -s -H &#34;Accept: application/json&#34; -X GET http://IP-Address/api/newdeveloper/lights&lt;br/&gt;
&lt;/code&gt;&lt;br/&gt;
Or request this information via de Bridge CLIP API Debugger page we used earlier.&lt;/p&gt;
&lt;h6&gt;Step 5&lt;/h6&gt;
&lt;p&gt;So far it’s pretty amazing how simple you can create you own domotica system for an apple and an egg 😉&lt;br/&gt;
But the really &lt;b&gt;(REALLY!)&lt;/b&gt; big advantage is yet to come!&lt;br/&gt;
Domoticz has a Lego like logic system built in that’s called Blocky. It’s more ore less comparable with the functionality that you can get from &lt;a class=&#34;extlink&#34; href=&#34;http://ifttt.com&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; title=&#34;If This Than That&#34;&gt;IFTTT&lt;/a&gt; (If This Than That) but now fully within your own domotica system.&lt;br/&gt;
By using that system you can tell you Hue lights to activate 10 minutes after SunSet and go off at 11 pm. That means that you never have to adjust a timer in your live again because it’s getting dark earlier or later.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.20.29.png&#34;&gt;&lt;img alt=&#34;Domoticz Blocky&#34; class=&#34;aligncenter size-full wp-image-133&#34; height=&#34;356&#34; sizes=&#34;(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.20.29.png&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.20.29.png 714w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.20.29-300x149.png 300w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Screen-Shot-2014-08-23-at-17.20.29-500x249.png 500w&#34; width=&#34;714&#34;/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h6&gt;Step 6&lt;/h6&gt;
&lt;p&gt;Relax and have a Brewski 😉&lt;a href=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Grolsch_small.jpg&#34;&gt;&lt;img alt=&#34;Grolsch&#34; class=&#34;alignright size-full wp-image-160&#34; height=&#34;217&#34; sizes=&#34;(max-width: 320px) 85vw, 320px&#34; src=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Grolsch_small.jpg&#34; srcset=&#34;https://www.oiepoie.nl/wp-content/uploads/2014/08/Grolsch_small.jpg 320w, https://www.oiepoie.nl/wp-content/uploads/2014/08/Grolsch_small-300x203.jpg 300w&#34; width=&#34;320&#34;/&gt;&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
