Running DiyHue on the Raspberry Pi

Hackbs

How to Run DiyHue on Raspberry Pi? Bring Home the Smartness!

Key Takeaways

  • DiyHue lets you control Zigbee lights without an official Hue bridge
  • Runs on a Raspberry Pi with Raspbian OS, Python, Node.js and CC2531 stick
  • Setup involves installing software dependencies and configuring DiyHue
  • Requires adding connected lights details to lights.json
  • Allows integration with Google Home, Alexa, HomeKit and more without Hue

DiyHue is an open-source software package that allows you to control commercial Zigbee-based lights (like Philips Hue) with software other than the official Philips Hue bridge. It emulates a Philips Hue bridge that connects to services like Google Home/Assistant, Amazon Alexa, Apple HomeKit and more.

DiyHue lets you:

  • Control lights without an official Hue bridge
  • Use cheap Zigbee lights instead of expensive Hue bulbs
  • Connect more lights than a Hue bridge allows
  • Integrate with more smart home platforms

It runs on multiple platforms like Raspberry Pi, Docker, and more. This guide focuses on running it on Raspberry Pi OS.

Hardware Needed

To run DiyHue on Raspberry Pi, you need:

  • Raspberry Pi board (3B+ recommended)
  • MicroSD card (16GB Class 10 minimum)
  • Power supply
  • Zigbee coordinator (CC2531 USB stick)

Optional accessories:

  • Case for Pi
  • Cooling fan or heatsinks

Software Required

You’ll need the following software:

  • Raspberry Pi OS (32-bit)
  • DiyHue latest release
  • Required dependencies like Python and Node.js

Steps to Run DiyHue on the Raspberry Pi

Follow these steps to get DiyHue running on your Raspberry Pi:

1. Install Raspberry Pi OS

Download and flash the latest 32-bit Raspberry Pi OS image to your microSD card using Raspberry Pi Imager or Etcher.

Insert the card into your Pi and connect keyboard, monitor, ethernet cable/WiFi dongle and power supply. Allow it to boot up, configure settings in Raspberry Pi Configuration if needed, then update the system with:

sudo apt update

sudo apt full-upgrade

2. Enable SSH

Next, enable SSH so you can remotely access the command line later:

sudo systemctl enable ssh

sudo systemctl start ssh

3. Install Required Dependencies

DiyHue requires Python 2.7 and Node.js 10 or later. Install the packages with:

sudo apt install python2.7 nodejs npm git

4. Download and Install DiyHue

Clone the DiyHue repository from GitHub into the /opt folder:

cd /opt

sudo git clone https://github.com/diyhue/diyHue.git

cd diyHue

Install dependencies and compile native modules:

sudo npm install --unsafe-perm

5. Configure DiyHue

Before first run, copy and edit config templates:

sudo cp config.json.template config.json

sudo cp lights.json.template lights.json

In config.json at minimum, edit the bridgeid and websocketport.

Next, edit lights. Son and add your bulb details. See the device compatibility list for reference.

Conclusion 

In conclusion, DiyHue is a versatile, open-source software to use commercial Zigbee lights without vendor lock-in. With a Raspberry Pi and few inexpensive parts, you can build your own smart home hub.

FAQs

Q: Does DiyHue work with WiFi bulbs like TP-Link or WiZ?
A: No, DiyHue only works with Zigbee protocol bulbs at this time.

Q: Can I control DiyHue lights when away from home?
A: Yes, as long as your Raspberry Pi hosting DiyHue is accessible over the internet. Port forwarding is required.

Q: Is a Raspberry Pi Zero powerful enough to run DiyHue?
A: Generally no – due to its single core CPU. Raspberry Pi 3B+ quad core or better is recommended.

Q: What can I use to control DiyHue lights?
A: You can control DiyHue via Google Assistant, Amazon Alexa, Apple HomeKit, home assistant, Node-RED and many other platforms.

Q: How many lights can DiyHue support?
A: Up to 250 Zigbee lights can be connected, assuming compatible Zigbee coordinator and adequate RPi resources.

Q: Can I use my Hue Dimmer Switches with DiyHue?
A: Yes, original Hue dimmer switches can pair directly with DiyHue for basic control. Some advanced features may not work.

Q: Is there a web based interface to control lights?
A: Yes, there is a built-in minimal web UI that allows you to control lights when on the same network.

Q: How do I backup or restore DiyHue configuration?
A: Simply copying your /opt/diyHue folder containing config.json, lights.json etc will backup settings. Restore by copying back.

Q: Can I add sunrise/sunset automations to DiyHue?
A: Yes, there are a couple ways to achieve this – using the DiyHue REST API, or via integrations with Home Assistant, Node-RED etc.

Q: Is DiyHue secure? Can someone hack my Zigbee lights?
A: Reasonable security practices are implemented, but as with all DIY internet-connected devices, caution is advised. Keep RPi and DiyHue updated.

Q: Why won’t some of my bulbs pair with the CC2531 controller?
A: Try updating bulb and coordinator firmware. Also power cycle bulbs that refuse to connect. Refer to troubleshooting steps.

Q: Can I use a alternative Zigbee sticks like ConBee II or Sonoff?
A: Potentially yes, but setup will differ. CC2531 reference designs have community firmware support tailored for DiyHue.

Q: How do I contribute to the DiyHue open source project?
A: You can help by testing, reporting issues & fixes, assisting other users on the forum, or contributing code changes via pull requests.

Q: Can Alexa discover and control my DiyHue lights automatically?
A: Yes, with some setup to expose your RPi on the internet, Alexa can discover and link the emulated hue bridge & lights.

Q: What exactly are the differences between DiyHue and ZHA in Home Assistant?
A: DiyHue emulates a Philips Hue bridge completely in software. ZHA directly interfaces Zigbee devices to HA. Different integration methods, choose as per your use-case.

Q: How do I securely expose my RPi hosting DiyHue to the internet?
A: Use VPN tunnel like Wire guard or Zero Tier. Advanced users can also leverage reverse proxy and firewall rules for security.

Q: Can I integrate DiyHue with custom voice assistants like Rhasspy or Almond?
A: Yes, DiyHue provides a JSON REST API that can be utilized by any home automation platform to control the lights.

Leave a Comment