JnyJny / blynclight

Python bindings for the Embrava BlyncLight family of products.
Apache License 2.0
22 stars 4 forks source link

Control from iOS shortcut application #16

Open mcnahum opened 4 years ago

mcnahum commented 4 years ago

Hi, I'm trying to control blynclight from my iphone with iOS Shortcut Application.

if I run from my Pi on SSH: "/home/pi/.local/bin/blync -r 255 -n -D 3600 &" it's working perfectly if I run the same command from the "Run script over SSH" from the iOS shortcut application, it's working and the light turn red but ... the action does not terminate and stay running... if I manually stop it ... all it's ok ... but I should not have to do it... any idea?

JnyJny commented 4 years ago

I haven't used iOS shortcuts, so my guess is the following:

When the blynclight package finishes a "session" using the light, by default it turns the light off and zeros all the various color values and feature switches. This is to avoid weird behavior when the light is activated again (flashing, bleeps and bloops that the user didn't initiate).

One way to fix the iOS problem is to allow blync to return and leave the light in it's currently configured state (on, shining red). This will lose the ability to run for an interval and then turn off. I guess you could have another action that turns the light off explicitly? Not sure.

Another way to get the desired behavior (iOS action terminates normally, light stays lit red for 1 hour and then turns off) would be to add a 'daemon' switch that would run the command in the background (without requiring the ampersand). The command would run in the background and turn off after an hour while allow the iOS action complete as expected.

mcnahum commented 4 years ago

I tired a lot of options, including a simple "/home/pi/.local/bin/blync -r 255" or even "/home/pi/.local/bin/rainbow" and it's the same... really strange ... I also tried to embed the command in a shell script but it's the same...

"/home/pi/.local/bin/blync -a" is working correctly and give the proper output

So yes a daemon could be a solution, it start and run for 1 hour ( or the parameter I could pass) ... I will have to look this week-end how I can do

JnyJny commented 4 years ago

The latest version (0.7.1) has an updated driver script that may do some of what you are looking for; now when the blync tool exits, it DOES NOT clear the state of the light (turning it off and zeroing all the commands issued while the script was running). So maybe now you can get some of the features to work via the iOS Shortcut application:

$ ssh <yourhost> blync  # will turn the light on with a green color and the light stays on.
$ ssh <yourhost> blync --off. # turns the light off

Effects that constantly update the state of the light will continue to disappoint I think; e.g. fli, throbber and rainbow.

Having those sorts of effects persist after a script runs will probably need a client/server architecture that sounds like fun to write, but I don't have plans to do it soon. I hope some of this helps.

Edit:

Created an iOS ssh shortcut that worked. After installing blynclight, had to use the full path to blync in order for it to work: /usr/local/bin/blync in my case.