Skip to content

Instantly share code, notes, and snippets.

@lordneon lordneon/steps.md
Last active May 30, 2020

Embed
What would you like to do?
UK Light Wiring with Shelly 1

Intro

This is a simple guide on how to automate UK lights with a Shelly 1 by installing the shelly 1 relay into the ceiling pendant which has both permanent live, neutral and a switched live back from the wall switch.

These steps are from my own experience making my lighting "smart" but also user friendly (it works via a wall switch!). This simple guide will go through replacing an a normal ceiling pendant with one with room for a Shelly 1. If you have a ceiling light with a bigger base it's even easier.

Warning Electrical regulations must be followed by law. If you are not a competent person under the regulations do not attempt electrical work. https://www.diydoctor.org.uk/projects/electrical_safety.htm

Wiring Diagram

This diagram has been taken from here and modified to include the Shelly 1. Wiring Diagram

Parts Required

Steps

  1. First pre-wire as much as the Shelly as you can. 2. You want a two lengths of brown wire around 6cm which will be the LIVE in and the SW in (Switched live back from the light switch), a length of blue wire around 6cm for the NEUTRAL in. 3. Cut a small piece of wire to connect LIVE to I (Input). This is the power feed shelly will supply to your light. 4. It should now look something like the following, only O (output which goes to the lamp live) will be un-populated. Pre-Wired Shelly
  2. Install the shelly into the base of the new lamp and connect up the lamp wires. 3. Rember to reduce the length of the lamp wire so the pendant is at the correct height. 4. The red/brown live of the lamp should connect to the O(utput) of the Shelly 1. The shelly will only supply power when you want the light on! 5. The neutral of the lamp can be fitted into the N terminal of the shelly if there is room, otherwise you can put it into the neutral connector block you will be installing.
  3. It should look something like this: Shelly Connected in Base
  4. Time to replace the ceiling pendant. If the wiring seems strange and you don't understand it, do not go ahead and please consulate a qualified electrician.
  5. Turn off the lighting circuit you are modifying and ensure that nothing is live (ensure the light does not work and use a voltage detector around the base of the light)
  6. Once you have removed the lamp shade, bulb and unscrewed the pendant it should look like this: enter image description here
  7. Please make sure you know what wires are which, this is very important!
  8. In this instance it's a very basic ceiling rose as the room only has one light. There are two neutral wires, three permanent live wires and a switched live wire (a red sleeved neutral wire which returns from the wall switch).
  9. The ceiling rose has a built in connector block, in order to fit the shelly we are replacing this with a simply bracket which the ceiling rose cover fits to and using our own connector blocks instead of one built into a base.
  10. You need to disconnect the lamp, which connects to the switched live block and the neutral block. It should now look something like this: Ceiling Rose without Lamp
  11. Remove the base keeping the wires together, you will need 4 connector blocks (Earth, Live, Neutral, Switched Live). For each block you need support for N + 1 wires. For example, Live in the above example will need a 4 way, the switched live will need a 2 way.
  12. Install the bracket for the new ceiling rose it should look something like this (I had not put on the earth connector at this point) Bracket Installed
  13. Time to connect the lamp up. 14. Connect up the N(eutral) from the Shelly (which includes the lamp) to the Neutral connector block. 15. Connect the L(ive) from the permanent live block to the Shelly. 16. Connect the SW(switched live) input from shelly to the switched live (sleeved neutral) connector block. 17. Connect the earths of all wires AND the metal ceiling rose together.
  14. It should now look something like this, this can be very tricky as there's not much space! It's much easier with lights with large bases. Make sure all connections are secure! Wired Up Hanging
  15. Secure the cover to the bracket on the ceiling, being careful with the cables and ensuring they have room and that the cables are secure. It should now look something like this: Dangling Lamp
  16. Done! Install a bulb and time to turn the power back on.
  17. Use the Shelly 1 App to add the Light to your network, also configure the button action! I have mine set to "Edge Switch" so the wall switch will change the status of the light no matter the position.

Before and After pictures Before enter image description here

Home Assistant Integration

