Welcome to mirror list, hosted at ThFree Co, Russian Federation.

README.md « phillips_hue - github.com/ansible/ansible-examples.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 42f295c00d2c8fe91c46bd0f7d11838ac241b565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## HUE LIGHTS WITH ANSIBLE

This README written on September 5th, 2018 by [Sean Cavanaugh](https://github.com/ipvsean).  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
   - [Install Guide](https://www.amazon.com/gp/product/B07D1J5QC7/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1)
- 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](https://www.amazon.com/gp/product/B07D1J5QC7/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1)
- 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](username_info.yml) file and change the IP Address to the IP address of your Hue bridge.

```nano username_info.yml```

```yaml
---
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](https://www.developers.meethue.com/documentation/getting-started) 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](https://docs.ansible.com/ansible/latest/modules/include_vars_module.html) 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](https://www.ansible.com/logos).

  - `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](hue.gif)

## License

GPLv3