# Changing variable over time

I would like to be able to change a variable over time.

1. Change the variable from x to y in specified minutes. (Change from 1 to 100 in 60 minutes)
2. Change the variable from x to y from now until specific time. (Change from 1 now to 100 at 12:00)

It might be possible. Then I would like to know how.

At this moment I'm thinking of using a virtual dimmer to steer the variable. That would work for option 1. But for option 2 it will mean that I will have to make another variable with value of minutes before specific hour. I would have to make such a variable for every hour that I would like to use. Not very simple...

Any ideas would be appreciated.

Sometimes it is helpful if you give an example of how you want to use these, as there may be alternative methods to explore.

I want to make a central Color_Temperature_Variable.
I would like to use this so that all my white lights will have the same temperature.
During the day a nice daylight color.
From a combination of illuminance and sunset (which could be anytime between 16:00 and 22:00) to 23:00 I would like to fade to a warm white.

I have a rule now based on illuminance only, but I cannot get it to work like I want. In summer the lights are too warm, which makes them look "old" and in winter it's too flourescent-like cold...

Hey there - did you ever figure this out? Looking to do the same thing for an identical reason, but can't quite figure it out

This is how I do something similar. The basis of the rule uses variable math to calculate the slope and value using basic algebra...

`y=m*x+b` and `m = (y2-y1)/(x2-x1)`

This rule is WAY more complicated than necessary, but i wanted it to be flexible so that I could change the duration, start values, or end values without having to rewrite the rule. So most of these values are local variables.

The 2 main things that apply to your scenario are the slope (ctSlope and levelSlope) calculations and then the final value calculations (ctValue and levelValue).

I can offer more details if you need, but it might be a few days.

OR i just saw this on another thread. Perhaps you could use this action in rule machine to set the color and level of a virtual bulb, then capture those settings into your variables.

Thank you, Dylan! This looks very interesting. I will dive into it and let you know the results!

1 Like

Well, thank you @dylan.c for the foundation rule! I started by copying the rule. I then added StartTime and EndTime variables. I filled in the EndTime variable (10:00).

I added the following to the rule:

Set StartTime to current time
Set durationMin to minutes of difference between StartTime and EndTime

The rest is your rule. I now have the perfect way to set a central variable from warm dimmed to daylight bright. Starting an hour before sunrise and ending at 10:00.

I'm now going to try to translate the whole rule to reverse the process from an hour before sunset to 23:00.

1 Like

Glad you got things working! RM is super powerful once you wrap your head around the logic involved.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.