benknight / hue-alfred-workflow

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

Choosing CSS literal always fails on the first try, succeeds on second and color picker doesn't set color #30

Closed adambair closed 7 years ago

adambair commented 7 years ago

First off -- THIS IS AWESOME. I'm a software developer and just took the plunge and setup my house with hue lights... this alfred workflow is going to kick ass :)

That said, I've run into:

which results in

on the first attempt... if I run the exact same command again... the lights change no problem...

benknight commented 7 years ago

@adambair this is because of the delay in script execution that occurs each time you type a character. If you wait a half second or so after typing the color, then press enter, it should work every time. This is a bummer I admit, especially as I'm a fast typer myself. I'll look into fixing this in the next update.

adambair commented 7 years ago

Awesome! Thanks for the easy work around -- I totally get it, not a big deal -- most appreciated. Your Alfred/Hue integration is fantastic.

While I'm not a Python developer, Ruby here:

The Least Surprised

...I'm curious about where the delay is located in the code so I can take a peek (and perhaps take a stab at it myself).

Either way, great work -- thanks!

benknight commented 7 years ago

@adambair See the "hue" script filter.

Each type you type a character it executes:

python -m logic.filters "{query}"

The script outputs the XML that Alfred uses to show results.

So as you're typing "purple" for example, there is a split second where after you type the final "e", the "Set color to" item has its action set to "lights:1:color:purpl", and if you hit enter too soon it will think you entered "purpl" which is invalid. Wait a tick more and it's finally updated to "purple" at which point it works.

I was hoping to get around this issue by tinkering with the "Script Behavior" settings on the "hue" filter, which I currently have as:

image

But none of those configurations seem to help or even apply really. The problem is in the script execution time for the Python filter script.

adambair commented 7 years ago

Sweet!

benknight commented 7 years ago

@adambair in the next version (2.5) I've "fixed" this by making it impossible to hit the enter key until it recognizes that the input is a valid color string.