webdjoe / pyvesync

pyvesync is a python library to manage Etekcity & Levoit smart devices
MIT License
168 stars 77 forks source link

Lighbulb not turning ON when setting brightness [regression] #184

Closed sdrapha closed 1 year ago

sdrapha commented 1 year ago

With the code of the master branch, as of today,(not sure about last Pypi, didn't check) we can't turn on a lightbulb by setting it's brightness level, if the brightness level is the same as before, EVEN when the light bulb is currently OFF.

This is a regression from the latest refactoring, this used to work in the past.

Steps to reproduce:

# setting up
from pyvesync import VeSync
mg = VeSync("###redacted_email###", "###redacted_secret###", "###region###", debug=False) 
mg.login()
mg.update()
mb0 = mg.bulbs[0]
mb0
mg.debug = True

#actual steps to reproduce issue
mb0.set_brightness(100)
mb0.turn_off()
mb0.set_brightness(100)
# here, the bulb will stay OFF when it shouldn't, no API call is made
sdrapha commented 1 year ago

I found the offending lines of code. And there is similar broken logic for color_temperature and rgb changes as well for differnet bulbs. I'll do a PR to fix those this Sunday if I am able to find some time.