Elk Rules Programming Example Database

jwilson56

Senior Member
Please upload your Elk rules you wish to share with others. This should be very helpful for anyone learning to use their Elk.
 
Here is a rule where a zone must be 'not secured' for at least five seconds before an action is taken. This is handy in cases where say you are measuring an over-current alarm on a motor and want to ignore it's startup peak.


(Zone 15 is the zone of interest):

Whenever Zone 15 Becomes Not Secure
Then Turn Output 64 On For 5 Seconds

Whenever Output 64 State is Turned Off
And Zone 15 is Not Secure
Then ------ Perform Your Alarm Function Here

Now Zone 15 will not perform your alarm function unless it has been in the "unsecured" mode for at least five seconds, thus eliminating glitch triggers.
 
Simple Alarm Clock

Code:
WHENEVER THE TIME IS 5:15 AM
		THEN ANNOUNCE Miscellaneous 6 (vm244)
		THEN ANNOUNCE SAY TIME (vm238)
		THEN TURN MB Bed Vibrator [2 (A2)] ON FOR 2 SECS
		THEN TURN Output 202 ON FOR FOUR SECS

MB Bed Vibrator is my bed vibrator connected via Insteon ApplianceLinc.
Miscellaneous 6 is "Wake Up."

Wireless Doorbell

Now this gets really complicated as it uses several outputs to perform some kind of animation per second.

Code:
WHENEVER EVERY 1 SECONDS
	AND Wireless DrBell (Zn 1) IS LESS THAN ANALOG VALUE 4.0 VOLTS
	AND DrbllActiv'd (Counter 3) IS EQUAL TO 0
		THEN ANNOUNCE Miscellaneous 5 (vm243)
		THEN SET DrbllActiv'd (Counter 3) TO 1
		THEN SET MB 2x Side FL [1 (A1)] TO 100% BRIGHT, FADE RATE = 1 FOR 1 SEC
		THEN TURN Output 206 ON FOR 1 SEC
WHENEVER EVERY 1 SECONDS
	AND Wireless DrBell (Zn 1) IS GREATER THAN ANALOG VALUE 4.1 VOLTS
	AND DrbllActiv'd (Counter 3) IS EQUAL TO 1
		THEN SET DrbllActiv'd (Counter 3) TO 0
		THEN SET MB 2x Side FL [1 (A1)] TO 46% BRIGHT, FADE RATE = 0
		THEN ANNOUNCE Miscellaneous 5 (vm243)
		THEN TURN Output 207  ON FOR 1 MIN
WHENEVER Output 203 IS TURNED OFF
		THEN SET LR 2x Side FL [4 (A4)] TO 75% BRIGHT, FADE RATE = 0
WHENEVER Output 204 IS TURNED OFF
		THEN SET LR 2x Side FL [4 (A4)] TO 40% BRIGHT, FADE RATE = 0
		THEN TURN Output 203 ON FOR 15 SECS
WHENEVER Output 205 IS TURNED OFF
		THEN SET LR 2x Side FL [4 (A4)] TO 60% BRIGHT, FADE RATE = 0
		THEN TURN Output 204 ON FOR 1 SEC
WHENEVER Output 206 IS TURNED OFF
		THEN TOGGLE STATE OF LR 2x Side FL [4 (A4)], FADE RATE = 0
		THEN TURN Output 205 ON FOR 2 SECS
WHENEVER Output 207 IS TURNED OFF
		THEN SET MB 2x Side FL [1 (A1)] TO 24% BRIGHT, FADE RATE = 0

Miscellanous 5 is "[800Hz BEEP] Someone Is At Front Door."

It's very complex. It'd be nice to group complex rules into one rule group.
 
Caveat for ELK Rule Execution

I wanted repeated F5 keypresses to show attic temperatures in the keypad display -- first the current temperature, then the day's high, and finally the day's low. This is easy enough to do by incrementing a counter and having rules to do each display. (Note that other rules not shown here handle the temperature tracking and overnight counter resets.)

HOWEVER, the straightforward "intuitive" way is the wrong way to create this function. The rules below do not produce the desired outcome. I want only one of the rules to fire with each keypress. But these rules are all executed in sequence, at the same time, with a single keypress, because each rule sets up the condition for the next one. The result: Only the last rule is left to display.

