JnyJny / blynclight

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

Flash not working #14

Closed robachambers closed 4 years ago

robachambers commented 4 years ago

I am unable to get the flash function to work. When using the Embrava Connect software it will flash properly. Light always remains on and steady

Environment Mac OS 10.15.2 python3

Embrava Blynclight Standard BLYNCUSB40-191

light.flash set to false

Light Status: Device: 0x2c0d:0x000c 0x00ff : red 0x0000 : blue 0x0000 : green 0x0000 : off 0x0000 : dim 0x0000 : flash 0x0000 : speed 0x0000 : music 0x0000 : play 0x0000 : repeat 0x0000 : volume 0x0000 : mute 0x0001 : immediate

light.flash set to true

Light Status: Device: 0x2c0d:0x000c 0x00ff : red 0x0000 : blue 0x0000 : green 0x0000 : off 0x0000 : dim 0x0001 : flash 0x0000 : speed 0x0000 : music 0x0000 : play 0x0000 : repeat 0x0000 : volume 0x0000 : mute 0x0001 : immediate

Attempted to set speed in case this was needed

Light Status: Device: 0x2c0d:0x000c 0x00ff : red 0x0000 : blue 0x0000 : green 0x0000 : off 0x0000 : dim 0x0001 : flash 0x0003 : speed 0x0000 : music 0x0000 : play 0x0000 : repeat 0x0000 : volume 0x0000 : mute 0x0001 : immediate

JnyJny commented 4 years ago

Hey thanks for the bug report, do you have a code snippet that demonstrates what you doing?

My first thought going by the debug output (thank you!) is the speed value isn't set correctly.

Per the docstring for blynclight.BlyncLight:

Command Word Documentation ==========================
The Embrava BlyncLight command word bit fields are:
...
speed : 3 0==off 1==low 2==medium 4==fast
...

To increase the rate of flash you would write:

    light.flash = 1
    light.speed = 0  # off regardless of flash
    light.speed = 1  # slow  (1<<0)
    light.speed = 2  # medium (1<<1)
    light.speed = 4  # fast (1<<2)

The design of the light's control word is... awkward and in this case I let the awkwardness shine through.

If someone were to feel strongly enough, I could see modifying how that setter works so that it accepts monotonically increasing speed values instead of the current bit-mask style values.

Let me know if that solves the problem.

robachambers commented 4 years ago

Sorry that was the issue. I misread the speed setting as 0-4 setting and had set it to 3. Just tested with 1 and it works.

JnyJny commented 4 years ago

Sweet! Glad to hear that it's working for you!