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.

Parts

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
wpi.setup('wpi'); 
//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

https://github.com/armzilla/amazon-echo-ha-bridge

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

https://github.com/rudders/homebridge-http


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 {
        callback(error);
    }
});

 

Homebridge allows Siri control

https://github.com/robertvorthman/homebridge-marantz-volume

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

https://github.com/armzilla/amazon-echo-ha-bridge

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.