Skip to main content

Automatic Kitchen Lights



We recently purchased Hue bulbs for our Kitchen they’re great, but since we already have an RFXCom 433 unit (as per my blog on automating hifi), we wanted to automate the lights and invested in a Lightwave PIR motion sensor. 


I downloaded Domoticz [http://domoticz.com/] on an SD Card for my Raspberry PI and also installed node-red [http://nodered.org/] a tool for filtering and processing MQTT messages. 

Domoticz is used to store the state of the motion sensor and is configured to emit an MQTT message whenever the state changes. 

We also wanted the lights to have a different colour depending on the time of day we enter the kitchen, for example during the evening we might want a relaxing light, meal times a white light above the dining table and during the day some multi coloured lights, but not change them if they've already on. 

For each of the time slots of the day, a template has been created containing the settings of each of the main and dining lights and will send these on to the relevant light bulbs. 

When motion is triggered, the node-red flow decides which template to use and as an additional requirement, switches the lights off after a configurable delay once no motion has been detected. 

The flow is pictured below (click to download):



Download the flow!

No Motion:

The PIR will send an 'off' signal when it detects no motion, a switch on the back can be used to configure this and I've set it to 2 seconds. If Domoticz receives an 'off' signal, then an MQTT message is sent and all messages received on ‘domoticz/out’ are received by this flow. The messages are filtered by the IDX value of the switch in Domoticz and a filter detecting motion indicated by the payload.nvalue. When the nvalue is 1, the message is directed to a trigger node which will delay it for 5 minutes. After 5 minutes, the trigger node will emit the same message to a 'turn light off' template the result of which is sent to both the dining table and main kitchen light.

Motion:

The PIR will send an 'on' signal when it detects motion. If Domoticz receives an 'on' signal, then an MQTT message is sent and received by this flow filtered by the IDX value of the kitchen sensor in Domoticz and a filter detecting motion indicated by the payload.nvalue. When the nvalue is 0; this does 2 things.

1: The message is directed to the 'Reset Timer' template node which generates a new message with a 'reset' attribute set to true, this is passed into the trigger node cancelling any timeout in process. This is useful if someone leaves the kitchen, the timer will start a countdown to switching the lights off after 5 minutes, but then cancel that countdown if someone walks back in before the lights have switched off. 

2: The message is also directed to the 'Scene Chooser' which runs a function evaluating the current time and emitting a message on each of the applicable channels to template nodes which will generate some JSON to control the relavant dummy switches in Domoticz switching them off. The function has 5 outputs representing each scene we want:

00 - 06: Evening
06 - 09: Breakfast
09 - 12: Coloured
12 - 14: Lunch
14 - 17: Coloured
17 - 20: Dinner
20 - 22: Evening
22 - 00: Coloured

I've made the flow available to download from here:
https://dl.dropboxusercontent.com/u/174818/TimedKitchenLights.json

Resources:

Comments

Popular posts from this blog

Dell 5530/Ericsson f3507g on Linux

A few months back I posted a howto guide on getting this mobile broadband card working with Linux, what I failed to mention was I continued to work on these scripts. I feel it is appropriate to post a status update on what I use now especially given there appears to be no further updates on the NetworkManager front. I no longer use UMTSMon as I found it relied on AT+CSQ for the signal quality and during UMTS and HSPA connections, the f3507g/dell 5530 returns either the previous GPRS value or 99,99 which UMTSMon considers as no connection available. I've used a simplified wvdial.conf scripts and now do the rest of the radio work using python. wvdial.conf # Author: Barry John Williams # Creative Commons Attribute-Share Alike 2.5 UK:Scotland Licence [Dialer defaults] New PPPD = yes Stupid Mode = 1 Modem Type = ACM Modem Modem = /dev/ttyACM1 Init1 = AT Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"ip","internet" Baud = 460800 I...

Howto: Ubuntu 8.10, Dell 5530, 3G/WWan and GPS

There is an updated howto on the Dell 5530 using my own python based monitoring tool at http://blog.bjw.me.uk/2009/03/dell-5530ericsson-f3507g-on-linux.html Introduction Here is a Howto document for getting the Dell 5530 wwan card working along with the onboard GPS under Ubuntu 8.10. This card does not work conveniently with the bundled Network Manager software, but replacing NetworkManager with other utilities will give the ability to get online using a pretty GUI and not have to resort to using wvdial and the command line... It should also work with the Ericsson f3507g as I believe the Dell 5530 is a rebadged version of this module. Check Hardware First you need to check the modem is detected correctly. On my computer, the modem is detected out of the box by the cdc_acm module and exposes three serial ports (/dev/ttyACM[0,1,2]) for communication. Check by running: dmesg | grep ACM Mine shows the following: [ 34.385302] cdc_acm 1-6:1.1: ttyACM0: USB ACM device [ ...

Linn DS Alarm Function

Update 2014 - An alternative to this is available on GitHub which uses Node.js and should be cross platform. Linn DS Playlist and Alarm Server Switching the radio on in the kitchen in the morning is a low priority amongst setting table, pouring cereals, carrying children, etc. The Sonos has an alarm clock facility which allows you to switch on the radio at a set time avoiding hassle of starting a controller. When I upgraded to my Linn Sneaky DS, I no longer had this function, though the remote control made it easy if I forgot to take my phone downstairs with me. Last week I decided to figure it out. I have a Linux machine which runs Ubuntu and runs all the media servers, backups and network shares. I decided to investigate how to control my DS from the command line. Conveniently, the DS can be controlled via a web api, so after reading the docs and a few examples I was able to switch off and on and change source via Postman (Chrome REST client). I then set about writing...