Code:
/*  WRONG WAY -- This code sequence does not work correctly */

/* KP F5 -- State 0 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 0
	THEN DISPLAY "Attic Now % TEMP ZN14 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 1

/* KP F5 -- State 1 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 1
	THEN DISPLAY "Attic High % CTR4 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 2

/* KP F5 -- State 2 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 2
	THEN DISPLAY "Attic Low % CTR6 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 0

A solution is to be sure that none of the rules can set the conditions for the rules that follow. In this example, continue to up-increment, but arrange the state testing in reverse order.

Code:
/*  ONE WAY THAT WORKS CORRECTLY  */

/* KP F5 -- State 2 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 2
	THEN DISPLAY "Attic Now % TEMP ZN14 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 99

/* KP F5 -- State 1 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 1
	THEN DISPLAY "Attic High % CTR4 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 2

/* KP F5 -- State 0 */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 0
	THEN DISPLAY "Attic Low % CTR6 % " IN Residence (Area 1) INDEFINITELY, [*] CLEARS
	THEN SET F5 Cycler (Counter 5) TO 1

/* KP F5 -- State 99 (reset to 0) */
WHENEVER KEY F5 ON KEYPAD1 ACTIVATES
  AND F5 Cycler (Counter 5) IS EQUAL TO 99
	THEN SET F5 Cycler (Counter 5) TO 0

Note that one additional rule is needed to catch and reset the state for the initial rule.
 
ELK Rules Documentation

A shortcoming of the ELK documentation is that there is nowhere to be found a ready listing of the WHENEVER / AND / THEN options. Below is a list of the WHENEVER and AND options, developed by Peter N. Steinmetz and posted here with his permission. I prepared the list of THEN options. Corrections and/or additions are appreciated.

Dave ("Lagerhead")

Code:
WHENEVER:

Time Occurence
	Time of Day Equals (hrs:mins)
	At Sunrise (+/-)
	At Sunset (+/-)
	Hour Equals X
	Minute Equals X
	Every X Hours and/or Minutes
	Every X Seconds
Input (Zone) Change
Output Change
Keypad F Key Press
Keyfob Button Press
Lighting Change
	Individual
	All
Automation Tasks
Security/Alarms
	Is Disarmed
	Is Armed
		Armed to any mode
		Armed Away
		Armed Stay
		Armed Stay Instant
		Armed Night
		Armed Night Instant
		Armed Vacation
		Force Armed
	Burglar Status
		Becomes Ready to Arm
		Becomes Not Ready To Arm
	Day Alert
		Activates
		Cuts Off
	Entry Delay
		Starts
		Ends
	Exit Delay
		Starts
		Expires
	Exit Error Occurs
	Closing Report Ring Back
	Key Switch Tamper Alert
		Turns On
		Cuts Off
	Alarm Turns On or Cuts Off
		Fire
		Fire Supervisory
		Burglar
		Medical
		Police
		Aux1 24 hr.
		Aux2 24 hr.
		CO Carbon Monoxide
		Emergency
		Freeze
		Gas
		Heat
		Water
		Any Alarm
	Access
	Chime
		Mode is Enabled
		Alert Sounds
		Mode is Disabled
	Zone Bypass Status
		At Least One Zone Becomes Bypassed
		All Zones Become Un-bypassed