I use the shelly MQTT support to monitor and control the lights in real-time (no waiting on a HTTP poll). WARNING using MQTT will disable cloud functionality through the shelly app.

  1. Get the IP address of the Shelly through the Shelly App (Settings -> Device Information). Also make a note of your Device ID.
  2. In a web browser go to the IP address of the Shelly, under the "Internet Security" tab there is an "ADVANCED - DEVELOPER SETTINGS" toggle. Tick the "Enable action execution via MQTT" 3. Enter your MQTT server IP and port 4. Tick "Retain" this ensures that home assistant always knows the correct state.
  3. Hit Save!
  4. In your home-assistant configuration.yml put the following
    light:
	  - platform: mqtt
	    name: Some Light
	    command_topic: "shellies/shelly1-<DEVICEID>/relay/0/command"
	    state_topic: "shellies/shelly1-<DEVICEID>/relay/0"
	    payload_on: "on"
	    payload_off: "off"
  1. This is making the assumption that you already have your MQTT server configured. I personally use a separate MQTT instance instead of the built-in one as I have a lot of devices using MQTT.
  2. Done! restart home assistant and you should be away.
@alanfic

This comment has been minimized.

Copy link

alanfic commented Feb 26, 2019

Conventional UK Pendant Fitting

Thanks for posting this practical example, I was encouraged enough to get some Shellys to try (pack of two from ebay listing). They do seem suited to working with UK wiring, having the 230V switch and the size to fit where the wiring is already in place. These devices seem ideal as a start in home automation. No extra equipment needed to solder or adaptors to flash the chip; just add to fairly conventional house wiring.

I thought I'd see what they look like in a conventional ceiling rose. Not practical up a ladder, but as a bench exercise they do (just) fit. This is one in a cheap pendant set from toolstation; only a minor cheat to cut down a couple of ridges on the base so the Shelly lies flat and the lid screws down:
image

Practically, I have replaced a landing light and including a Shelly. Mostly so it gives us a timed light we can also set when we're away. I was a bit wary about putting the Shelly in a earthed steel electrical rose, but the WiFi signal strength will depend on your own set up. For my project I used a decorative ceiling centre, so room for a large opening and tuck the wiring above the electrical rose while still leaving it accessible.

Shelly Firmware

A note about current firmware levels. From the web browser interface, under Settings => Firmware Update the factory firmware:
20180903-123604/v1.1.3@67ef4071
is still being supplied in the ones I bought from Bulgaria (early 2019). MQTT is only available with later versions. There should be an Update Firmware button and the latest firmware version listed as available – at time of writing
20190214-074430/1.4.7-revertwifi@0f3372b3
A couple of minutes to update and reboot, then among the extras available MQTT is under Internet & Security => Advanced – Developer Settings

One of the (minor) problems setting up the Shelly is that it seems to have restrictions on initial set up; it didn't like attaching to the no-password SSID I usually enable to initialise devices for example. If the Shelly becomes unresponsive, it can be reset by powering on, then 5 quick on-and-off switches to the SW terminal. You should be able to hear the relay flicker on and off a few times after the 5th switch on. Check the SSID Shelly-999999 or similar is available on 2.4Ghz. The most reliable initialisation seems to be through the Shelly cloud, as described in the box leaflet. You will need to input your usual household WiFi SSID and password. Once that is done, check which IP is allocated on the router and use a browser to that address for the Shelly set up, setting a fixed IP for example.

Automation with MQTT and Domoticz

There is a timer available from the web interface for each Shelly individually, and the "Shelly Cloud" is another option if you don't mind relying on your broadband connection. However, the better option is to use one of the home automation projects to centralise your controls and logs. There appear to be a few notes out there on using Shelly with Home Assistant, as @lordneon describes. I have used my Domoticz instance as the home automation hub for these lights. I already had it running on a Pi because it offered the best support for my heating controls (Honeywell evoHome). For Sonoff controls, I had added MQTT to the Pi in the form of Mosquitto. There is a good walk through of setting up Mosquitto on a Pi at https://blog.hobbytronics.pk/installing-mosquitto-broker-on-raspberry-pi/ which includes automating the startup with systemd.

