benknight / hue-alfred-workflow

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

Alternative fix for #52 compatibility with Deconz and Homekit hue #55

Closed benknight closed 3 years ago

benknight commented 3 years ago

@dpasdar I think this approach is a bit simpler. Just filter out anything that doesn't look like a light. Can you check if this works?

dpasdar commented 3 years ago

Unfortunately not, here is the error:

Traceback (most recent call last):
  File "logic/packages/workflow/workflow.py", line 2073, in run
    func(self)
  File "/Users/dpasdar/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB0F350D-07DF-4543-B8B5-43898306C9DE/logic/filters.py", line 458, in main
    items = hue_index_filter.get_items()
  File "/Users/dpasdar/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.EB0F350D-07DF-4543-B8B5-43898306C9DE/logic/filters.py", line 102, in get_items
    lights = utils.get_lights()
  File "logic/utils.py", line 85, in get_lights
    load_full_state()
  File "logic/utils.py", line 47, in load_full_state
    create_light_icon(lid, light_data)
  File "logic/utils.py", line 66, in create_light_icon
    rgb_value = (255, 255, 255) if light_data['state']['on'] else (0, 0, 0)
KeyError: u'on'

Changing that line to

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

solved the problem.

benknight commented 3 years ago

@dpasdar I've pushed a fix for the error you pasted, can you check one more time and see if the code runs successfully now? Thanks for your patience.

dpasdar commented 3 years ago

It works now! Thanks a lot.