Intro

The house I live in was build in the ’80s. This means the configuration of the electrical installation is pretty basic and could sometimes be called old-fashioned.
This also means that the house has no provisions for the fancy home automation systems new houses often have included from the start.

Since adding these fancy systems in a house like mine would require me to basically strip and rewire the whole house –which I don’t feel like doing– I have to resort to home automation add-ons.
Luckily, there’s already a whole market of devices that can assist in setting up home automation in situations like mine. They’re easily recognisable, since they’re usually called “smart” + “non-smart device name”, like “smart toaster”.

I didn’t feel much excitement for the first wave of smart device and I also have my doubts about the need to smartify just about anything, especially the apparent need to connect just about anything to the internet.
If you want to have a laugh(?) at the things manufacturers add internet connectivity to, have a look at the Twitter profile Internet of Shit.

Requirements

The first rule of automation is that it should add functionality without adding extra burden.
For example: with most smart light bulbs, you cannot use your classical light switches anymore, since the bulbs require constant power. As such, you’ll either need to always use an app to turn on/off your lights, or buy smart light switches for manual control.

I definitely don’t want to get vendor-locked. Devices should be able to work with devices from other brands. Preferably, 1 central hub should be able to control different devices and I should be able to set up automations across them.

Related to the previous requirement, I prefer to use open standards.
E.g., my security cameras work with ONVIF, so I can capture a copy of the video stream to my local NAS or control them using open software.

Devices shouldn’t require internet connectivity to work.
If network access is require, e.g. for remote access from my smartphone, this should go through the central hub. All other devices should be behind a firewall rule blocking outgoing connections. Definitely no UPnP opening random ports on my FW.

Of course I want to be able to install everything myself. Unless there’s a high amount of risk involved or there’s specific code to be followed, I want to do all installations on my own. I feel comfortable opening switches and wall sockets, know the basics of electricity and safety, and have friends who I’m able to call for advice if I have specific doubts.
An active support forum is definitely useful.

Since I don’t have much experience (yet) with building devices myself, flashing firmware on ESP chips, etc. I want to be able to build prebuild devices. But as I said before: I don’t want blackbox devices with zero room for tinkering.

Updates are important.
In just about any device, tool, software package… bugs are discovered, some more dangerous or more impactful than others.
It’s gives comfort knowing that the manufacturer still supports the devices and provides updates, be it Over the Air (OTA) or by manually flashing new packages.

Finally, I also want to be sure that my devices stay working in the future.
I’m one of the many owners of a Pebble watch and am grateful for the developers and community continuing the project after Fitbit bought and killed the Kickstarter backed smartwatch.

Introducing: Shelly

Saying that the devices of Shelly are the first introduction of smartness to my house, would be incorrect.
I already own a smart doorbell and perhaps you could almost call security cams managed by my NAS smart as well.
However, since I wasn’t doing anything particularly smart with them yet, other than answering the door while at work, I won’t count these in just yet.

Shelly devices are manufactured by Allterco, which has its headquarters in Sofia, Bulgaria.
By the looks of it, Shelly emerged around 2018 and has quickly risen in popularity.
It’s usually compared to Sonoff, with the Shelly1 being matched with the Sonoff Basic. If you want a comparison between these two devices, I would advise you to watch this Youtube video by The Hook Up. In short, the Shelly relays (they have other devices as well) are small devices (the size of 2 Oreo cookies stacked on top of each other) that are usually installed in a switch box and can be controlled via a physical switch or button, via the app, or home automatation software like Home Assistant (which I’ll cover in another blog post).

Shelly compared to Oreo cookies
© Shelly Cloud - Shelly 1 compared to Oreo cookies

I installed 3 Shelly devices in my house so far, one Shelly 1PM and two Shelly 2.5’s, and plan on installing more in the future. These currently control the light in one bedroom and two lights in my living room.

Installation

WARNING
Mains voltage can kill you!
Always turn off the breaker.
Ask an electrician for help if you don’t know what to do.

There are multiple types of Shelly relays. Which one you’ll use depends on the type of load your switching and the specifics of your configuration.

