- Set Dimmer Level
- Ramp to Level with Duration
- Get Light Level
- Get Light State
It's a work in progress. I thought I'd upload the code that I have so far. Ideally, I'd like to make a Python module. My apologies in advance for any formatting errors.
Usage:
In a previous post, I showed how to get the device IDs. If you run that script, you should obtain output similar to this:
Output:
...
276, Kitchen Main Cans264, Family Ceiling Cans Dim.
...
Functions:
Below are some example uses for the functions.
setLevel(276, 1) # Sets Kitchen Main CanssetLevel(264, 50) # Sets Family Ceiling lights to 50%
time.sleep(3) # Wait 3 seconds
rampToLevel(264, 0, 3000) # Ramp ceiling lights to 0% over 3 seconds
print getLevel(264) # Outputs light intensity
print getLightState(276) # Outputs light state
An important thing to add is the use of the getLevel and getLightState functions. The getLevel function only works with dimmer switches. In the future. I'll add error checking to make it work for normal switches too. To get information about toggle switches use the getLightState function. It will either return 1 or 0 for on and off, respectively. getLightState works for dimmers, too.
When I find some time, I'll implement arguments so the scripts can be called with IDs and values in a console.
Script:
The script is on my git repo, lightsControl.py: