How do you use discover_scenes.py to find hue groups & scenes?

How do you use the discover_scenes.py referenced here?

I get the error

Traceback (most recent call last):
  File "./discover_scenes.py", line 17, in <module>
    import phue
ImportError: No module named phue

Hopefully this helps someone since this info isn’t on the Philips Hue component page. The light.hue_activate_scene service didn’t work with just the discovery component.

The hue groups showed up as switches in the frontend (not using default view) when I added this to configuration.yaml

  platform: hue
  host: x.x.x.x
  allow_unreachable: true```

That allowed the ```light.hue_activate_scene``` service. The Hue group and scene names in the Hue app that I had been trying then started working (and I didn't need discover_scenes.py - never did figure that out, hehe). But I couldn't figure out a way to turn them on and off in automations. I think you can just trigger scenes stored on the Hue bridge.

After adding ```allow_hue_groups: true``` the Hue groups show up as light.room
with the attribute ```is_hue_group: true``` and I just replaced group.room with light.room in all of my automations.
1 Like

I have installed the phue phython module via:

sudo pip install phue

but now I need to give the script a config file:

./discover_scenes.py
usage: discover_scenes.py [-h] hue_conf
discover_scenes.py: error: too few arguments

and if I give a blank config file i get the following:

./discover_scenes.py hue_conf
Traceback (most recent call last):
  File "./discover_scenes.py", line 42, in <module>
    discover()
  File "./discover_scenes.py", line 31, in discover
    bridge = phue.Bridge(config_file_path=args.conf)
  File "/usr/lib/python2.7/site-packages/phue.py", line 629, in __init__
    self.connect()
  File "/usr/lib/python2.7/site-packages/phue.py", line 752, in connect
    self.register_app()
  File "/usr/lib/python2.7/site-packages/phue.py", line 706, in register_app
    response = self.request('POST', '/api', registration_request)
  File "/usr/lib/python2.7/site-packages/phue.py", line 647, in request
    connection = httplib.HTTPConnection(self.ip, timeout=10)
  File "/usr/lib/python2.7/httplib.py", line 736, in __init__
    (self.host, self.port) = self._get_hostport(host, port)
  File "/usr/lib/python2.7/httplib.py", line 768, in _get_hostport
    i = host.rfind(':')
AttributeError: 'NoneType' object has no attribute 'rfind'

but not sure what this config file should look like… any tips?

Regards

I couldn’t get the script to work either but I just used the phue module as follows. Be sure to press the button on the hue hub before you run this.

import phue

b = Bridge('192.168.1.206')
b.connect()
b.groups

May I know the exact steps you took to discover your Hue groups and scenes? I’ve been trying to do this and I have no clue how to use discover_scenes.py (which seems like doesn’t actually work anyway, according to these posts?)

I attempted to follow your post by doing the following.

pip install phue

(Successfully installed phue-1.1)

Pressed the button on the Hue bridge (which has a static IP).

python 
import phue

Then ran a .py script with the exact lines you posted, and my Hub’s static IP in place of 192.168.1.206.

Got the following instead

NameError: name 'Bridge' is not defined

I’m kinda new to running Python scripts and all, so any help would be appreciated.