The simplest method I found of setting up the Shelly on Domoticz (Version: 4.9700) is to use the Python plug-in kindly made available by @enesbcs at https://github.com/enesbcs/Shelly_MQTT. This is designed to use default Shelly firmware MQTT topics such as "shellies/shelly1-999999/relay/".

The Shelly_MQTT readme has references to getting started with Python plug-ins on Domoticz. The extra step for current latest versions at time of writing (early 2019) is that the Python lib needs to be updated to the dev version for the Domoticz PluginSystem to start correctly. My plug-in install and update sequence on a Pi looked like:

  sudo apt update
  cd domoticz/plugins
  git clone https://github.com/enesbcs/Shelly_MQTT
  cd Shelly_MQTT/
  chmod +x plugin.py
  chmod +x mqtt.py
  cd ../../..
  sudo apt-get install libpython3.5-dev
  sudo systemctl restart domoticz.service

Check in the Domoticz Setup => Log that the PluginSystem has started correctly, something like below, If it doesn't there will be a complaint that the Python version needs updating.
2019-02-99 00:00:00.000 Status: PluginSystem: Started, Python version '3.5.3'.
On the Domoticz Setup => Hardware menu, the “Shelly MQTT” should appear as a new “Type” to choose when adding your new hardware. Enter the MQTT server details (the Mosquitto instance running on the Pi), this will control all your Shelly switches. All you have to do now to add your Shelly switch to your Domoticz hub is turn it on and off a few times (web interface or on the switch) the new MQTT entries will prompt Domoticz to add a new switch with a name something like "ShellyMQTT - shelly1-999999-0". That can easily be edited to something more meaningful such as "Landing Light".

@optilude

This comment has been minimized.

Copy link

optilude commented May 1, 2019

Thank you for this - really helpful!

There probably isn’t space for a Shelly inside a normal U.K. ceiling rose / cup / pendant light fitting (mine are about 8cm in diameter and only deep enough for the wires).

I bought some CableCups to solve that problem: CableCup Compact White https://www.amazon.co.uk/dp/B01E77LSSE/ref=cm_sw_r_cp_api_i_1uuYCbZ4J1BBZ

I screwed a standard hook screw into the centre of the rose (careful not to hit any wires!) - won’t bear a lot of weight but enough for my needs. Then fitted the Shelly as shown above and placed the CableCup around it. Very easy and tidy.

@iranzo

This comment has been minimized.

Copy link

iranzo commented May 13, 2019

Hi,
If the switch (commuted) has three wires coming, do you know how to make the wiring properly?

2019-05-13 15 46 59

In that image, I was able to get the shelly powered and the switch to alter the status, but still the light was not connected (in the regular switch two wires do connect/disconnect depending on the other switch position and the other brings the power).

In my pic, grey is the one bringing power, black is connected to the other switch (same as the other black left unconnected) and put two simple wires to transmit switch position to the shelly

Thanks!

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

Before I go and buy one of these, i would like to install it behind my UK light switch would the same set up work

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

If not how would you do it

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented Jan 10, 2020

You could do it behind your light switch if you have a neutral there and you have enough depth for the shelly unit (17mm).

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented Jan 10, 2020

https://shelly.cloud/wifi-smart-home-automation-shelly-dimmer/ the dimmer sl is your only option if you don't have a neutral.

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented Jan 10, 2020

Yes that's right.

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented Jan 10, 2020

No red is live and black is swiched live. Check out the diagram at the top.

@halfajobj

This comment has been minimized.

Copy link

halfajobj commented Jan 10, 2020

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented Jan 10, 2020

No it's still live. I recommend you consult an electrician and get them to install them for you.

@notorioustubze

This comment has been minimized.

Copy link

notorioustubze commented May 30, 2020

06C8321B-5242-4A0C-B94A-BA6A85F3182E_1_105_c
This is the wiring I have behind my garden lights. I have a Shelly 2.5 can I use them here? If so where do I begin any help greatly appreciated.

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented May 30, 2020

