diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html
index 1f87f9d9a..9498f8ecf 100644
--- a/fhem/docs/commandref.html
+++ b/fhem/docs/commandref.html
@@ -4198,21 +4198,27 @@ Attributes:
- The perl specials in the definitions of the set and get commands can contain macros. Apart from the rules
- outlined in the documentation of perl specials in fhem, the following rules apply:
+ The perl specials in the definitions of the set and get commands can
+ contain macros. Apart from the rules outlined in the documentation of perl specials in fhem, the following
+ rules apply:
- - The character @ will be replaced with the device
- name. To use @ in the text itself, use the double mode (@@).
+ - The character @ will be replaced with the device
+ name. To use @ in the text itself, use the double mode (@@).
- - The macro
%NAME
will expand to the device name (same as @
).
+ - The macro
%NAME
will expand to the device name (same
+ as @
).
- - The macro
%<parameter>
will expand to the current value of the
- named parameter. This can be either a parameter from the device definition or a parameter
- from the set or get command.
+ - The macro
%<parameter>
will expand to the
+ current value of the named parameter. This can be either a parameter
+ from the device definition or a parameter from the set or get
+ command.
- - The macro substitution occurs before perl evaluates the expression. It is a plain text substitution.
+ - The macro substitution occurs before perl evaluates the
+ expression. It is a plain text substitution.
- - If in doubt what happens, run the commands with loglevel 5 and observe the log file.
+ - If in doubt what happens, run the commands with loglevel 5 and
+ observe the log file.
@@ -7041,7 +7047,7 @@ isday
In this case only one specific graphic will be rendered assuming that plotmode is 'gnuplot-scroll':
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
The 'zoom' will be either qday/day/week/month/year (same as used in FHEMWEB).
- The offset 'off' is either 0 (then the second part can be omitted, or -1/-2.... to jump back in time.
+ The offset 'off' is either 0 (then the second part can be omitted), or -1/-2.... to jump back in time.
The resulting filename will be 'attr-tmpfile file-name.png'
NOTE: If you want to use zoom AND offset then you have to concatenate via '&' !!
@@ -7221,90 +7227,132 @@ isday
Perl specials
-
- - To test perl oneliners, type them on the prompt by enclosing it in {}, e.g.
-
-
+ If you want to automate some tasks via fhem, then you'll probably use at or notify. For more complex tasks
+ you'll use either a shell-Skript or a perl "oneliner" as the at/notify
+ argument. This chapter gives some tips in using the perl oneliners.
- - To store some macros, see the Notes in the notify
- description.
+ - To test perl oneliners, type them on the telnet prompt (or FHEMWEB text
+ input) by enclosing it in {}, one line at once. The last line will only
+ write something in the logfile, the output of the other lines is directly
+ visible.
+
+ { "Hello" }
+ { 1+3*4 }
+ { `ls /etc` }
+ { Log 1, "Hello" }
+
+
- - To use fhem commands from the perl expression, use the function "fhem",
- which takes a string argument, this string will be evaluated as a fhem
- command chain.
- Example:
-
- define n1 notify piri:on { fhem "set light on" }
-
+ -
+ Perl expressions are separated by ;, in fhem oneliners they have to
+ escaped with ;;
+
+ { my $a = 1+1;; Log 1, "Hello $a" }
+
+
- - To make date and time handling easier, before evaluating a perl
- expression the variables $sec, $min, $hour, $mday, $month, $year, $wday,
- $yday, $isdst are set (see perldoc -f localtime), with the exception that
- $month is in the range of 1 to 12, and $year is also corrected by 1900 (as
- one would normally expect). Additionally $we is 1 if it is weekend (i.e
- $wday == 0 || $wday == 6), and 0 otherwise. If the holida2we global attribute is set, $we is 1 for
- holidays too.
- Example:
+
- To use fhem commands from the perl expression, use the function fhem(),
+ which takes a string argument, this string will be evaluated as a fhem
+ command:
+
+ { fhem "set light on" }
+ define n1 notify piri:on { fhem "set light on" }
+
+
-
- define n2 notify piri:on { if($hour > 18 || $hour < 5) { fhem "set
- light on" } }
-
+ - Notify can be used to store macros for manual execution. Use the trigger command to execute the macro:
+
+ define MyMacro notify MyMacro { Log 1, "Hello"}
+ trigger MyMacro
+ define MacroWithArg notify MyMacro { Log 1, "Hello %"}
+ trigger MyMacro MyArg
+
+
- -
- The following small helper functions are defined in 99_Util.pm (which will
- be loaded automatically):
-
- - min(a,b), max(a,b)
- - time_str2num("YYYY-MM-DD HH:MM:SS") returns a numerical value,
- which makes computation of time differences easier
- - abstime2rel("HH:MM:SS") converts an absolute time to a relative one,
- to compare it with the sunrise commands in the following example:
- # Switch lamp1 on at sunrise, but not before 07:00
- define a13 at +*{max(abstime2rel("07:00"),sunrise_rel())} set lamp1
- on
-
-
-
- -
- Note: do not forget to escape the semicolon (;) with two semicolons
- (;;), else your perl code will be interpreted as an fhem command and you
- most certainly get syntax errors.
-
+ - To make date and time handling easier, the variables $sec, $min, $hour,
+ $mday, $month, $year, $wday, $yday, $isdst are available in the perl
+ oneliners (see also perldoc -f localtime). Exceptions: $month is in the
+ range of 1 to 12, and $year is corrected by 1900 (as I would expect).
+ Additionally the variabe $we is 1 if it is weekend (i.e $wday == 0 or
+ $wday == 6), and 0 otherwise. If the holida2we
+ global attribute is set, $we is 1 for holidays too.
+
+ define n2 notify piri:on { if($hour > 18 || $hour < 5) {
+ fhem "set light on" } }
+ define roll_en *07:45:00 { fhem "trigger SwitchAllRoll on" if(!$we) }
+ define roll_en *08:30:00 { fhem "trigger SwitchAllRoll on" if($we) }
- -
- The current value (the string you see in paranthesis in the output of the
- list command) is available in the
value
hash; to access it
- use Value("name")
. If you need the old value (and time) of
- the currently triggered device, then you can access it with
- OldValue("name")
and OldTimestamp("name")
.
-
+
+
- -
- To access the numerical value of an FS20 command (e.g. toggle), use the
- hash
fs20_c2b
. E.g. { Log 2, $fs20_c2b{"toggle"} }
-
+ -
+ The following helper functions are defined in 99_Util.pm (which will
+ be loaded automatically, as every module with prefix 99):
+
+ - min(a,b), max(a,b)
+ - time_str2num("YYYY-MM-DD HH:MM:SS") returns a numerical value,
+ which makes computation of time differences easier
+ - abstime2rel("HH:MM:SS") converts an absolute time to a relative one,
+ to compare it with the sunrise commands in the following example:
+ # Switch lamp1 on at sunrise, but not before 07:00
+ define a13 at +*{max(abstime2rel("07:00"),sunrise_rel())} set lamp1
+ on
+ # Note that this functionality is easier to achieve with:
+ define a13 at +*{sunrise_rel(0,"07:00",undef)} set lamp1 on
+
+
+
- -
- By using the 99_SUNRISE_EL.pm module, you have access to the following
- functions:
-
- sunset_rel()
- sunset_abs()
- sunrise_rel()
- sunrise_abs()
- isday()
-
- The _rel functions should be used as "at" spec, and the _abs functions as
- argument to the on-till argument of the set command.
- isday returns 1 if the sun is visible, and 0 else.
-
+ -
+ To access the device states/attributes, use the following functions:
+
+
+ - Value(<devicename>)
+ returns the state of the device (the string you see in paranthesis in
+ the output of the list command).
+
+ - OldValue(<devicename>)
+
- OldTimestamp(<devicename>)
+ returns the old value/timestamp of the device.
+
+ -
+ ReadingsVal(<devicename>,<reading>,<defaultvalue>)
+ Return the reading (the value in the Readings section of "list device")
+
+ -
+ AttrVal(<devicename>,<attribute>,<defaultvalue>)
+ Return the attribute of the device
+
+ { Value("wz") }
+ { OldValue("wz") }
+ { time_str2num(OldTimestamp("wz")) }
+ { ReadingsVal("wz", "measured-temp", "20")+0 }
+ { AttrVal("wz", "room", "none") }
+
+
+
+ -
+ By using the 99_SUNRISE_EL.pm module, you have access to the following
+ functions:
+
+ sunset_rel($offset, $min, $max)
+ sunset_abs($offset, $min, $max)
+ sunrise_rel($offset, $min, $max)
+ sunrise_abs($offset, $min, $max)
+ isday()
+
+ offset is in seconds, and the format of min/max is "HH:MM" or "HH:MM:SS".
+ isday returns 1 if the sun is visible, and 0 else.
+
+
+
+
+
+
-