Jump to content

Program writing help needed


cmerlino

Recommended Posts

Posted

Hi All,

Sorry in advance for the long post.

I've been puzzling over this for a while now and could use some direction.

 

I have a mix of Insteon and x10, + Elk M1G

There are 4 outside lights - all x10 switches (O1-O4), and programs to turn them on at sunset, all but one off at bedtime, and the last one off at sunrise.

Just added a driveway sensor to the Elk, and I need the following:

 

If it is dark, and the driveway sensor is triggered, turn on any outside lights that are not already on for 30 minutes. If the outside lights are on, do not turn them off until the later of "regular turn off time" or 30 minutes.

 

I have up to 5 spare buttons on a KPL, so I thought that could be a mechanism for communication from the Elk, create a scene with KPL-H, and have Elk turn on the scene when the driveway is triggered, and turn off the scene 30 minutes later.

 

Now is the part where I get lost....

 

I can't wrap my head around the programming constructs.

 

Why "control if kpl-g is switched on AND CONTROL KPL-G IS NOT SWITCHED OFF"?

What is the difference (when should you use) "if CONTROL" vs. "if STATUS"??

Can I indeed switch the KPL-H scene from the Elk???

 

I've read a lot of code snippets from the forum, and while I can read them clearly and understand how they work, just can't get into my (thick) head why they are written the way they are. I know there is a reason, but....

 

Sorry if these questions are repeats (I'm sure they are), but I can't find the relevant posts.

I have included the 3 relevant programs below for reference, but any direction is greatly appreciated.....

THANKS!

 

 

Program - Evening

If

Time is Sunset - 15 minutes

Then

Set 'Living Room Ceiling' 35%

Set 'Dining Room Ceiling' 35%

Set Scene 'Fan Lady' On

Set 'Master Bedroom Nightstands' 35%

Set 'Media Room Lamp' 50%

Set Scene 'Kitchen Cabinet Blue LED' On

Send X10 'O1/On (3)'

Send X10 'O2/On (3)'

Send X10 'O3/On (3)'

Send X10 'O4/On (3)'

Else

- No Actions - (To add one, press 'Action')

 

 

Program - Morning

If

Time is Sunrise - 30 minutes

Then

Send X10 'O1/Off (11)'

Send X10 'O2/Off (11)'

Send X10 'O3/Off (11)'

Send X10 'O4/Off (11)'

Else

- No Actions - (To add one, press 'Action')

 

 

Program Nightime

If

On Sun, Mon, Tue, Wed, Thu

Time is 11:45:00PM

Or On Sat, Sun

Time is 1:00:00AM

Then

Set 'Living Room Ceiling' Off

Set Scene 'Media Room Lamp' Off

Set 'Dining Room Ceiling' Off

Set 'Dining Room Sconces' Off

Send X10 'O1/Off (11)'

Send X10 'O3/Off (11)'

Send X10 'O4/Off (11)'

Else

- No Actions - (To add one, press 'Action')

Posted

cmerlino

 

Cannot help with ELK in any way but can provide insight into some of the questions.

 

†Why "control if kpl-g is switched on AND CONTROL KPL-G IS NOT SWITCHED OFF"? “

 

The first half of If causes the Program to trigger whenever an On command is received. The condition will be True so the Then clause will run. The second half of the If causes the Program to trigger whenever an Off command is received. Because of the NOT the condition will be false so the Else clause will run.

 

In summry, KPL button G On runs the Then clause, KPL button G Off runs the Else clause.

 

 

“What is the difference (when should you use) "if CONTROL" vs. "if STATUS"?? “

 

If Control On triggers whenever the On command is received. If the On paddle is pressed 3 times in a row the Program is triggered 3 times.

 

If Status On triggers only when the status changes and the status matches the If condition. If the On paddle is pressed 3 times (assuming the device was Off to start) the Program would trigger only once. When the status changed and the new status is On. The second and third On command do not change the status as it is already On and do not trigger the Program.

 

Hope this helps a little. Repost these areas if not clear.

 

EDIT: KPL button H must be controlled with a Scene. Secondary KPL buttons cannot be turned On/Off with device Direct commands. Do not know ELK capability to run an ISY Scene. I think it can but do not know that as a fact.

 

Lee

Posted

Thanks Lee - just the tip needed!

Coded it up, and it's working fine (so far...)

 

Just as a follow-up, if I understand correctly, the IF will be evaluated only when the element changes, so the following will execute on either a KPL-A/ON or a KPL-A/OFF

 

If control KPL-A is switched on

and control KPL-A is not switched off

then

....

else

....

 

However, the following will run whenever the status of KPL-A changes (but not necessarily when the key is pressed)...

 

If status KPL-A is on

then

....

else

....

 

 

Thanks again!

Chris

Posted

In the If Control example the Program is trigger when either an On command or Off command is received from KPL-A. The On command causes the Then clause to run, the Off command causes the Else clause to run. If Control does not care about the current state of the device. If Control is looking for specific command(s) flowing from the device.

 

If Status is looking at the "Current State" information the ISY maintains for each device. The If Status requires first that the status of the device changes and second that the new status matches the specified condition. An If Status On triggers only when device status changes and the status is changed to On in this example.

 

If Control triggers for each On command received even if there are three On commands in a row.

 

If Status triggers once even if the status is set to On three times in a row (assuming starting from an Off status). The first status change moves from Off to On status (so there is a status change) and the since the result status is On the Program triggers. If addition actions are taken that repeat directing the device status change to On the Program will not trigger because the status is already On thus no prerequisite change in status.

Posted

Perhaps a real life example that uses both If Control and If Status together will help.

 

If

Control Motion Sensor is switch On

And Status Hall Light is Off

Then

Set Hall Light 50%

 

This Program is triggered whenever the Motion Sensor signals motion (On command received from MS) and the Hall Light is Off (Status Off), it turns the Hall Light On to 50%. The first part of the If is looking for On commands from the Motion Sensor to indicate motion sensed with the second part of the If checking for the current state (If Status) of the Hall Light to determine if any action should be taken.

 

In previous discussions it has been use If Control or use If Status. In practice it is common to have both types of checks in a Program. The use of If Control or If Status is based on what the Program is trying to accomplish rather than some hard rule about one or the other.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...