06C8321B-5242-4A0C-B94A-BA6A85F3182E_1_105_c
This is the wiring I have behind my garden lights. I have a Shelly 2.5 can I use them here? If so where do I begin any help greatly appreciated.

Is there a lightswitch for them or are they hard wired in?

If there is a light switch then the brown is switched-live, as such you could use the shelly but you would have to leave the light switch in the on position and only control them via the app.

Luckily I have a shelly 2.5 on my desk! It's pretty straight forward:

Disconnect the fabric brown and connect that to 01 on the shelly 2.5, this is the output to the light.
Connect the brown to the L on the shelly, then have another cable loop from that L to the other L (so they are all connected).
Connect to Neutral to the N on the shelly, make sure the fabric neutral is still connected as well.
Leave all the earths connected.

@notorioustubze

This comment has been minimized.

Copy link

notorioustubze commented May 30, 2020

06C8321B-5242-4A0C-B94A-BA6A85F3182E_1_105_c
This is the wiring I have behind my garden lights. I have a Shelly 2.5 can I use them here? If so where do I begin any help greatly appreciated.

Is there a lightswitch for them or are they hard wired in?

If there is a light switch then the brown is switched-live, as such you could use the shelly but you would have to leave the light switch in the on position and only control them via the app.

Luckily I have a shelly 2.5 on my desk! It's pretty straight forward:

Disconnect the fabric brown and connect that to 01 on the shelly 2.5, this is the output to the light.
Connect the brown to the L on the shelly, then have another cable loop from that L to the other L (so they are all connected).
Connect to Neutral to the N on the shelly, make sure the fabric neutral is still connected as well.
Leave all the earths connected.

Thank you so much for the rapid response yes this light does have a switch I have included a picture in my repsonse. I was really hoping to be able to use these lights with ability to control them regardless of switch state are you saying this isn't possible? Thanks again.
33CD28CE-FDE6-4845-A825-1D6CA7714129_1_105_c

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented May 30, 2020

No i'm afraid not. Without a permanent live feed for the shelly there is no way to do it.

You could bypass the light switch if you wanted to only control them via the shelly. This would prevent someone from accidently turning them off.

@notorioustubze

This comment has been minimized.

Copy link

notorioustubze commented May 30, 2020

Ahhh ok no problem I may just look at getting smart bulbs for the outside lights then at least that way I can change the colours. Thank you for the prompt response again. I do however have another question if that's ok with you, I have some under cupboard lighting in my kitchen that I'd love to automate would you mind taking a look at the pictures supplied and letting me know If I can maybe use the shelly with them instead? So there are two seperate feeds to each side of the cupboards but all are controlled with a single switch. One has a junction box the other seems to be wired direct to the powersupply.
7941677D-BA4B-4EC2-A08F-C2E6A0B71514_1_105_c
FDA9172B-1CDB-473E-B9BC-BDD0CBA57D02_1_105_c
811638AF-3BF1-42A0-97A6-7E15831678E4_1_105_c

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented May 30, 2020

Looks to be the same again. So that junction box has, switched live neutral and earth going in, then it goes out to the transformer and to another twin and earth cable for the other transformer.

You could put a shelly in if you left the switch on. It might be worth taking off your light switch and see if there is a neutral there, if there is then you could put it in there.

There will be a junction box before your light switch which would be the place to put this, however this is probably in your ceiling so will not be the most accessible.

@notorioustubze

This comment has been minimized.

Copy link

notorioustubze commented May 30, 2020

Damn this is raining on my parade.... Sorry not shooting the messenger, can't thank you enough for getting back to me on this before paying for a sparky to come in. I could certainly deal with leaving the switch on for the under cupboard lights would you mind talking me through how i'd go about adding a shelly into this scenario? Thank you

@lordneon

This comment has been minimized.

Copy link
Owner Author

lordneon commented May 30, 2020

Yeah quite simple.

You want to install it by that plastic junction box (ideally get another bigger junction box).

Connect the incoming browns to L, again loop the L to the other L.
Connect the two outputs to 01 and 02 (or just to 01, splitting them allows you to control the lights individually)
For the neutral just put an extra cable in and connect it to the shelly.

Job done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.