Jump to content

How to remember last setting for lights


Recommended Posts

Posted

I have several programs that change the lighting throughout the day. Here's an example. It sets the color, brightness, and a 9 min fade from the last setting. That way if the light is already on, there is a gradual transition to the new settings.

Kaz's Ceiling Light HSBKD Day - [ID 000F][Parent 000C]

If
        From    Sunrise +  1 second
        To      Sunset  + 30 minutes (same day)
 
Then
        Set 'Kaz's Bedroom / Kaz's Ceiling Lights / LIFX Group Bedroom'  Hue 58000 Saturation 0 Brightness 65535 Color Temp 6000° K in 540000 ms
        $s.Kaz.Light.Last.Setting  = 1
 
Else
   - No Actions - (To add one, press 'Action')

As nap time approaches and  bluer light can help avoid that dragging feeling starting around 2pm till about 5pm I again change the color and brightness; this time towards blue and about 75% full brightness. Then again around sunset it changes into a more orangeish dimmer value for evening and finally into a dim red (submariner lighting)as a night light after everyone is in bed. You know, just in case I need to use the bathroom 6 times before sunrise. ?‍♂️

The last program I have involved in all this is an override that turns the lights on full brightness for things like the fire alarm going off, or if I just need really really bright light in the room for something I'm doing. I do this via a fast on / fast off (double tap, yes that's rule #2)

The problem is after a fast on I have no way of returning the light back to it's previous setting based upon time of day. Here's the override program.

 

Kaz's Ceiling Light HSBKD Full Brightness - [ID 003C][Parent 000C]

If
        'Kaz's Bedroom / Kaz's 6-Button KeyPad / Kaz's Fan KeyPad LIGHT(1)' is switched Fast On
    And 'Guest Room / Guest 6-Button KeyPad / Guest Fan KeyPad Light(1)' Status is 100%
 
Then
        Set 'Kaz's Bedroom / Kaz's Ceiling Lights / LIFX Group Bedroom'  Hue 58000 Saturation 0 Brightness 65535 Color Temp 9000° K in 1000 ms
        Set 'Kaz's Bedroom / Kaz's Ceiling Lights / LIFX Group Bedroom' On
 
Else
   - No Actions - (To add one, press 'Action')

 

So how do I recall the previous setting on the next press of the ON button?

Posted (edited)

You might write a program (Program1) that only writes the HSBKD settings to integer variables every couple of minutes, then, when you tap a fast on, run another program (Program2) that disables the first program (Program1) and sets your lights how you want them.  Then, when you tap the on button, you could have another program (Program3) read in the values from the variables into the HSBKD settings and re-enable the first program (Program1), continuing where you left off?  That's the easiest way I can think of. 

There's probably a better way, but I think you could make this work and not have it become too complex.  I doubt that writing values to integer variables every few minutes would add much processing overhead to your Polisy.

Edited by Bumbershoot
  • Like 1
  • Thanks 1
Posted

I control most of my major lighting with state variables. When I override their setting to "borrow" the light/s I copy the variable to another variable until I am done with the light and just copy the second variable back to the controlling state variable again.

 

  • Thanks 1
Posted

@larryllix I started to try something like that and got side tracked. I wanted to run it by you guys before I started up on it again and make sure I was on the right track. Between you and @Bumbershoot I've got some good thoughts on what to do. Thank you!

Posted

I am away from my office computer but if memory serves isn't there a PG3 node server called backup the does something like that?

  • Thanks 1
Posted
2 hours ago, kzboray said:

@larryllix I started to try something like that and got side tracked. I wanted to run it by you guys before I started up on it again and make sure I was on the right track. Between you and @Bumbershoot I've got some good thoughts on what to do. Thank you!

Ohh yeah... One thing I always do when I write a value to a State Variable that controls devices...I write a -1 value before the final value. That way no programs based on the State Variable will be triggered by the extraneous value, and it guarantees the programs that control the lighting/device will actually trigger. You could have some lights that you "borrowed' with the same value in the State Variable and writing the same value will not trigger the program to do it's job. The -1 value guarantees it triggers.

Another note... if you have a bank of programs all based on a State Variable as a trigger. (eg. 0,1,2,3 = Off, low, med, high) cannot have any Else code or else they will trigger with other values.

Sample programs
If
    $sLampLevel = 3
Then
     set lamp to 100%
Else
   ---   <----- do not use

.....
If
    $sLampLevel = 0
Then
      set Lamp Off
Else
   --- <----- do not use

 

Program Borrow Lamp
If
     ----?
Then
    set $LampLevel.saved = $sLampLevel
    set Lamp to xxx %
    Wait 5 minutes
    set $sLampLevel = -1 (I use a constant named $cMODE.RESET) <---- ensure it changes value to trigger
    set $sLampLevel = $LampLevel.saved
Else
    ----

  • Thanks 1
Posted
14 hours ago, TJF1960 said:

I am away from my office computer but if memory serves isn't there a PG3 node server called backup the does something like that?

Yes, but it backs up all lighting type devices and restores all lighting type devices.   You can't work with just a subset of devices.  Although that would be a nice enhancement.

  • Like 1
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37.2k
    • Total Posts
      372.4k
×
×
  • Create New...