Jump to content

Program to run only when device first turns on


kegacide

Recommended Posts

Posted

Sorry this may be a newbie question, but I am a newbie to this automation fun stuff.

 

My first program controls certain lights when I turn my TV on, including my dining room light. BUT I only want it to turn off that light when the TV first turns on, that way if that light is still actually needed (like there are guests there), it can be turned on by the physical switch. The current program I created checks if the TV is on and runs the program which turns off the light, and therefore keeps it off regardless of switch the entire time the TV is on. I want a way to run it only when the TV is turning on, not maintained the whole time it is on, can I do that?

 

I am posting this from work, so I can't play with it right now (didn't turn on internet access yet), but the only thing I just thought about is disabling the program after the program runs, then when the TV is turned back off, reenabling the program. Is it possible to disable a program inside its own THEN statement?

 

Thanks for the help, and I tried searching for this, but wasn't able to find the right commands to search for to get answers.

Posted

You could use a variable.

 

I think this should do it, but it might have some bugs as I haven't fully vetted it.

 

If

status Light is off

and control tv is switched on

Then

set light on

set $tvlight to 1

Else

. . .

 

If

$tvlight = 1

and Control tv is switched off

Then

set light off

set $tvlight = 0

Else

- --

Posted
You could use a variable.

 

I think this should do it, but it might have some bugs as I haven't fully vetted it.

 

If

status Light is off

and control tv is switched on

Then

set light on

set $tvlight to 1

Else

. . .

 

If

$tvlight = 1

and Control tv is switched off

Then

set light off

set $tvlight = 0

Else

- --

 

Thanks, but this is basically exactly what I have. My problem is the switched on/switched off commands. How do I do that? I use control TV "on" or control TV "off", so the entire time the TV is on it is running the program. I want the program to only be run 1 time when the TV is first turned on, then even while the TV is still on I can manipulate those lights anyway I want because the program ran and is done.

 

So i want the program to only run when the TV is first switched on, not the entire time it is on, how do I do that?

Posted

Actually think I found it in the Wiki

 

Control 'node' is switched On

When you use 'Control' you are testing for how it was turned on, eg. On, Fast On, Off, Fast Off etc. You see the word 'switched' to emphasize that.

If the action listened for occurs (eg. Fast On) then this condition activates the program (causes program to run either then or else path).

 

Status 'node' is On

When you use 'Status' you are testing for its current brightness level.

If the status changes then this condition activates the program (causes program to run either then or else path).

 

I think I was trying the status node, but need to use the control node? i'll have to give it a shot tonight.

Posted

Programs do not "run the entire time". The program only runs when it is triggered and then it is done.

 

This program will trigger on any change in the light status, but that will always cause a false, which is blank, so it is meaningless.

 

The important point is the program will also trigger when the tv is turned on (incidentally, I don't know what you are using to turn your tv on, and this could be important). And then, it will only run tru if the light is off.

 

The jist of this, is that the second program will only run true (and turn the light off) if it was the act of turning the tv on that caused the light to turn on in the first place. If the light was already on when you turned the tv on, the second program won't run when you turn the tv off and the light will staff on, because the variable would never have been set to 1.

Posted

Maybe i'm not being clear, let me start over. My goal is to turn off my dining room light when I turn on my TV because i get a bad glare (plasma TV issue) as the dining room light is directly behind the TV.

 

My devices are as follows:

TV (using a synchrolinc)

Dining Room Light

Den Lamp

 

Here is my program (the gist of it because i'm doing this off of memory):

If:

status TV= on

AND

status Dining Room Light = on

 

Then:

set status Dining Room Light = off

set status Den Lamp = on

$DR = 1

 

I then use the $DR variable to turn the light back on when the TV turns off in a different program, but that's not the issue.

 

So when i turn on the TV my dining room light turns off, den light on, all is great in the world. BUT my issue is that while the TV is still on, say my wife needs to turn on the dining room light. When she turns that light on, it runs the program again because TV and Dining Room Light = on both become true again, and it turns it right off.

 

So what I need is a way that when I turn on the TV it runs this program and turns off the dining room light, but if need be (say there is company over) that dining room light can be turned back on without the program then running again to turn it off.

 

Thats why i was hoping I could find something instead of

If:

TV = on

AND

Dining Room Light = on

 

There was something like

if:

TV status changes from off to on

AND

Dining Room Light = on

 

That way it only runs the program when the TV is first turned on, then if the dining room light needs to be turned on while the TV is turned on, the program wont turn it back off again.

Posted

Use "if Control" rather than "If Status"

 

If

Control "TV" is switched On

AND

status Dining Room Light = on

 

Then:

set status Dining Room Light = off

set status Den Lamp = on

$DR = 1

Posted
Use "if Control" rather than "If Status"

 

If

Control "TV" is switched On

AND

status Dining Room Light = on

 

Then:

set status Dining Room Light = off

set status Den Lamp = on

$DR = 1

 

Thanks LeeG, i'm going to try it this evening.

 

Figured it had to be some setting to control just when a device is first switched on/off.

Posted

That way it only runs the program when the TV is first turned on, then if the dining room light needs to be turned on while the TV is turned on, the program wont turn it back off again.

 

That is why I used "control is switched on" for your tv. It will only be true when the tv is switched from off to on (at least with a synchrolinc).

 

I misunderstood on the light on/off, thought you wanted the light to turn on with the tv, not off. So swap on for off and vice-versa on the lights. Be aware, that for "if status is on" you might instead say "if status is not off" since "not off" encompasses all the dimmed states whereas "on" means 100% only.

Posted

That way it only runs the program when the TV is first turned on, then if the dining room light needs to be turned on while the TV is turned on, the program wont turn it back off again.

 

That is why I used "control is switched on" for your tv. It will only be true when the tv is switched from off to on (at least with a synchrolinc).

 

I misunderstood on the light on/off, thought you wanted the light to turn on with the tv, not off. So swap on for off and vice-versa on the lights. Be aware, that for "if status is on" you might instead say "if status is not off" since "not off" encompasses all the dimmed states whereas "on" means 100% only.

 

Thanks, yeah I use not off, but just simplified for the point of describing my situation.

Guest
This topic is now closed to further replies.

×
×
  • Create New...