Miscellaneous System
	Troubles
		Power Supv Zn - AC Trouble
		Power Supv Zn - Low Batt Trouble
		Any Fire Zone Trouble
		2-Wire Smoke Det. Clean Trouble
		Any Burglar Zone Trouble
		Failed to Communicate
		Any RF Sensor Low Battery
		Any RF Sensor Supervision Loss
		ANC Module Trouble
		Keypad Trouble
		Input Expander Trouble
		Output Expander Trouble
		EEProm Memory Error
		Flash Memory Error
		AC Power Failure
		Low Backup Battery
		Control Over Current
		Any Expansion Module Trouble
		Output 2 Supervisory Trouble
		Telephone Line Trouble
		Ethernet Expander Trouble
	Restorals
		Power Supv Zn - AC Trouble Restore
		Power Supv Zn = Low Batt Restore
		Communication Fail Restore
		AC Power Failure Restore
		Low Battery Restore
		Control Over Current Restore
		Expansion Module Restore
		Output 2 Restore
		Telephone Line Restore
		Ethernet Expander Restore
	Other
		Audio Amplifier
			Turns On
			Turns Off
		Dialer Abort
		Dialer Cancel
		Dialer AutoTest
		Dialer C.S. Kissoff
		Keypad Beep
		Keypad Locked Out
		Event Log Reaches 80% Full
		Local Programming
			Begins
			Ends
		Telephone Line is Ringing
		Telephone Line Seize
			Occurs
			Clears
		Telephone Line On/Off Hook
			Goes Off-hook
			Goes On-hook
		Telephone Local Access
			Begins
			Ends
		Telephone Remote Access
			Begins
			Ends
		Remote Programming
			Begins
			Ends
		System Start-up Occurs
Text (ASCII) String is Received
Counter Changes/Expires
Thermostat Setting Changes

Code:
AND WHEN:

Time is
	Relative to a Specific Time of Day
	Relative to Sunrise
	Relative to Sunset
	Every (n) Days
	Every (n) Months
Date is
	Specific Days of the Week
	A Specific Day of the Month
	A Specific Month of the Year
	A Specific Year
Light/Dark
	It is Light Outside
	It is Dark Outside
Input (zone) is
Output is
Last User Was
Lighting is
Security/Alarms
	Is Disarmed
	Is Armed
		Armed to any mode
		Armed Away
		Armed Stay
		Armed Stay Instant
		Armed Night
		Armed Night Instant
		Armed Vacation
		Force Armed
	Burglar Status
		Is Ready to Arm
		Is Not Ready To Arm
	Day Alert
		Is Active
		Is Not Active
	Entry Delay
		Is Active
		Is Not Active
	Exit Delay
		Is Active
		Is Not Active
	Exit Error
		Is Active
		Is Not Active
	Key Switch Tamper Alert
		Is Active
		Is Not Active
	Alarm On or Off
		Fire
		Fire Supervisory
		Burglar
		Medical
		Police
		Aux1 24 hr.
		Aux2 24 hr.
		CO Carbon Monoxide
		Emergency
		Freeze
		Gas
		Heat
		Water
		Any Alarm
	Alarm Memory
	Chime
		Mode is Enabled
		Mode is Disabled
	Zone Bypass Status
		At Least One Zone Is Bypassed
		No Zones Are Bypassed
Miscellaneous System
	Troubles
		Power Supv Zn - AC Trouble
		Power Supv Zn - Low Batt Trouble
		Any Fire Zone Trouble
		2-Wire Smoke Det. Clean Trouble
		Any Burglar Zone Trouble
		Failed to Communicate
		Any RF Sensor Low Battery
		Any RF Sensor Supervision Loss
		ANC Module Trouble
		Keypad Trouble
		Input Expander Trouble
		Output Expander Trouble
		EEProm Memory Error
		Flash Memory Error
		AC Power Failure
		Low Backup Battery
		Control Over Current
		Any Expansion Module Trouble
		Output 2 Supervisory Trouble
		Telephone Line Trouble
		Ethernet Expander Trouble
	Other
		Audio Amplifier
			Is On
			Is Off
		Event Log, 80% Full
		Local Programming
			Is Active
			Is Not Active
		Telephone Line Seized/Not Seized
			Is Seized
			Is Not Seized
		Telephone Line On/Off Hook
			Is Off-hook
			Is On-hook
		Telephone Local Access
			Is Active
			Is Not Active
		Telephone Remote Access
			Is Active
			Is Not Active
		Remote Programming
			Is Active
			Is Not Active
Counter is
Temperature
Thermostat
Code:
THEN:

Automation Tasks
	Activate Task (t)
Security
	Automatically Arm
		Away
		Stay
		Stay Instant
		Night
		Night Instant
		Vacation
	Automatically Disarm
	Set Expected Arm/Disarm Times
		hh:mm
Turn Output On/Off
	Turn On/Turn Off/Toggle
	[for duration dd:hh:mm:ss]
	[for Custom Setting time]
	[Restart if running]
