Jump to content

Adjusting On Level Of Switches Using Variables


DualBandAid
Go to solution Solved by Bumbershoot,

Recommended Posts

10 hours ago, DualBandAid said:

I'm new to variables. Is there any way I could substitute this 100% for a variable, so if I change my mind and want it to be 90%, I don't have to change each item individually?

Thx!

 

image.png.ca6242baa8d449454ad7c6ef060c2c8c.png

Easily done,  Here's an example (all the 'sld* devices are Insteon SwitchLinc Dimmers):

KitchenLights - [ID 0077][Parent 000A]

If
        $s.KitchenLights is not 1000
 
Then
        Set 'Devices / dirKitchen / sldKitchenSink' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldDining' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldKitchenIslandSouth' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldKitchenIslandNorth' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldTrackLightSouth' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldTrackLightNorth' On '$s.KitchenLights %'
        Set 'Devices / dirKitchen / sldUnderCounter' On '$s.KitchenLights %'
 
Else
   - No Actions - (To add one, press 'Action')
 
This program is used to interface with Alexa, and uses a STATE variable ($s.KitchenLights) to set a brightness value for the lights in the kitchen. 
"Alexa, set the kitchen lights to 50" will set the STATE variable to 50, which causes this program to run.

 

  • Like 1
Link to comment

Thank you for the response!

 

I guess the problem I’m having, I get the concept. But it is the minutia details in the steps to get that concept to work that I don’t know or I’m not familiar with. For example, I know I need a variable name in the percentage box that comes after the “on” box.

Youhave:

'$s.KitchenLights %'

But all that is there for me is the option to go from one percent to 100%. I don’t know how to declare this variable exists, and then I don’t know how to get it in that percentage box. If that makes sense

Edited by DualBandAid
Link to comment
  • Solution
41 minutes ago, DualBandAid said:

Thank you for the response!

 

I guess the problem I’m having, I get the concept. But it is the minutia details in the steps to get that concept to work that I don’t know or I’m not familiar with. For example, I know I need a variable name in the percentage box that comes after the “on” box.

Youhave:

'$s.KitchenLights %'

But all that is there for me is the option to go from one percent to 100%. I don’t know how to declare this variable exists, and then I don’t know how to get it in that percentage box. If that makes sense

You don't have to declare anything.  Just create the variable (in this case, $s.KitchenLights is a state variable, which is why I prefix the name with the 's' - If it were an integer variable, I would have named it 'i.KitchenLights').

Once you've created the variable, it's available to use in programs.  You have to select the ">" symbol in the AC program interface to select the % or variable you want to use.  See screenshot:

 

Screenshot 2023-11-04 at 12.38.41 PM.png

Link to comment

Yep! That’s exactly what I want!

Quote

You don't have to declare anything.  Just create the variable

I may have used the wrong term. I meant create. I was just trying to sound cool. And then just exposed my ignorance. I’m not at my computer now but I think I can figure it out from here. That variable section thingee in the interface. I had tried a few times to create a variable - but it never showed up anywhere. But I think I created an integer variable. Maybe that was the problem. 

You may have answered this already, but why exactly do you have that particular “if” condition? And why does the number go up to 1000? They aren’t in intervals of 1 to 100?

Link to comment
1 hour ago, DualBandAid said:

Yep! That’s exactly what I want!

I may have used the wrong term. I meant create. I was just trying to sound cool. And then just exposed my ignorance. I’m not at my computer now but I think I can figure it out from here. That variable section thingee in the interface. I had tried a few times to create a variable - but it never showed up anywhere. But I think I created an integer variable. Maybe that was the problem. 

You may have answered this already, but why exactly do you have that particular “if” condition? And why does the number go up to 1000? They aren’t in intervals of 1 to 100?

He uses 1000 because he knows the value will never hit that number.

However, everytime the variable changes the If section will call attention to the executive of the IoX operating system to evaluate the expression again. If the value evaluated is less than 1000, his program will run.

