Saturday, February 01, 2020

Sonoff wifi smart switch with Homekit

I just got some cheap Sonoff smart switches for the existing ceiling led lights (which can't fit hue bulbs). Sonoff uses eWelink and I needed to link this to Alexa, Siri(homekit) and Fibaro.


Alexa

Alexa was fine with the skill already available. Just need to add the skill.

HomeKit

The next challenge was homekit/homebridge.  I started trying to find an API and it's actually more complicated than I imagined. I looked out for more commercial integrations to eWelink and found the IFTTT one. That makes it "easier" with the IFTTT applet with a webhooks.

1. Create an IFTTT applet: IF webhook event name "ewe_light_on" THEN turn on the light

2. Create an IFTTT applet: IF webhook event name "ewe_light_off" THEN turn off the light

3. Create a bash shell script to call the IFTTT webhook with the webhook address.

Example ewe_light.sh:
curl -X POST https://maker.ifttt.com/trigger/ewe_light_$1/with/key/

-- The $1 variable allows input for the on/off variable.

4. Create a virtual device in Domoticz with the on commands as the script name
script:///home/pi/scripts/ewe_light.sh on
script:///home/pi/scripts/ewe_light.sh off

5. Add the virtual device to the Homekit Roomplan. And the device will appear in Homekit. (Recap, I've already had thehomebridge-edomoticz npm module setup.)


Fibaro

With Domoticz already setup, it's easy to create a virtual device pointing to the domoticz URL.


No comments:

Splitting the home network

Who wouldn't want to separate the traffic at home for security reasons. The more common ones include wireless guest and wireless users. ...