Control Lighting
	Individual
		Turn On/Turn Off/Toggle
		[for duration dd:hh:mm:ss]
		[for Custom Setting time]
	All
		All Lights On/All Units Off/All Lights Off
Speak
Send Text Out Port
	Text String Through Serial Port (n)
Send Text To Keypad
	Select Message (m) Select Area (a)
	[Clear any previous message]
	[Beep keypad(s)]
	[Allow user to clear with *]
	[Display message for (n) seconds]
Enable/Disable Chime
Beep Keypad(s)
	Select Area (a) Start Beeps/Stop Beeps
Chirp Outside Siren
	(n) times
Set/Change Counter
	[Toggle between 0 and 1]
	[Set counter to value (n)]
	[Add value (n) to counter]
	[Subtract value (n) from counter]
	[Set counter to temperature of (temp sensor)]
Dial Telephone Number
Set Email Message
Thermostat
	[multiple thermostat settings]
Enable/Disable User
Enable/Disable Voice
Bypass/Unbypass a Zone
	Bypass/Unbypass a specific zone
	Bypass/Unbypass all non-secure burglar zones in area
Reset Smoke Power
 
In many closets and stairwells in my house I have the lights coming on automatically when the door is opened and times out to turn the light off because no one can remember to turn off the lights. In the case of closets, if you close the door the light will turn off immediately without timing out. I wired a security reed switch to a hardwire input on the M1 and wired an ELK-912 relay across the light switch. An output on the M1 controls the relay. This may not pass the electrical inspector so be careful. You can also do the same arrangement wirelessly with a wireless door transmitter and replacement of your electrical light switch with a powerline or RF based light switch like UPB, Insteon, or Zwave.

WHENEVER Master BR Closet (Zn 15) BECOMES NOT SECURE
THEN TURN Mstr BR ClosetTr (Out 15) ON FOR 5 MINS
WHENEVER Master BR Closet (Zn 15) BECOMES SECURE
THEN TURN Mstr BR ClosetTr (Out 15) OFF

The basement stairwell has a switch at the top of the stairwell (Zn 2), at the Inside Basement Door (Zn 3), and a motion detector in the basement (Zn 13). If any one of them becomes not secure, the light turns on for 5 minutes and the timer is retriggered with each violation to keep the light on.
WHENEVER Kitchen Basement (Zn 2) BECOMES NOT SECURE
THEN TURN BasementLiteTrig (Out 14) ON FOR 5 MINS, RESTART TIMER IF RUNNING
WHENEVER Basement Inside (Zn 3) BECOMES NOT SECURE
THEN TURN BasementLiteTrig (Out 14) ON FOR 5 MINS, RESTART TIMER IF RUNNING
WHENEVER Basement Motion (Zn 13) BECOMES NOT SECURE
THEN TURN BasementLiteTrig (Out 14) ON FOR 5 MINS, RESTART TIMER IF RUNNING


My wife and I both love the automated wake up in the mornings, Monday through Friday. It allows you to slowly wake up over time.
WHENEVER THE TIME IS 6:30 AM
AND THE DAY(S) OF THE WEEK IS/ARE -MTWTF-
THEN ANNOUNCE Say Time (vm238)
THEN TURN Coffee Pot [6 (A6)] ON
THEN ACTIVATE DimMainLights (Task 7)
WHENEVER THE TIME IS 6:40 AM
AND THE DAY(S) OF THE WEEK IS/ARE -MTWTF-
THEN ANNOUNCE Say Time (vm238)
WHENEVER THE TIME IS 6:45 AM
AND THE DAY(S) OF THE WEEK IS/ARE -MTWTF-
THEN ANNOUNCE Say Time (vm238)
WHENEVER THE TIME IS 6:50 AM
AND THE DAY(S) OF THE WEEK IS/ARE -MTWTF-
THEN ANNOUNCE Say Time (vm238)
 
Lagerhead-

I am wanting to do something like what you have done. I have a RCS outdoor temperature sensor that is set up as Thermostat # 1 in my elk. I am wanting my Keypad to display this temperature.

My problem is that I can not find the command "Display" in the ELKRP that you are using.

