studioimaginaire / phue

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

The Scene container needs to be updated #142

Closed MedievalMarmot closed 5 years ago

MedievalMarmot commented 5 years ago

Two errors encountered after updating my Hue Bridge:

Traceback (most recent call last): File "./hueList.py", line 31, in scenes = b.scenes File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/phue.py", line 1144, in scenes return [Scene(k, v) for k, v in self.get_scene().items()] File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/phue.py", line 1144, in return [Scene(k, v) for k, v in self.get_scene().items()] TypeError: init() got an unexpected keyword argument 'type'

Traceback (most recent call last): File "./hueList.py", line 31, in scenes = b.scenes File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/phue.py", line 1145, in scenes return [Scene(k, v) for k, v in self.get_scene().items()] File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/phue.py", line 1145, in return [Scene(k, v) for k, v in self.get_scene().items()] TypeError: init() got an unexpected keyword argument 'group'

After dumping the JSON for the scenes from the API, I see two values missing from the Scene class. Type and Group are additional values now present in scenes - I manually fixed this on my own by updating the following in phue.py

`class Scene(object): """ Container for Scene """

def __init__(self, sid, appdata=None, lastupdated=None,
             lights=None, locked=False, name="", owner="",
             picture="", recycle=False, version=0, type="", group=""):
    self.scene_id = sid
    self.appdata = appdata or {}
    self.lastupdated = lastupdated
    if lights is not None:
        self.lights = sorted([int(x) for x in lights])
    else:
        self.lights = []
    self.locked = locked
    self.name = name
    self.type = type
    self.group = group
    self.owner = owner
    self.picture = picture
    self.recycle = recycle
    self.version = version`
Cazfri commented 5 years ago

Should be resolved with #143

MedievalMarmot commented 5 years ago

Thanks guys, you rock!