It's a cheap way of saying " Watch this variable and if anything changes...."

Link to comment
1 hour ago, DualBandAid said:

You may have answered this already, but why exactly do you have that particular “if” condition? And why does the number go up to 1000? They aren’t in intervals of 1 to 100?

I use 1000 because I'm never going to set the variable's value to 1000, which means the program will run every time the value is set to any other number.  The only possible numbers for the program to work are 0-100, which corresponds to a % on value for the Insteon dimmers.

EDIT: FWIW, this program is called from an Alexa routine that sets the value of the state variable (s.KitchenLights) to a spoken value, i.e., "Alexa, set the kitchen lights to 45", and the devices in the program change to a 45% on value.  The routine is called "kitchen lights"...  Works like a charm.

Edited by Bumbershoot
Link to comment

What’s the use case here with Alexa?  

By that, I mean, if I want my lights to be at 45%, I just tell Alexa to set the lights at 45% without any need for a program. 
 

Or are you saying that you use Alexa to change the value of a local press of the switch? What do you use that for? I generally just have my local value change as the time of day changes, on a consistent basis. With no need to use Alexa to change the local value of the on button. 
 

If I’m going to use Alexa with my mouth, to change the on value, I would just use my mouth Alexa combo to turn the light on to a desired value. 
 

The only time I could see this being valuable is if I am, for whatever reason, having to constantly change the value of the local switch on an unpredictable basis. 

Link to comment
9 hours ago, DualBandAid said:

What’s the use case here with Alexa?  

By that, I mean, if I want my lights to be at 45%, I just tell Alexa to set the lights at 45% without any need for a program. 
 

Or are you saying that you use Alexa to change the value of a local press of the switch? What do you use that for? I generally just have my local value change as the time of day changes, on a consistent basis. With no need to use Alexa to change the local value of the on button. 
 

If I’m going to use Alexa with my mouth, to change the on value, I would just use my mouth Alexa combo to turn the light on to a desired value. 
 

The only time I could see this being valuable is if I am, for whatever reason, having to constantly change the value of the local switch on an unpredictable basis. 

Alexa cannot control Insteon devices directly or many other devices directly.

Controlling a program gives much more control. Some of my lights are set at 50% of the value while some are set at 100%. Some are set using more Cold White LEDs and later changed to Warm White LEDs. This cannot be done using Alexa alone.


What happens when the Alexa server is down? I can still control my lights with Insteon keypads, switchLincs and Insteon remotes.

With an ISY program I can also change the time my lights go out depending on day of the week, when I go to bed, get up, or the weather outside. Alexa has no intelligence, only timers and basic factors.

Link to comment
11 hours ago, DualBandAid said:

Or are you saying that you use Alexa to change the value of a local press of the switch? What do you use that for?

In our home, we find that the right level of lighting really makes the house much more pleasant, and being able to adjust a variety of dimmer switches without having to fiddle with each one really improves the usability of the house.

We change the 'on' values of the kitchen lights based on activity, time, ambient light, etc.  We don't even need to physically touch the switch.  Preparing meals in the evening means we have the lights on brighter, around 80%.  After dinner clean up and they go somewhat dimmer, maybe to 45%.  Making coffee early in the morning, they're dimmer still.  We can turn them on/off or to a particular percentage just by asking Alexa and not having to touch the switches (there are several that in combination light up our kitchen).  The same goes for our living room, primary bedroom, etc., where the switches are much more inconveniently located around the rooms (which is the reason I started with home automation in the first place).

BTW, this functionality has a high WAF (wife approval factor).

Link to comment

I use variables to automatically adjust lighting in our apartment also. I have one command preset

Alexa... turn on TV lights

that starts with most lights on 100% cold white and some lamps, visible to our eyes, while watching TV about 50% of that brightness level. At select times, ISY dims these 10 lamps and slowly changes the colours to warm white until about 11:00 PM.

We have found with the slow dimming and colour changing of the lights, we tend to go to bed much earlier than before the auto-dimming, and typically feel better in the morning.