where is this at????


thanks


Steve
 
Steve,
You have to setup a text string to display the temperature information. Then setup a Rule to display the text string.
 
Checking for water leak:
Zone 6 - Analog input with 470k resistor between input and negative, copper wires at both ends, giving 13.9 volts when dry and 3.7 when soaked in water.
230 (O6) - Lighting device to indicate the ON and OFF status
Output 57 - flag to announce in 15 minutes interval

RULES:
TO SENSE WATER LEAK
WHENEVER EVERY 2 SECONDS
AND WS-Basement (Zn 6) IS LESS THAN ANALOG VALUE 10.0 VOLTS
AND WS-Basement (Zn 6) IS GREATER THAN ANALOG VALUE 0.0 VOLTS >> so no false alarm during controller bootup
AND WaterLeakAnnounce (Out 57) STATE IS OFF
THEN TURN WaterLeak sensor (Out 14) ON
THEN TURN ws-Basement [230 (O6)] ON
THEN DISPLAY "water leak" IN HOME (Area 1) INDEFINITELY,[*] CLEARS, ....
THEN TURN WaterLeakAnnounce (Out 57) ON FOR 15 MINS
THEN ANNOUNCE WS-Basement (Zn 6)

TO RESET
WHENEVER EVERY 2 SECONDS
AND WS-Basement (Zn 6) IS GREATER THAN ANALOG VALUE 10.0 VOLTS
THEN TURN WS-Basement [230 (O6)] OFF
THEN TURN waterLeakAnnounce (Out 57) OFF

PROBLEM:
I only wanted it to announce every 15 minutes but still announcing every 2 seconds. Can someone figure out what is missing. The water sensor works great though with just the 470K resistor.
 
I misspoke on displaying the thermostat temperature on the keypad. It is implemented in the M1 control, but ELKRP has not enabled the feature. It is now on the list to add in ELKRP. :)

You can speak the temperature of the thermostat by writing a Rule to say the temperature if pressing a keypad key or saying the temperature at some time during the day.

When writing the Rule:
Whenever [an event has fired]
THEN ANNOUNCE TEMPERATURE READING of Thermostat 1

Scroll down to the bottom of the voice message list when selecting which phrase to say.
 
I misspoke on displaying the thermostat temperature on the keypad. It is implemented in the M1 control, but ELKRP has not enabled the feature. It is now on the list to add in ELKRP. :)

You can speak the temperature of the thermostat by writing a Rule to say the temperature if pressing a keypad key or saying the temperature at some time during the day.

When writing the Rule:
Whenever [an event has fired]
THEN ANNOUNCE TEMPERATURE READING of Thermostat 1

Scroll down to the bottom of the voice message list when selecting which phrase to say.

Can you announce the setpoint of the thermostat as well? So if you change the setpoint (or it is changed by a rule) you hear a confirmation of what the new setpoint is?
 
Lagerhead-

I am wanting to do something like what you have done. I have a RCS outdoor temperature sensor that is set up as Thermostat # 1 in my elk. I am wanting my Keypad to display this temperature.

My problem is that I can not find the command "Display" in the ELKRP that you are using.

where is this at????


thanks


Steve

Hi Steve,

Could you let me know what RCS outdoor temperature sensor that you have connected to your ELK? I have been looking for a suitable solution to get an outdoor temp into my M1 for a while. THe only one I can find on the RCS site looks like it has to connect to a RCS wall display unit.

Hope you can demystify how and what RCS outdoor sensor you have connected to the Elk M1

Thanks and regards,

Fleetz
 
Fleez- I have the outdoor sensor that Automated Outlet sells. Here is the link
http://www.automatedoutlet.com/product.php...at=0&page=1

Everything worked as expected when I had it connected to HomeSeer, but now I am moving everything to the Elk, I have hit a few snags.

Spanky-

When I used the example that you suggested, the Elk speaks the temperature of Thermostat #1. The problem is that it is always 72 degrees!!!

Any ideas


thanks for the help

Steve
 
If you go to the keypad user menu 1,6, what is the thermostat temperature showing?

If it is other than 72 degrees and the M1 is saying 72 degrees, I need to dig deeper.
 
Back
Top