benknight / hue-alfred-workflow

An Alfred workflow for controlling Philips Hue lights.
367 stars 34 forks source link

Compatibility with deConz bridge #52

Closed dpasdar closed 3 years ago

dpasdar commented 3 years ago

I have newly replaced my hue-bridge with a deCONZ (on raspberry-pi), it should be(and is) compatible with the hue API, and the workflow is also working so far quite well with some small adjustments which I thought I would share here:

filters.py(line 125) instead of

if light['state']['on']:

we can use:

if 'state' in light and 'on' in light['state'] and light['state']['on']:

The same should also be done in utils.py(line 66)

rgb_value = (255, 255, 255) if ('state' in light_data and 'on' in light_data['state'] and light_data['state']['on']) else (0, 0, 0)

The problem is that the deCONZ bridge identify it's own configuration-tools as a light, but without an on/off state. If these simple changes are reasonable to be integrated into the main branch, I would gladly open a branch/pull request (if I would be given the necessary permissions)

benknight commented 3 years ago

@dpasdar Feel free to submit a pull request. Sorry it's been a long time since I wrote Python. Is there a less verbose way to check for existence?

dpasdar commented 3 years ago

Funny you mentioned it, my daily job is Java, so verbose is the name of the game ;P, so I don't know tbh. But according to this another way is to use exceptions : https://stackoverflow.com/questions/43491287/elegant-way-to-check-if-a-nested-key-exists-in-a-dict