Premise Fun and games with Momentary Booleans.

Motorola Premise

123

Senior Member
A Boolean property is either True or False. A momentary Boolean property is normally False and can maintain a True state for a brief moment. It is frequently used for devices like motion detectors and security zones. It can also be used to activate a function similarly to an "OK" button.

When performing a backup, Premise does not save the state of momentary Booleans. There's no need to record the state of something that is normally False (and True for a mere moment in time).

I encountered a unique situation where the state ought to be recorded. My RampDimmerEx module adds new functionality to existing Light objects. It allows you to ramp a lights's brightness over a long period of time (hours). It uses a momentary Boolean called RampPlay to initiate the ramping operation.

You can use this new functionality in Scenes and that's where things get interesting. In a Scene, you set RampPlay to True and it stays True. It doesn't immediately flip back to False because momentary Booleans behave like regular Booleans when used in a Scene.

When the Scene executes it will start ramping the light because RampPlay=True. Well, it is True only if Premise Server is never restarted! Being a momentary Boolean, RampPlay's state is not saved. When Premise restarts, RampPlay's state is False (the default state of a momentary Boolean) and the light is no longer dimmed when the Scene executes.

It is possible that no one anticipated the use of momentary Booleans in a Scene. To circumvent this little glitch, I added a simple script that executes upon startup. In a nutshell, it finds all Lights in all Scenes, confirms they have a RampPlay property, and then sets it to True.

Code:
' Enable the RampPlay property for each Lighting device in a Scene
' The state of a momentary boolean property is not saved during a backup.

for each oScene in sys.GetObjectsByType(Schema.System.Scene.Path) ' Get all Scenes
	for each oLight in oScene.GetObjectsByType(Schema.Device.Lighting.Lighting.Path) ' Get all Lights in the Scene
		set oCheck= oLight.FindClassProperty("RampPlay") ' Check if the Light has a RampPlay property
		if not oCheck is nothing then oLight.RampPlay = True ' Set RampPlay to True
	next
next
 
Back
Top