The internet to the rescue:
GPIO0 = push switch
GPIO12 = relay
GPIO13 = LED
GIOP14 = available
Interesting project. this is something i am in the process of doing and decided to try the sonoff devices. they seem to work ok so far, if you are happy to reprogram them. here is an excellent video on how to control the light by wireless and by the light switch with a couple of hacks into the sonoff. Might be worth a look.
There are of course these (UK specific variation), tooā¦https://www.itead.cc/smart-home/sonoff-t1.html
For the super lazy person who does not mind changing the cosmetics of the switches in their home.
Shame they dont do dimming, too!
I love that Itead is a company that sees hacking as an opportunity not a threat.
I ordered a couple of these switches. Works great with tasmota+hass, but I really would love to see a non-touch version of this.
Ooops, hadnāt watched that yet. Iām definately giving the Sonoff a go then.
Presumably these switches require power at the switch. For those of us with the 3 plate in the ceiling theyāre probably not an easy option.
Dimming lights is a whole different kettle of fish, particularly with the new LED lights.
This PDF describes the problem, and a solution: http://large.stanford.edu/courses/2012/ph240/johnson2/docs/CD00003922.pdf
TL;DR: You canāt just use a Triac, and LEDs need to be dimmed differently to downlights.
You can however buy conventional dimmers that are smart(ish).
For about Ā£10 I have bought and use a number of these v-pro varilight dimmers: https://www.varilight.co.uk/dimmers/v-pro.php
They support all types of loads: incandescent, LED and florescent. Also you can change whether leading or falling edge, and trim the min dim for leds that only dim down to a certain level before extinguishing.
All they need now is an esp2866
My Sonoff finally arrived and Iāve had a play tonight. Happy to confirm that with a few small tweaks my code does indeed run on a Sonoff and you can still use the wall switch and the special / double click functions .
Good call @hijinx. This is a neater hardware solution .
If anyoneās interested let me know and I will post the updated code on Github.
Iām currently building a ESP8266 enabled mouse trap. Not because itās some great need or because itās a cheap solution, but because Iām learning so much, challenging myself, and learning fun stuff along the way. IMO itās a great way to learn how to build custom solutions to your own specific HA setup that end up making you (and it) much better off.
Iād be interested to see your code, please.
Also, as a fellow UK resident, Iād be interested to see your wiring diagram with the sonoff and wall switch.
Iāll be honest that my knowledge of UK lighting ring topologies is not particularly goodā¦ although a cursory inspection revealed the presence of brown and blue wires behind some of my switches, so my working assumption is that I have both live and neutral.
Caution suggests I dont necessarily rely on wire sleeve colours though
No problems, Iāll try and publish my code and some pointers on wiring over the weekend .
New repo added for use on a Sonoff device. The README.md in the repo explains how to use it and includes a wiring diagram.
Hopefully this is useful to someone .
Thanks for sharing.
I have a couple of Sonoff basics on their way.
I think I have L and N connections at (at least some of) my light switches.
Iām going to try to incorporate a pot or rotary encoder to act as switch and also to allow soft on/off and dimming via mqtt of smart bulbs.
Iāve spent some time on my SwitchedSonoff repository and now you can configure all of the WiFi, MQTT and Other settings over WiFi and you no longer need to make any changes to the code. This should make it easier for those who donāt want to get into Arduino / C++.
I really love all this info. Iāve been very keen to find a way to make my kitchen light accessible both manually via the wall switch and also via HA automations.
However, has anyone had any experience or luck with the idea of having a wifi bulb and doing something similar. In the sense that it could be triggered off by a wall switch and controlled in HA as well. I would assume the wall switch would be completely detached from the wiring for the actual light socket and simply be a trigger to tell HA to turn it off and on.
That way scenes and dimming of the light could be used as well as turning it off and on.
Of course the desire to do this is based on the better half stating there is no way the kitchen light can only be turned on via an app or even controlled by a motion sensor.
I created a soft switch that looks like a normal uk 1gang dimmer. Rather than dimming directly it sends mqtt messages to HA, which then in turn controls smart bulbs etc
There are many other such projectsā¦
But doesnāt the MQTT message either say to HA for the light to be on or off? With a smart wifi bulb you donāt want to turn the power off, you want it to control itās on and off state at the bulb. My current LIFX bulb in the loungeroom requires that the wall switch be left constantly on and the bulb itself does all the work.
Iām just thinking about a way to have a physical wall switch not wired to the bulb in any way that is almost like a mini version of the HA UI for just that one light. Perhaps a touchscreen is the way to go.
I donāt know for sure but I can imagine hijinxās project has a HA automation listening out for the correct MQTT message. This in theory could trigger any action including the toggling of a wifi bulb.
I actually have a similar use case that I will be working on shortly. Hereās my current setup:
I have 2 lights in my bathroom, the ceiling lights and the lights in the mirror. Both are connected separately to HA using MQTT. The light switch is plugged into the micro-controller looking after the main lights and turns them on and offā¦then an HA automation triggered by the main light turning on and off turns the mirror lights on and off in sync.
There is also a motion sensor that will turn on the mirror lights if anyone walks in the bathroom at night (kind of a night light). The trouble is, when the night light is on and the main lights are off I would like to be able to turn the night light out by switching the switch (instead of waiting for the motion sensor to time out). At the moment this will turn the main lights on.
What I plan to do is, in the case of the main bathroom lights, instead of the switch controlling the light and then updating HA, I want it to tell HA that the switch has been switched and then HA can make a decision on what to do. In my case, if either of the lights are on, turn them all off, if both are off, turn them all on.
This could be used in your use case to toggle the wifi bulb instead.
Iām sure there are plenty of projects out there that do this already, hijinxās project for example does a great job if you need dimming functionality. If you just need a on / off switch and canāt find anything else then Iāll let you know when Iāve updated my repo.
I hope this helps.
So many great project to be inspired by and fork
Youāre quite correct. The on/off/brightness is sent from the switch via mqtt, picked up by ha and then drives automation to tell a philips hue bulb to turn on/off or set brightness.
If you only want on/off then you could use the same setup but with a conventional light switch wired to the esp8266 rather than the rotary encoder + small change to espeasy config (rocker switch instead of the momentary in the rotary encoder).
If youāre using smart bulbs though I guess they can be brightness controlled so why not consider dimming too?