How do I get devices to adjust to variable changes


#1

1) Give a description of the problem
I have a piston to adjust the brightness and color of my lights based on time of day using variables, I need to make the piston adjust the lights if they are on when the variable changes.
I2) What is the expected behaviour?
The piston works as intended, I just want to refine it, and i’m not sure how to go about getting the expected results.
3) What is happening/not happening?
If the lights are already on when the variable changes the lights do not adjust to the settings that match the new variable. Im guessing i need a way for the lights to poll the variable and adjust to changes, but im not sure.

4) Post a Green Snapshot of the piston

)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)


#2

I am thinking:

IF @global changes            <-- Trigger
Then
    IF @global is 'dawn'      <-- Condition
        Then Set lvl to 45
    END IF
    IF @global is 'daylight'  <-- Condition
        Then Set lvl to 90
    END IF
    IF @global is 'dusk'      <-- Condition
        Then Set lvl to 40
    END IF
END IF

Just be aware, that if the light is off, the “Set level to X” will turn it on.


This variation only adjusts the level if the light is already on.

IF @global changes
Then
    IF @global is 'dawn'
      and
      Light is on
         Then Set lvl to 45
    END IF

    IF @global is 'daylight'
      and
      Light is on
         Then Set lvl to 90
    END IF

    IF @global is 'dusk'
      and
      Light is on
         Then Set lvl to 40
    END IF
END IF

#3

Perhaps a more efficient way would be to tweak your piston “dpchm” above…

Every day at 4AM
    Set @global to dawn
    IF light is on
        Then set level to 45
    END IF
END EVERY

Every day at 31 minutes past sunrise
    Set @global to daylight
    IF light is on
        Then set level to 90
    END IF
END EVERY

Every day at 59 minutes before sunset
    Set @global to dusk
    IF light is on
        Then set level to 40
    END IF
END EVERY

This is less triggers… and less vague conditions


#4

Thanks, I’ll give these a try