Installation usually boils down to the following:

  • The Shelly relay should be installed as close as possible (electrically speaking) to the load you’re switching.
    I.e. You’ll probably install it behind the last switch in a multi-switch configuration, or in the lamp base.
  • You’ll need to power the Shelly itself using mains voltage (110-230V AC) or using a power supply (12V/24-60V DC*).
    For this you’ll need connectors L (phase/-) and N (neutral/+).
    Don’t forget to set the jumper on the correct pins. By default, the jumper is set to power the Shelly with mains voltage.
  • The Live wire doesn’t necessarily need to come off the same wire feeding the switches (SW), but it must be on the same phase.
    Note that the Shelly and lamp will be protected by the breaker feeding the Shelly, so this may change if you borrow a wire elsewhere.
  • The Shelly 1 has a dry relay, which means that you can switch a load with a different voltage than what you’re using to power the Shelly.
    That’s why, for the Shelly1, you’ll also need to provide input voltage on connector I (input).
    The other relays have the Input internally connected to the Live connector.
  • Connect your physical switch/button to the SW connector. This could be the light switch of your existing light fixture.
    This needs to be the same voltage as what you’re providing to the Input connector (Shelly 1) or the Live connector (other Shelly relays). Make sure you’re not mixing phases if you’re pulling wires from different circuits.
  • Whatever you’re switching (e.g. your lights) will be connected to the O connector (Output).
    You could have a Shelly relay at your switch just to detect input changes (I) and perhaps have a Shelly elsewhere to do the actual switching (O).

* DC voltage may differ depending on the Shelly model. Make sure you check the manual first!

Make sure you follow your local code/regulations regarding type of cable used, colour coding, water/fire proofing, safety, etc.
For example: where I live, the most commonly used wires are the 1.5mm² and 2.5mm² used for lighting and wall sockets respectively. Wires are coloured brown/red* for Phase/Live/Hot (I’ll call this Live from now on), blue for Neutral, green-yellow for Ground, and black/grey for switch wires. Since local building code has changed since my house was built, other colours might still be present, which is something to be wary of when working in older houses.

* Actually, any colour other than green-yellow may be used for Live. Even blue is allowed in a multi-phase layout where there’s no Neutral. Old houses over here often have white wires for Live.

However, I’m not an electrician, building codes differ amongst countries/states/…, and they change over time (e.g., to accomodate for home automation systems), so:
Always check your local building code and regulations! Consult a licensed electrician if you have any questions!

Shelly 1 wiring instructions
© Shelly Cloud - Shelly 1 wiring instructions on mains

When you’ve double-checked your wiring, turn on the breaker to power the Shelly and continue in the Shelly app for the initial configuration.

Info on the “basic” installations can be found in the Shelly manual or on the website.
These assume you have all the wires you need present at the location you want to install the Shelly relay.

Powering the Shelly

As I discussed a few lines up, the Shelly needs to be powered as well.
But what if you don’t have power available at the location you’ll be installing the Shelly?

Depending on what you have available, you might still be able to get your automation going.

  • Do you have the possibility to get power to that location?
    • By pulling extra wires from the power source of your load (most commonly near the first switch in a multi-switch layout).
    • By borrowing power elsewhere. E.g. a wall socket or switch from a different room.
      Do pay attention to the phases and keep in mind that this may cause your load to be connected to a different breaker than before.
  • Can you reuse some of the wires already present?
    • In a multi-switch layout, you’ll have 2 switch wires between each switch. You could use these to carry power.
      • If you have Neutral available at your load, you’ll only need to transfer Live/Phase and have 1 cable available for SW.
      • If you don’t, you’ll have to use them for both Live and Neutral. I’ll cover how to get SW to work later.

Tip! You may want to do the initial configuration of the Shelly device on your workbench first. Just in case anything goes wrong or you happen to have a broken device, you don’t want to have to undo the whole installation of the Shelly again.

Shelly configuration

There’s 2 methods of setting the Shelly up:

  • using the Shelly app
  • using the Web UI

Both methods have their pros and cons, I leave it up to you to pick which method you prefer.

Examples

Two-way toggle switch with Shelly1(PM)

Below is the most common installation of a 2-way switch, also known as a hotel switch. Two switches control the same light and physical state of the switch (up/down) is not linked to the state of the lamp.

Wiring schematic of 2-way toggle switch
Wiring schematic of 2-way toggle switch

By installing a Shelly1(PM) you can make these switches “smart”.
Install the Shelly as below and set Button Mode to Edge.

