studioimaginaire / phue

A Python library for the Philips Hue system
Other
1.52k stars 267 forks source link

run_scene error #144

Closed Cazfri closed 5 years ago

Cazfri commented 5 years ago

Noticed tonight that the Bridge.load_scene function was working, complaining with the error message:

Traceback (most recent call last):
  File "/Users/noah/code/viki/app/hue/hue.py", line 35, in <module>
    h.load_scene('Relax')
  File "/Users/noah/code/viki/app/hue/hue.py", line 17, in load_scene
    self.bridge.run_scene('Noah Bedroom', scene_name)
  File "/Users/noah/code/viki/venv/lib/python3.7/site-packages/phue.py", line 1166, in run_scene
    scenes = [x for x in self.scenes if x.name == scene_name]
  File "/Users/noah/code/viki/venv/lib/python3.7/site-packages/phue.py", line 1138, in scenes
    return [Scene(k, **v) for k, v in self.get_scene().items()]
  File "/Users/noah/code/viki/venv/lib/python3.7/site-packages/phue.py", line 1138, in <listcomp>
    return [Scene(k, **v) for k, v in self.get_scene().items()]
TypeError: __init__() got an unexpected keyword argument 'type'

When I tested on the Hue API debugging tool at /api//scenes, I got responses such as

{
    "KL2XQKROiKfvwQU": {
        "name": "Savanna sunset",
        "type": "GroupScene",
        "group": "1",
        "lights": [
            "1",
            "2"
        ],
        "owner": "Z6JmooCHGmbrg65weMUH5dPnTPtP1ryQ5kTwnS2x",
        "recycle": false,
        "locked": false,
        "appdata": {
            "version": 1,
            "data": "XqVVT_r01_d15"
        },
        "picture": "",
        "lastupdated": "2018-09-07T02:28:38",
        "version": 2
    },
        ...
}

The type and group properties from the API response must have been causing the error, since they're not expected kwargs in the Scene constructor. I submitted PR #143 that fixes the issue for me.

Bridge: Version 1810251352 Lights: Version 1.29.0_r21169