Use Siri to Control Wireless Power Outlets (Homebridge)
This is a follow up for my guide on how to control cheap wireless power outlets using a raspberry pi. This is part 1 of a 3 part series on controlling the wireless power outlets using your voice. Part 2 is on Google Home and part 3 covers the Amazon Echo.
With Apple’s Home app, you can control any device that is HomeKit enable from your iOS device. Lucky for us an open source project called HomeBridge was created so we can control the devices from a raspberry pi. HomeBridge is a great open source project that has many plugins and allows you to customize your home automation.
Steps to Setup HomeBridge to control Wireless Power Outlets
- Install HomeBridge on your raspberry pi
- Setup HomeBridge to start on bootup
- Install CmdSwitch2, a plugin for HomeBridge that allows you to execute commands via HomeKit
-
npm install -g homebridge-cmdswitch2
-
- Edit your HomeBridge config.json file
- Type this command to edit your config file.
-
sudo nano /var/homebridge/config.json
- Add this section to the platforms array. Example of my config.json
-
{ "platform":"cmdSwitch2", "switches":[ { "name":"Lamp", "on_cmd":"/var/www/html/rfoutlet/codesend ******", "off_cmd":"/var/www/html/rfoutlet/codesend ******" } ] } - Replace the asterisks with your 6 digit code. Verify that /var/www/html/rfoutlet/codesend is the correct path to your codesend executable.
- You can add multiple lights just be sure to name them appropriately.
- Save and exit (Use “ctrl + x” then “y” to save the file) then restart HomeBridge:
-
sudo systemctl restart homebridge
- Install the Home app on your iOS device.
- Connect to the same network as your raspberry pi and you should now see your accessories
- Say “Hey Siri, turn on the lamps” or “Turn off the lamps”
Here is a guide if you would like to control your lights from when you are away from home. You must have an iPad or Apple Tv to act as your HomeKit hub.
Please leave a comment below if you have any questions.