Wiring schematic of 2-way toggle switch with Shelly1
Wiring schematic of 2-way toggle switch with Shelly1

Note that you need to pull an extra wire to be able to provide permanent Live to the Shelly.

Two-way momentary switch with Shelly1(PM)

A two-way setup can also be achieved using momentary switches. A momentary switch setup is also ideal for when you want to make a toggle switch setup smart using a Shelly since you can install the switches in parallel so that you don’t need to pull an extra Live wire.

Extra switches would be installed in parallel, requiring only 2 wires: Live and signal.

Wiring schematic of 2-way momentary switch without relay module
Wiring schematic of 2-way momentary switch without relay module

Momentary switches send a pulse when they are pressed. That’s why they are always connected to some sort of relay unit which will toggle a relay each time a pulse is received. Without the Shelly (or a different relay unit) the light would only be on while one of the buttons is being pressed.

Installing the Shelly will usually involve replacing the existing relay module with the Shelly.

Wiring schematic of 2-way momentary switch with Shelly1
Wiring schematic of 2-way momentary switch with Shelly1

Two-way switch, renovation

My first install of a Shelly relay was in a bedroom I was renovating at that time.
The bedroom initially had one light switch at the door, but none near the bed. So you either had to get in bed in the dark, or throw a shoe at the switch :P

While renovating, I got rid of the single switch and installed two two-way switches.
The Engineering Mindset has a good video on how a two-way switch works.

In the old configuration, 3 wires would run from the switch to the lamp: Ground, Neutral and Live interrupted by the switch.

Wiring schematic of lamp with single switch
Schematic of old situation with single switch

To convert this into a two-way switch, I need to pull 2 (switch) wires between the switches and a Live wire from the second switch to the lamp.
Note that the old Live wire is no longer used. If you plan on installing a wall socket near the switch, you could still use that wire. But make sure that you need to follow your local code re. mixing circuits.

Wiring schematic of lamp with two-way switch
Schematic of new situation with two-way switch

To install the Shelly, we’ll reuse the old Live wire. By connecting this in front of the switch, it becomes a “permanent Live”.
We use this wire and the Neutral to power the Shelly. The Live is also used as the Input.
The output Live wire of the final switch is connected to the SW input.
Finally, the lamp is connected to the Output.
Note: use Wago clamps to connect multiple wires together.

Wiring schematic of lamp with two-way switch and Shelly 1
Schematic two-way switch installation with Shelly 1

Two-way switch, existing installation

I did my second Shelly installation in my living room.
In this room I have 2 switches at either side of the room to control 2 lights, so two sets of 2-way switches (a.k.a. 3-way or hotel-switch).

Since I cannot pull any extra wires to either switches or to the lights, I have to do with what’s already there.
Luckily, at both locations I had access to permanent Live and Neutral, so I only need to take care of the switches and the output.

There’s multiple ways you can get this to work:

a) Using buttons

The easiest setup would be to replace the switches with buttons (momentary switches).
Install a Shelly 2.5 at the final switch and use the switch wires to send the signal for each button.
Use a Wago to combine these wires with the wires connected to the matching buttons on the other side and run a wire to SW1 and SW2 respectively.

Wiring double 2-way momentary switch (buttons) with a Shelly 2.5
Wiring double 2-way momentary switch (buttons) with a Shelly 2.5

b) Using Shelly 2.5 and Shelly i3

You could also install a Shelly i3 behind the first switch, using 2 of its 3 inputs.
Install a Shelly2.5 behind the final switch and connect the switches/buttons to SW1 and SW2.
Use the Actions menu on the Shelly i3 to toggle the outputs on the Shelly 2.5 using the HTTP REST API.
I.e., to toggle O1 use the following URL http://<IP_of_Shelly_2.5>/relay/0?turn=toggle

The diagram can be found a bit lower in the blog post.

c) Using two Shelly 2.5’s

There are also two methods that use two Shelly 2.5’s. Depending on how much room you have to install the Shelly’s, you may pick one or the other.
The first method is also useful if you don’t have Neutral available at the final switch.

I started with the first method but eventually redid the installation because I had the space and prefered to keep the 2 Shelly’s apart to give them some breathing room and keep the temperatures lower.

Both at the end

First, you could install both Shelly 2.5’s at the final switch.

