I started out with the Occupancy and Automatic Lights module from the help file and have slowly been adding/modifying to make the automatic on/off/dim a bit less harsh and more of a seamless experience.
Below is code for an Automatic Off function that works as a house keeping type task, turning off lights in rooms that have been unoccupied for a specified amount of time.
Rather than turn the lights completely off immediately, I want to dim them to a low level (0.15) and then have them turn off one minute later. The code below throws a "unsupported method" error when the timer expires. Any thoughts? I know I'm probably missing something obvious with the expression. Eventually I want to have it dial down over a specific period using multiple timers.
Below is code for an Automatic Off function that works as a house keeping type task, turning off lights in rooms that have been unoccupied for a specified amount of time.
Rather than turn the lights completely off immediately, I want to dim them to a low level (0.15) and then have them turn off one minute later. The code below throws a "unsupported method" error when the timer expires. Any thoughts? I know I'm probably missing something obvious with the expression. Eventually I want to have it dial down over a specific period using multiple timers.
Code:
ElseIf this.AutomaticOff = True Then
debugout "OnChangeOccupancy(): Automatic Off"
If sysevent.newVal = False Then
For Each obj In this.GetObjectsByType(Schema.Device.Lighting.Lighting.Path, False)
If SupportsMember(obj, "Brightness") Then
debugout "OnchangeOccupancy(): Set Brightness=0"
obj.Brightness = 0.15
addTimer 60, "obj.Brightness = 0", 1, this.ObjectID
Else
debugout "OnchangeOccupancy(): Set Powerstate=0"
obj.PowerState = 0
End If
Next
End If
End If