benknight / hue-alfred-workflow

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

Error in workflow 'Philips Hue Controller' #69

Open icn2you opened 1 year ago

icn2you commented 1 year ago

Was delighted to see this Alfred Workflow was updated. Thank you! I missed it.

After installing, I'm getting the above-referenced error. The detail on the error is as follows:

list indices must be integers or slices, not str

What am I doing wrong?

[17:43:47.131] Logging Started...
[17:44:05.382] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Queuing argument ''
[17:44:06.463] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Script with argv '(null)' finished
[17:44:06.469] ERROR: Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Code 1: .
17:44:06 workflow.py:2476 DEBUG    ---------- Philips Hue Controller (3.1.0) ----------
17:44:06 workflow.py:1784 DEBUG    reading settings from /Users/icn2you/Library/Application Support/Alfred/Workflow Data/hue-alfred-workflow/settings.json
17:44:06 workflow.py:2758 INFO     checking for update ...
17:44:06 background.py:229 DEBUG    [__workflow_update_check] command cached: /Users/icn2you/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/hue-alfred-workflow/__workflow_update_check.argcache
17:44:06 background.py:233 DEBUG    [__workflow_update_check] passing job to background runner: ['/usr/bin/env', 'python3', '-m', 'workflow.background', '__workflow_update_check']
/Library/Developer/CommandLineTools/usr/bin/python3: Error while finding module specification for 'workflow.background' (ModuleNotFoundError: No module named 'workflow')
17:44:06 background.py:237 ERROR    [__workflow_update_check] background runner (['/usr/bin/env', 'python3', '-m', 'workflow.background', '__workflow_update_check']) failed with 1
17:44:06 workflow.py:1784 DEBUG    reading settings from /Users/icn2you/Library/Application Support/Alfred/Workflow Data/hue-alfred-workflow/settings.json
17:44:06 connectionpool.py:228 DEBUG    Starting new HTTP connection (1): 192.168.99.170:80
17:44:06 connectionpool.py:456 DEBUG    http://192.168.99.170:80 "GET /api/mcPI3LrX9vBUjxvMEKUzntrZlKG2r3JE3s00eySq HTTP/1.1" 200 None
17:44:06 workflow.py:1994 DEBUG    saved data: /Users/icn2you/Library/Application Support/Alfred/Workflow Data/hue-alfred-workflow/full_state.pickle
17:44:06 workflow.py:1910 DEBUG    data `full_state` stored as `pickle`
17:44:06 workflow.py:1925 DEBUG    stored data loaded: /Users/icn2you/Library/Application Support/Alfred/Workflow Data/hue-alfred-workflow/full_state.pickle
17:44:06 workflow.py:2496 ERROR    list indices must be integers or slices, not str
Traceback (most recent call last):
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/libs/workflow/workflow.py", line 2489, in run
    func(self)
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/filters.py", line 464, in main
    items = hue_index_filter.get_items()
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/filters.py", line 106, in get_items
    lights = utils.get_lights()
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/utils.py", line 97, in get_lights
    lights = data['lights']
TypeError: list indices must be integers or slices, not str
17:44:06 workflow.py:2518 DEBUG    ---------- finished in 0.248s ----------
[17:44:06.473] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] {
  "items": [
    {
      "title": "Error in workflow 'Philips Hue Controller'",
      "subtitle": "list indices must be integers or slices, not str",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

Also:

lrwxr-xr-x   1 root   67 Jun  1 14:02 python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3*
icn2you commented 1 year ago

Based on a Stack Overflow post, I attempted to install workflow as follows:

pip3 install workflow

Now I'm getting the following debugging output:

[19:33:24.580] Logging Started...
[19:33:29.793] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Queuing argument ''
[19:33:30.418] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Script with argv '(null)' finished
[19:33:30.423] ERROR: Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Code 1: /Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/libs/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (2.0.3) or chardet (None)/charset_normalizer (2.1.1) doesn't match a supported version!
  warnings.warn(
Traceback (most recent call last):
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/filters.py", line 11, in <module>
    import utils
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.C3E481E9-532C-43DF-B3D9-5ABC4924A852/utils.py", line 17, in <module>
    from workflow import Workflow
ImportError: cannot import name 'Workflow' from 'workflow' (/usr/local/lib/python3.11/site-packages/workflow/__init__.py)

I'm not a python programmer, but I do know JavaScript. I'd appreciate any guidance anyone can offer!

benknight commented 1 year ago

Hey @icn2you sorry I'm not super active about maintaining this plugin anymore.

In the first error it looks like the cache data wasn't the format it was expecting.

Can you try running this command: hue workflow:reset

You don't need to hit enter, just but typing that it should delete the Workflow’s settings, cache and saved data.

icn2you commented 1 year ago

Hi, @benknight!

Thanks for following up with me; I really appreciate it.

So I ran the specified command in Alfred, and now the workflow quickly disappears when I type hue. Following is the log from the debugger:

[23:08:01.230] Logging Started...
[23:08:12.048] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Queuing argument ''
[23:08:12.677] Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Script with argv '(null)' finished
[23:08:12.682] ERROR: Philips Hue Controller[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA%3E024CCF2C-F278-4295-B1AF-CCF8771F79AB)] Code 1: /Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA/libs/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (2.0.3) or chardet (None)/charset_normalizer (2.1.1) doesn't match a supported version!
  warnings.warn(
Traceback (most recent call last):
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA/filters.py", line 11, in <module>
    import utils
  File "/Users/icn2you/Library/Mobile Documents/com~apple~CloudDocs/Backups/Alfred/Alfred.alfredpreferences/workflows/user.workflow.1EF84550-BCAD-4DBA-B9E9-43DA0D5AC7EA/utils.py", line 17, in <module>
    from workflow import Workflow
ImportError: cannot import name 'Workflow' from 'workflow' (/usr/local/lib/python3.11/site-packages/workflow/__init__.py)

Maybe I shouldn't have installed the workflow package as I previously did (pip3 install workflow)?

mschel commented 1 month ago

I actually had the same problem. Even the reset command did bring up the error, so I've deleted the workflow and ran the "Clean Workflow Data" script from Alfred Gallery (https://alfred.app/workflows/alfredapp/clean-workflow-data/). Afterwards re-Installed this workflow and did the setup again. Now all works like a charm again