File: test.rule
Code: Select all
if event['Test#Temperature'] > 15 :
gpio('d12',1)
timerSet(1,15) # seconds
Code: Select all
if event['system#boot']:
gpio('d12',0)
timerSet(1,15) # seconds
Code: Select all
if event['Rules#Timer'] == 1 :
gpio('d12',0)
So far only the structure (dictionary) event is available, together with these functions gpio and timerSet.
It's mandatory that every rule starts with if <trigger> :
Every line following this line is, according to Python syntax, indented with the same number of spaces.
Since it's Python, it's also possible to use else: which should be placed at the beginning of the line.
A short explanation:
event contains the <trigger>:
- <event>
OR
- <event><comparison operator function><value>
The <event> can be:
- <taskname>#<valuename>
- Rules#Timer
- System#Boot
The <value> can be anything, as long as it's the same type as the contents of the <valuename>
The function <gpio> has two parameters:
- port: the gpio port like 'd13'
- level: the gpio port level like 0 (low) or 1 (high)
- timer: the timer number which is an integer between 1 and 10
- seconds: the number of seconds before the timer is triggered
All three rule files which reside in the rules directory attached.