<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sofia Orlova on Medium]]></title>
        <description><![CDATA[Stories by Sofia Orlova on Medium]]></description>
        <link>https://medium.com/@sofiaorlova?source=rss-7bcbbde9a1ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tCcO7wxdiHdYcITn7hEAsQ.jpeg</url>
            <title>Stories by Sofia Orlova on Medium</title>
            <link>https://medium.com/@sofiaorlova?source=rss-7bcbbde9a1ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:59:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sofiaorlova/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to connect Shelly Switches with Philips Hue motion sensors.]]></title>
            <link>https://sofiaorlova.medium.com/how-to-connect-shelly-switches-with-philips-hue-motion-sensors-5fcdc4c1bfb8?source=rss-7bcbbde9a1ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fcdc4c1bfb8</guid>
            <category><![CDATA[motion-sensor]]></category>
            <category><![CDATA[philipps-hue]]></category>
            <category><![CDATA[curl]]></category>
            <category><![CDATA[shelly]]></category>
            <category><![CDATA[bash]]></category>
            <dc:creator><![CDATA[Sofia Orlova]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 22:45:11 GMT</pubDate>
            <atom:updated>2021-02-06T11:40:10.030Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*3CBC9VzpWuZyqHWo.jpg" /></figure><p>Hue offers a significant variation of chic lamp designs and hue plugs to connect as many devices as possible. Unfortunately, there is still no Hue way to connect all the lamps we want. In a previous <a href="https://www.geekischic.net/post/smartifying-classical-lamps">blog post</a> I introduced you to Shelly switches that smartify classical lamps. Shelly is not in the friends of hue program, and you can not control the Shelly switches with your Hue app.When you are using Hue motion sensors and want your Shelly switches controlled by these motion sensors, you have to get creative. Philippe Hue offers an API that lets you write your controller script or app. In the following guide, I will describe step by step how to write a script that polls the status of your hue motion sensor and turns your Shelly switches on and off based on that.</p><h3>First let’s get the status of your hue motion sensor</h3><p>1. Go to your hue app, go to ‘settings’, select ‘hue bridges’ tap on the information button of your listed bridge, and note the IP address your bridge has. In my case, it’s 192.168.1.8</p><p>2. Type the URL</p><pre><a href="http://yourbridgesip/debug/clip.html">http://yourBridgesIP/debug/clip.html</a></pre><p>to your browser and you should see the CLIP API debugger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rn48ZVZ_ZH8v56KmP3jKA.png" /></figure><p>3. To get and send information from and to your Hue system, you’ll need to be an authorized user. Philipps Hue takes security seriously. One reason I choose this system is that you don’t want outsiders to play with your lights. So we need to get our authorization by making a post-call to the bridge and press the button on the bridge to verify that we are in the same household. Type this string into the message body and press post:</p><pre>{&quot;devicetype&quot;:&quot;sofias_hue_app#sofias pixel&quot;}</pre><p>You should get an error message if you didn’t push that button yet. Now press the button and do the post-call again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NsFDLRlolNOYB__xG2ZhAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avYVvC-eEwSfVg5h9HzCwA.png" /></figure><p>Now you should get a success message and your userid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvbN9ouo1PSXT73r6j-7fw.png" /></figure><p>4. To have an overview of your lights you can open a new tab and look up the following URL:</p><pre>http://<em>yourBridgesAPI</em>/api/<em>yourUsername</em>/lights</pre><p>You should see a response in a JSON format. To have a better overview, let’s copy that entire content and format it correctly. Go to <a href="https://jsonformatter.org/">https://jsonformatter.org/</a>, paste the JSON string, and press format/beautify. It should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83z5L8hoOEiPGMWCexGB5A.png" /></figure><p>5. Now let’s do the same but let’s look for the sensors this time. Look up this URL now:</p><pre>http://<em>yourBridgesAPI</em>/api/<em>yourUsername</em>/sensors</pre><p>6. Pick the sensor you want your Shellys to be triggered from. In the example, I’ll pick my motion sensor nr. 13. The following is the specific URL to that sensor:</p><pre>http://<em>yourBridgesAPI</em>/api/<em>yourUsername</em>/sensors/13</pre><p>The variable we are interested in is called ‘presence’, and its possible values are true or false, indicating whether a motion is sensed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IhfrZIXOGoPXZNl1rilQbg.png" /></figure><p>7. We’ll write a bash script in curl, that makes a get request to the Hue API and stores the JSON in a variable. Create a new file called shellycontroller.sh. Paste the following command at the top:</p><pre>#!/bin/bash MOTION_SENSON_JSON_VALUE=$(curl -s –request GET <a href="http://yourbridgesapi/api/yourUsername/sensors/13)">http://<em>yourBridgesAPI</em>/api/<em>yourUsername</em>/sensors/13)</a></pre><h3>Connect to your Shelly devices</h3><p>8. The first part was getting the information we need from the hue motion sensor. In the second part, we need to access our Shelly switches and turn them on and off with our script. Follow the official Shelly <a href="https://shelly.cloud/documents/developers/shelly_cloud_api_access.pdf">cloud API guide</a> and retrieve your server location link, device id, auth_key, and channel. You can test the post request to your device on <a href="https://reqbin.com/">https://reqbin.com/</a>, it’s an online REST &amp; SOAP API testing tool.</p><p>The request looks like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*soo2Ec7yyT4HQ1zQptYP7w.png" /></figure><p>9. Now, let’s bring it all together. Open your shellycontroller.sh script and paste the following code into it:</p><pre>#!/bin/bash MOTION_SENSON_JSON_VALUE=$(curl -s –request GET <a href="http://yourbridgesapi/api/yourUsername/sensors/13)">http://<em>yourBridgesAPI</em>/api/<em>yourUsername</em>/sensors/13)</a></pre><pre>if [ &quot;${MOTION_SENSON_JSON_VALUE:21:4}&quot; = &quot;true&quot; ]; </pre><pre>then $(curl -X POST -F &#39;auth_key=<em>yourShellyAuthkey</em>&#39; -F &#39;id=<em>yourShellyId</em>&#39; -F &#39;turn=<em>on</em>&#39; -F &#39;channel=<em>yourChannel</em>&#39; https://shelly-20-eu.shelly.cloud/device/relay/control/ )</pre><pre>echo &quot;Motion detected.&quot;</pre><pre>else</pre><pre>echo &quot;No motion detected.&quot;</pre><pre>fi</pre><p>The command MOTION_SENSON_JSON_VALUE:21:4 takes the JSON string and gets the first four chars from position 21 on. If these chars equal “true” it means that motion is detected. In that case, a post request to turn on the Shelly switch will be sent, and a message will be logged that there has been a motion.</p><p>You can run that script from any controller like raspberry by or another. Use the following bash command to run the script every second:</p><pre>watch -n 1 ./shellycontroller.sh</pre><p>The console output should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*sYZhTdNL3YMMVk4_J14-jg.png" /></figure><p><em>“Let the be light!”</em></p><h3>Final thoughts</h3><p>This script is an idea of how you can use your gadgets’ APIs to interact with each other. Every time I get a new device, I look at whether they have an API and its methods. It’s a good inspiration for new projects. Every time you shut the power down on your devices and reconnect them to your network, they might get a new IP address from your router. If your network-scripts don’t work as they should after a power breakdown or something like that, consider checking their IP addresses.</p><p><em>Originally published at </em><a href="https://www.geekischic.net/post/how-to-connect-shelly-switches-with-philips-hue-motion-sensors"><em>https://www.geekischic.net</em></a><em> on February 4, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fcdc4c1bfb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>