Since I have two 2-way switches, I have 4 wires running between both locations (two times two switch wires).
Using one set of two wires to carry Live and Neutral, I can power one or both Shelly’s. The other two wires are connected to the two switches and SW1/SW2 of the first Shelly.

I then powered the 2nd Shelly from the wires present at the final switch (but could’ve used the previously repurposed switch wires).
The two switches at this side are then connected to SW1/SW2 on the 2nd Shelly, matching the order on the other Shelly.

I then use the HTTP REST API again to have the first Shelly control the outputs of the 2nd one.

Note: Instead of matching O1 and O2 of one Shelly with a light each, you could also match each Shelly with a certain light.
So you’d connect the switches controlling the same light to the same Shelly instead of the same SW#.
In this scenario, use O1 for the output and setup an action for SW2 to toggle O1 using localhost as target.

Note2: You can set a relay to Detached mode if it’s not linked to an output, so that it doesn’t “click” when you toggle the connected switch. The call to the API will still be executed.

Each at a switch

I finally chose this setup instead, because it’s less cramped and leaves more breathing room for the Shelly’s.

Wiring double 2-way switch with two Shelly 2.5's
Wiring double 2-way switch with two Shelly 2.5’s

This installation is basically the same as when using an i3.

Wiring double 2-way switch with Shelly 2.5 and Shelly i3
Wiring double 2-way switch with Shelly 2.5 and Shelly i3

If you have Live and Neutral available at both switch locations, you don’t even need to repurpose any wires.

Wiring double 2-way switch with Shelly 2.5 and Shelly i3 using seperate power feeds
Double 2-way switch with seperate power feeds

Three-way switch with Shelly1(PM)

Below is the most common installation of a 3-way switch, sometimes called 4-way switch or hotel switch. Three (or more) switches control the same light and physical state of the switch (up/down) is not linked to the state of the lamp.
More switches can be added by including more cross-switches in the middle.

Wiring schematic of 3-way switch
Wiring schematic of 3-way switch

By installing a Shelly1(PM) you can make these switches “smart”.
Install the Shelly as below and set Button Mode to Edge.

Wiring schematic of 3-way switch with Shelly1
Wiring schematic of 3-way switch with Shelly1

Note that you need to either pull an extra wire or borrow one elsewhere to be able to provide permanent Live to the Shelly.

Conclusion

The devices by Shelly/Allterco are affordable and flexible.
They already have quite a big collection of useful and I’m certain many more awesome devices will follow.

I wrote this article when I installed one Shelly 1PM and two Shelly 2.5’s (double 2-way setup).
Writing this, I actually realised it might be a good idea to replace one of the 2.5’s by a Shelly i3 :P

By the time I published this article, I already upgraded my installation with 2 more Shelly 1PM (front door and back door lighting), 3 Shelly H&T and 2 Shelly Door/Window 2.
I’m definitely adding more devices in the future :)

I also integrated my Shelly’s in Home Assistant, together with some other devices in my network, and am using Node-RED to build automations.
Since the Shelly firmware 1.8 update had some breaking changes to the CoAP implementation, the ShellyForHASS plugin is currently broken. So if you want to use this plugin as well (instead of using e.g. MQTT), you’ll currently have to stick with or downgrade to the v1.7 until a new update of the plugin is rolled out.
The people behind ShellyForHASS are working hard to push a working update out as soon as possible.

The support group on Facebook is awesome.
You have Shelly enthusiasts but also Shelly employees answering just about any question you may have.
Also keep an eye on this FB group if you want to stay up-to-date on the latest updates on Shelly, the owner is very active and updates are often posted on FB first.

Changelog

Update 2021-11-06

  • Add section on Shelly configuration

Update 2021-10-18

  • Added schematic for 2-way momentary switches
  • Small changes in titles

Update 2020-11-06

  • Added schematic for 3-way switch
  • Added schematic for double 2-way switch using 2 different power feeds
  • Small modification to installation instructions to clarify usage of different Live wires between switches and Shelly.

Update 2020-11-05

  • Added schematic for 2-way switch

Update 2020-09-12

  • ShellyForHASS update is now out of beta and supports Shelly firmware v1.8.x

Update 2020-08-26

  • Added schematic for wiring two-way switch using buttons and one Shelly 2.5
  • Added schematic for wiring two-way switch using Shelly i3 and Shelly 2.5