If at any time somebody wants to do crafts or read where more intensive light is required, we have another vocal command

  Alexa....  turn on craft lamps!

that turns on two much taller lamps with spot lighting shining down from behind our chairs and also brightens two other lamps that sit on the sides of the same chairs in question. When the crafts lamps off command is spoken, the lighting is resumed where it was found before. It is easy to remember one variable value and restore it when done borrowing the lighting.

I don't use variables quite the same as @Bumbershoot does but rather as presets for programs that create scenes. Since most of my lighting is WiFi controlled these are not Insteon scenes but rather combinations of protocols to achieve these lighting scenes.

My vocals control programs that change variables and banks of programs watch those variables to set levels of many lamps, RGBWW strips and bulbs.

ISY is your friend. I use it for it's advanced logic.

Edited by larryllix
Link to comment

I def have been using ISY to control the level of dim at all my switches. I just find that it's a *constant* change.

SUN-UP: 100%

SUN-DOWN: 70%

LATE EVENING (SUN DOWN +3 hours): 40%

LATE NIGHT (after 11): 20%

I have an ISY program that changes the on switches for all these. But this confused me:

Quote

i.e., "Alexa, set the kitchen lights to 45", and the devices in the program change to a 45% on value.  The routine is called "kitchen lights"...  Works like a charm.

If I want to change my lights outside of my program, I just tell Alexa to change the lights directly "Alexa, set [group] to 45%". But my program is still running. But it sounds like you are telling Alexa to change the program itself that controls the lights? Are you finding the % that you set up in the program needs to be tweak that often?

Edited by DualBandAid
Link to comment
On 11/4/2023 at 2:17 PM, larryllix said:

He uses 1000 because he knows the value will never hit that number.

However, everytime the variable changes the If section will call attention to the executive of the IoX operating system to evaluate the expression again. If the value evaluated is less than 1000, his program will run.

It's a cheap way of saying " Watch this variable and if anything changes...."

I may be doing the same thing differently, or I'm missing some opportunity with what you are doing. My "If" section has a time frame on it:

Screenshot 2023-11-05 at 5.28.13 PM.png

Screenshot 2023-11-05 at 5.28.17 PM.png

Edited by DualBandAid
Link to comment
10 hours ago, larryllix said:

At select times, ISY dims these 10 lamps

I had something like that set up at my old place but I had programmed it, like 9 years ago...and I wonder if A) I was doing it clunky to begin with and B ) if there is a more elegant way now. It sure is a lot easier to change the LOCAL ON level at the switch than it was a decade ago.

The way I'm thinking, I need to determine if a light is on? And then, if so, change the ramp rate to the max (9 min?) and then ramp down from it's current level down to a lower level? Is that the right way to think of it? Or do I have make scenes for every light? And then adjust the scene?

Edited by DualBandAid
Link to comment
3 hours ago, DualBandAid said:

But my program is still running. But it sounds like you are telling Alexa to change the program itself that controls the lights? Are you finding the % that you set up in the program needs to be tweak that often?

I have a program that sets the kitchen lights to a low "on" level early in the morning (4:30am).  When I ask Alexa to modify the on level when I make coffee doesn't have any affect on the program at all.  The program is set to run at a specific time, and once that happens, the program is done for the day.  What I do subsequently doesn't matter to the program I use.  When I tell Alexa to set the light to a different value, the program doesn't execute.

The difference between scenes and programs is that scenes change the lights in the scene in parallel (all at the same time), and programs change the lights in the program in series (one after the other).  Scenes are much more elegant to use, but programs are easier to create and manage IMHO.  It just depends on your use case.

I hope I'm not misunderstanding your question.

EDIT: BTW, Alexa can initiate both programs and scenes.  A great parlor trick is when we have company over for dinner, and I say, "Alexa, turn on dinner", and the lights in the house all turn to set values (a scene), then a music station plays on the Sonos node server (the next line in the program that turns on the scene).  It's almost too easy...

