Saturday 4 February 2023

Smart Light Switch and bulb

As a Christmas present I requested and received a smart wall light switch for my study.  I want to be able to turn the light on or off using Google Home (GH) voice commands.

Choosing a switch

There is a technical difficulty replacing a traditional switch with a smart one. Strange as it may seem there is a power problem.  Wall switches typically just have a live wire going in, through the switch and out again.  We cant use a single wire to power anything.  A clever solution is to add a capacitor in the ceiling rose which provides the necessary charge/current to operate wifi.  I had to make sure I ordered a "no-neutral" switch.

Hardware installation

Installing the wall switch is easy, though the wall box for mine isn't quite deep enough so I installed a spacer to make it fit neatly.  Similarly the ceiling capacitor went in nicely.  I used a very convenient video from Geek Street to make sure I did it right.  Once I had completed the install the switch worked fine as a light switch - to me this is good progress 😉

Adding the Switch

The switch can be added to the SmartLife app which discovers it easily when you select "Add device".  It is now possible to switch on and off the light using SmartLife.

Home Assistant (HA) can see a new switch in the Tuya (i.e. SmartLife) integration.  After restarting HA I can switch the light on and off using a dashboard switch.  I added the switch to my lights dashboard page.

The switch is also visible to Google Home and I added it into the Study devices.  Now it is included if I ask google for "lights on" when I am in the study.

We have made very good progress and the switch is fully working and controllable and I started to think about a dimmer.😀

Philips Hue 100W (equiv) dimmer

Previously I had a dimmer switch for the study room light but my room bulb wasn't very bright in the first place and I didn't use it.  I saw an advert for a Philips Hue 1600 lumen warm light dimmable bulb.  the bulb is supposed to be compatible with Home Assistant and Google Home.  At £20 it isn't outrageously expensive compared with some other Hue products so I bought one.

Hue installation

I needed a new "Philips Hue" app on my iPad.  As expected the light was discovered and I could adjust the brightness.  I was very impressed that full brightness is equivalent to a 100W bulb and I now have a bright light suitable for electronics work.  70% brightness is fine most of the time and 50% gives the room a warm cozy ambience.  By default, if you switch off and on with the wall light, the bulb comes on at full brightness rather than remembering the previous setting.  This avoids a problem if you turn the brightness right down and it appears the bulb isn't working.

Google Home setup

 I experienced some problems configuring Hue in Google Home.  In theory it should be discovered automatically but, although I tried repeatedly I couldn't get GH to do this.  Lots of documentation refers to the need for a bridge; older Hue lights were controlled from a bridge/hub which communicated with them using Zigbee wireless protocol.  Mine is a new one which also has bluetooth obviating the need for a hub and Philips documentation confirms this.  A reddit post provided inspiration for a fix - I did a factory reset on Hue within the Hue app and deleted the wifi device from my iPad.  GH still didn't discover the bulb immediately, but when I told it that the device was a light which supported "Seamless Device Setup" it was added.  Looking at lighting devices in my study I can now see a switch and a dimmer for the ceiling light.  When I tell Google "lights off" or lights 50% Google will adjust it for me.😀

Home Assistant

Earlier I had no success making the Hue Bluetooth known to HA which only seems interesting in the old-fashioned Bridge version.  It occured to me there may be a way of accessing GH devices from HA.  Luckily for me the functionality appears to have been implemented in the latest version 2023.1 of HA.
Even better the "EverythingSmartHome" channel has an excellent youtube tutorial on the subject which was published a couple of weeks ago.

I followed the tutorial to add a new integration "Google Assistant SDK".  As part of the procedure I had to setup Google Credentials on the Google Cloud Developers Console. These provide a link between Google Assistant (GA) and Home Assistant so that HA can send commands to GA.

There is a neat interface into GA, you send commands from HA to GA as text versions of GA voice commands.  Following the tutorial I added a new Service to HA using the SDK and sent a command to dim the lights exactly as if I had said "Hey Google, lights dim 50%".😀