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 was fine with the skill already available. Just need to add the skill.


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.

curl -X POST$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/ on
script:///home/pi/scripts/ 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.)


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

No comments:

dead pi

Well, I guess it has to happen at some point. the home automation raspberry pi has died. Much to do with the stupid Strontium mini SD card. ...