Moderators: Voyager, BertB, Stuntteam, LisaM

Normal user
Posts: 509
Joined: 11 Apr 2017, 18:29


#1 Post by LisaM » 24 Jan 2018, 11:19

The Rules currently working on my almost there beta-1 release:

File: test.rule

Code: Select all

if event['Test#Temperature'] > 15 :
     timerSet(1,15)   # seconds
File: boot.rule

Code: Select all

if event['system#boot']:
     timerSet(1,15)   # seconds
File: timertest.rule

Code: Select all

if event['Rules#Timer'] == 1 :
Rules are miniature python programs with a fixed context. The syntax must comply with the Python syntax: ... _semantics
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>

  • <event><comparison operator function><value>
Where the "comparison operator function" is any legal Python comparison function: ... xample.htm

The <event> can be:
  • <taskname>#<valuename>
  • Rules#Timer
  • System#Boot
Where <taskname> is the name of the task in the device and <valuename> is the name of the value in that task.

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)
The function <timerSet> (case sensitive!) has two parameters:
  • timer: the timer number which is an integer between 1 and 10
  • seconds: the number of seconds before the timer is triggered
In time all of these commands: ... _Reference will be added.

All three rule files which reside in the rules directory attached.
(628 Bytes) Downloaded 74 times


Who is online

Users browsing this forum: No registered users and 1 guest