Skip to content

Latest commit

 

History

History
 
 

phillips_hue

HUE LIGHTS WITH ANSIBLE

This README written on September 5th, 2018 by Sean Cavanaugh. The original username feature seems to have been disabled since James Cammarata wrote the original modules and URI based Playbooks in 2016. I updated my Phillips Hue Bulbs to the latest firmware as of this post and made some new Playbooks based off the original Cammarata URI playbooks :)

PREREQUISITES

  • Ansible
  • Phillips Hue Lights
    • The kit used for this particular demo was a Philips Hue White and Color Ambiance A19 60W Equivalent LED Smart Light Bulb Starter Kit. The link on Amazon can be found here
  • IP Address of the Hue Controller (known as the bridge).
    • Most home networks will allow you to pin a static IP address to the Hue bridge. I use Google Wifi and this took a couple clicks on my iPhone.

Also make sure that you can control the lights normally from the free iPhone or Android app. This may require you adding the serial numbers manually which can be found on the side of the bulbs.

SETUP

Step 1

Open up the username_info.yml file and change the IP Address to the IP address of your Hue bridge.

nano username_info.yml

---
username: FmAXS-XpnLIxBQwyaw1tkIw04YzIt-BIG4YL0v8X
ip_address: "192.168.86.30"
body_info:
  devicetype: "Ansible!"

Ignore the username and body_info fields. The username is automatically generated by the Hue bridge and updated in this file in the following step. The body_info is just used to register this particular computer (the computer you are executing Ansible from) in the following step, the devicetype could be anything. Please refer to the getting started guide from Phillips for more information.

Step 2

For the Playbooks to work correctly you must run the register.yml playbook first:

ansible-playbook register.yml

The playbook will run and then prompt you on the terminal window:

[PROMPT USER TO PRESS PHYSICAL BUTTON HUE HUB]
Press the button on the hub now...:

You must physically touch the button on the Hue bridge (the top of it where the word PHILLIPS is clearly printed) as a security measure. Press enter on the terminal window after you have pressed the Hue bridge button.

This will save a unique Hue generated authorized user to username_info which will look like a long string of text (e.g. elY1xx9p5twUBYDjELgMUuQT99kLaVqGT1p0eDrl).

PLAYBOOKS

There are three demo playbooks included. All three of them use the include_vars task to grab the IP address and username information from username_info.yml. Run them with ansible-playbook <name>.yml e.g. ansible-playbook on_off.yml.

  • on_off.yml

    This playbook turns off all bulbs that are registered to the Hue bridge. It then prompts the user, and then turns them back on.

  • ansible_colors.yml

    This playbook cycles all bulbs between Ansible mango and Ansible pool a couple times You can find the official Ansible colors and logos here.

  • effect.yml

    This playbook takes all bulbs and puts them into a mode called colorloop where the bulbs will randomly cycle colors. This will happen for 5 seconds then it will turn off the effect.

DEMONSTRATION

hue screencast

License

GPLv3