Wednesday, November 7, 2018

Sonoff switch linkage to home automation

Hooking up a Sonoff 4 Gang Smart Switch, Interlock Switch for Generator, Inching/Self-locking WiFi & RF Wireless Switch 90~250V AC/ 5~24V DC,Work with Alexa,& Google Home & IFTTT (1-16s delay in inching mode) to Homeseer.

There are other versions of these switches that these instructions will work for too. The single switch unit bought in packs can be way cheaper than this 4 switch unit but are also AC only. In my case I'm wanting to switch individual cameras connected to a single power supply so the above switch is the way to go. Note unlike most WiFi smart switches, these are all inline units meaning you need to connect wires to them.

The most helpful instructions I found To help save time you will also want to know:

Make sure your phone is connected to the 2.4 GHz WiFi you want the Sonoff unit to use.before adding a new switch to the app. Note in this app, this just works. No need to find and connect to WiFi coming from the unit.

Unless you want it to work in the default, only one active relay at a time mode, you need to change the switches.

Remove power from the unit before changing any switches!

You do not need to take the cover off to connect up the relays. There is a hinged hatch but taking the lid off  might make connecting the wires easier. The connections are of the pinch type so smaller gauge wires may not be held well. In most you are probably using 18 ga though which work fine.

Tools you will need:

To get the lid off so you will need a larger phillips screwdriver but with a thin bit so you can get enough torque to turn the tight screws and fit in the small holes to get to them. Something that looks like this.

There is a film cover K5 and K5 that is hard to see but will need to be removed to toggle the switches. You will probably want a good pair of fine point tweezers for this. If the are not sturdy enough to toggle the K5 and K6 switches you may need something else for that.

The switches are you may want some sort of magnifying glasses.

Setting the switches:

The text can be a bit confusing. Such as it will say "Toggle to the right" when the pictures are not all the same rotation.

To set it up to turn off on each of the 4 channels separately and immediately the config you want is:
S6 toggled "right" (toward the LEDs)
remove film cover on K5 and K6 switches.
K5 (mode) and K6 (delay) toggle all the switches to 1, ON (toward the terminals.)

Note the yellow tint to the switches. It is from these film covers. (Photographed through magnifying glass.)


Hook up your 12 volt wiring like this

I'm using these cables for the wiring.

Software config

Note if this unit loses power it returns all relays to the off position. So for instance if you are using this as a camera power reset you probably want to reverse the actions as in ON in your home automation is "OFF" / NC on the switch. 
Also note a lag of up to a couple seconds in not unusual going through IFTTT. 

Create Homeseer device

First you will want to create a virtual device in Homeseer like this.

Note it might take IFTTT a few minutes to pick up changes so best of create your virtual devices all up front then wait a bit for proceeding.

Link through IFTTT

As with all such IFTTT linkages you will want at least and off and on IFTTT applet for each direction.

First to control the plug when the Homeseer device changes create and applet like this

To get Homeseer to reflect changes to the Sonoff relays by others create applets like this

Note there are other options out there that involve flashing the single switch unit by soldering a USB port to the single switch board to get local control. With the stock firmware I scanned mine and found there are 0 open ports on the unit so reflashing might be the only way to make these cloudless. Though this blog post seems to say you can control one locally by pointing at a local Node.js server as a bridge. Since I'm mainly looking for a cheap way to repower hung cameras on an infrequent basis it seems more than it is worth. If the Sonoff / IFTTT connection starts playing up like the Etekcity one has been then it might be worth looking into.

No comments:

Post a Comment