EDIT2:  If you want to run a program that adjusts a scene, then Alexa will do it for you.  In the program, you could run "adjust scene", wait a few seconds, then run the scene with the adjusted values.

Edited by Bumbershoot
  • Like 1
Link to comment
On 11/5/2023 at 6:45 AM, larryllix said:

At select times, ISY dims these 10 lamps and slowly changes the colours to warm white until about 11:00 PM.

How do you do this? With a scene? A scene with a slow ramp rate that dims to a certain level?

And do you need an if statement to verify the light is on the first place? And then you need one for every light?

Link to comment
23 hours ago, DualBandAid said:

How do you do this? With a scene? A scene with a slow ramp rate that dims to a certain level?

And do you need an if statement to verify the light is on the first place? And then you need one for every light?

Basically you don't. I avoid most Insteon scenes for several reasons. Programs give so much more control and most of my lights are WiFi bulbs. I don;t use ramping as the bulbs only contain one fast ramp...about 1.5 seconds.

Lights do not need to verified if they are on. When you turn the bulb on, it doesn;t matter what state it was in before.

With my software I load up to ten variables with values of the bulbs, that just happen to to be the last octet of their IP addresses,  the level parameters for colour, RGB Level, WW level, and CW level, and then run one NR to send the commands to my software inside my polisy. That software sets the list of bulbs up to the levels and then turns them all on at in rapid sequence so it appears they are completely synchronised to the human eye.

ISY control whatver goup/scene it wants dynamically with no preset configurations.

Link to comment

Ah. I see I maybe have misunderstood what you meant by:

Quote

"At select times, ISY dims these 10 lamps"

I thought you meant that if, say a light is on, you slowly would dim the light down to the lowered setting. I had a set-up like that. If, say, my living room lights were on, they would slowly dim over the course of 9 minutes to the evening light. I wouldn't even notice the dimming.

Quote

Lights do not need to verified if they are on. When you turn the bulb on, it doesn;t matter what state it was in before.

In the case I was talking about (and thought you were talking about) whether the lights were on was important. Think of it this way.

Light is on 100%. Program starts...

1) Ramp rate is changed to 9 minutes

2) Light is slowly dimmed down to 50%

If my light is NOT on, I don't want this program to run at all. If it runs, the light will turn on and start dimming, right?

The reason I used a scene for this was, if I changed the switch's ramp rate for this event, anyone trying to use the switch to override the current light change would have a ramp rate of 9 minutes.

But lemme ask you something else. Let's say I don't worry about the ramp rate.

Light is on 100%. Program starts...

1) Light is dimmed to 50% at 7:00 pm

But I don't want that change to happen if the light is off, do I?

Quote

That software sets the list of bulbs up to the levels and then turns them all on

Summarizing: I am already set on how to change the local on levels. Light is on or off, doesn't matter. It just changes what happens at the switch. But what if I want a light that is ON ALREADY to dim to a lower level, but if the light is NOT on, I don't want anything to happen. What then?

Link to comment

I have found for my application on my main level that scenes work much faster and more efficient. Downside, is you cant easily ask a scene to dim etc. 

Roughly thirty lights are included in the scenes, insteon, hues and kasa.

Scenes include: evening, mood, dim, nightlight, dinner, supper, cooking etc. 

Alexa is the initiator that either runs the scene directly or in the case of dinner or supper, first plays music and then an ISY program that turns on the right music zone to the right volume (russound NS) and turns on the scene. 

I do have a few programs to control these for all on / all off, but they are significantly slower to turn all the lights on / off etc. 

Each light can also be accessed via Alexa separately  so if someone desires the island cans to be brighter they can easily do that independent of the preset scenes. 

The nice thing about this is that while watching tv in an adjoining room, Alexa can trigger programs that set scenes in that room while also dimming the lights in the rest of the area simply by calling one of the above scenes. 

Link to comment
Guest
This topic is now closed to further replies.

×
×
  • Create New...