Controlling the Microwave Light with a Raspberry Pi + Relay

I can control every light in my house thanks to Z-Wave switches and Philips Hue.  Every light EXCEPT the bulb in the microwave above the stove.  This really bothered me for some reason, even though it was an LED that would consume $0.0001 per year.  So I took apart my microwave and attached a relay to this bulb.  Now when I tell Siri to turn off all the lights, ALL the lights go off, and that is very satisfying.


Raspberry Pi Relay Code (node.js)

//require the wiring-pi node library
var wpi = require('wiring-pi'); 
//use GPIO pin 3
var configPin = 3; 
//setup wiring-pi library
//configure pin 3 to be used for output, instead of input like for a sensor
wpi.pinMode(configPin, wpi.OUTPUT); 
//turn on relay by writing 1 to the pin which sends voltage to the relay, send 0 to turn off
wpi.digitalWrite(configPin, 1);

Amazon Echo Bridge allows Alexa control

Amazon Echo Bridge simulates a Philips Hue bridge for controlling web services with an Amazon Echo.  It supports on, off and brightness.  An Express web server on my Raspberry Pi handles Alexa’s requests, then triggers the relay.

Homebridge-http allows Siri Control

TV Mounted On Outside Corner

It’s possible to mount an 85 lb 50″ Plasma TV on an outside corner, just in case anyone is wondering.  I was able to get eight big lag screws into studs.  An LCD would be less than half the weight so it wouldn’t need as many screws.



Dishwasher Completed Alerts

I wanted to be sure that my dishwasher started and be alerted when it was completed.  Like most dishwashers, mine does not have any smart features or network connectivity.  Instead of directly interfacing with the dishwashser, I decided to use a smart plug that supports energy metering.  A Raspberry Pi continuously queries the smart plug to determine how much power it is consuming, then triggers IFTTT to send a notification to my phone and Watch when wattage exceeds 10 watts.  Now when my wife asks “did you start the dishwasher” I don’t have to rely on my late-night memory, and can just look at my phone.

I’m using this TP-Link HS100 smart plug because it unofficially supports network control.

This guy reverse engineered the smart plug’s network protocol.

This guy wrote a node module to simplify interfacing with the smart plug.

I wrote a node module to simplify getting notifications from an appliance when it starts and stops using power.  The script runs forever on my Raspberry Pi using PM2.

var SmartPlugPowerMonitor = require('smart-plug-power-monitor');

var smartPlugPowerMonitor = new SmartPlugPowerMonitor({
    smartPlugIP: "",
    iftttMakerChannelKey: "abcdefg",
    startEventName: 'dishwasher-started',
    endEventName: 'dishwasher-completed',
    wattsThreshold: 10,
    pollIntervalSeconds: 15,
    startTimeWindowSeconds: 5,
    endTimeWindowSeconds: 20 * 60


Amazon Echo Pauses My TV

I can say “alexa, turn on TV pause” or “turn on TV play” to control my TV.  A Raspberry Pi receives the request from the Amazon Echo, then the Pi queries my receiver to find out if I am watching my TiVo or my smart TV’s built in apps like Hulu, YouTube or Netflix.  Then the Pi pauses either the TiVo or the smart TV.  I am fortunate that my LG TV, TiVo and Marantz receiver can all be network controlled, so I don’t have to rely on a stateless infrared blaster.

Using Alexa is very handy in case I abruptly have to walk out of the room, I can pause my TV while walking, so I am not slowed down but also do not have to miss my TV show.  If the phone rings, I can quickly pause the TV without waiting to answer my phone.  Another use case is when somebody turns on the blender or gets ice from the fridge.

Next I plan to implement an “alexa turn on rewind” to skip back 30 seconds both with the TiVo or smart TV.

Software Libraries

  • Custom code that talks to my TiVo (telnet) and Marantz stereo (http)

All the code and libraries are kept running forever on my Raspberry Pi using PM2.

PM2 is designed for node scripts, not Java, so to keep Amazon Echo Bridge running forever I use this PM2 process configuration.  (Thanks Zalym)

    "name": "Amazon Echo Jar",
    "args": [
    "script": "java",
    "node_args": [],
    "log_date_format": "YYYY-MM-DD HH:mm Z",
    "exec_interpreter": "none",
    "exec_mode": "fork"

Control Stereo Volume with Siri and Alexa

Denon and Marantz receivers have a web interface that allows the volume to be changed using standard HTTP requests.  Siri and Alexa can change the brightness of a lightbulb between 0% – 100%.  My Raspberry Pi simulates a light bulb but instead of changing the brightness of a light, the Raspberry Pi sends an HTTP message to my receiver to adjust the volume according to the simulated brightness percentage.

  • “hey siri, set the stereo volume to 25%”
  • “alexa, set the stereo to 50%”

Now I can control my TV volume with these devices

  • TV remote
  • Stereo remote
  • TiVo remote
  • Siri on my iPhone or Apple Watch
  • Siri on my wife’s iPhone, Watch or iPad
  • Stereo’s web interface
  • Amazon Echo Dot’s Alexa
  • iPhone light bulb brightness shortcut
  • Apple Watch digital crown

I almost always set the volume using Alexa, because she is in the same room as the stereo.  If I turn up the stereo so loud that Alexa can’t hear me well enough to turn it down, then I can speak directly into the mic of my Apple Watch, which will always hear me over any background noise since my mouth is so close to the mic.


A Node.js HTTP PUT request to the stereo’s control URL changes the volume

var relativeVolume = (newVolume - 80).toFixed(1);
request.get('http://stereo/goform/formiPhoneAppVolume.xml' + '?1+' + relativeVolume, function(error, response, body) {
    if (!error && response.statusCode == 200) {
        callback(null, response.statusCode);
    } else {


Homebridge allows Siri control

A Raspberry Pi running Homebridge uses this plugin to create a fake lightbulb which changes the stereo volume when you use your iPhone to change the brightness.

Amazon Echo Bridge allows Alexa control

Amazon Echo Bridge simulates a Philips Hue bridge for controlling web services with an Amazon Echo.  It supports on, off and brightness.  An Express web server on my Raspberry Pi handles Alexa’s requests, then forwards them to my stereo.