From 3dcc2516ef368d5584a904047ec9a8acb116b4b9 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Fri, 25 Jul 2008 15:49:31 +0000 Subject: [PATCH] Examples revisited git-svn-id: https://svn.fhem.de/fhem/trunk@215 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/examples/01_fs20 | 2 +- fhem/examples/02_fs20 | 16 ++++++------ fhem/examples/03_fht | 6 ++--- fhem/examples/04_log | 8 +++--- fhem/examples/05_rm100 | 6 ++--- fhem/examples/06_at | 11 ++++---- fhem/examples/07_sunset_windowed | 43 ++++++++++++++++++-------------- fhem/examples/sample_fhem | 8 ++++++ fhem/examples/sample_pgm2 | 12 +++++++++ 9 files changed, 70 insertions(+), 42 deletions(-) create mode 100644 fhem/examples/sample_fhem create mode 100644 fhem/examples/sample_pgm2 diff --git a/fhem/examples/01_fs20 b/fhem/examples/01_fs20 index 64f90c847..5e833bd24 100644 --- a/fhem/examples/01_fs20 +++ b/fhem/examples/01_fs20 @@ -11,7 +11,7 @@ attr global logfile /tmp/fhem-%Y-%m.log attr global statefile /tmp/fhem.save # where to save the state of the devices attr global verbose 3 # "normal" verbosity (min 1, max 5) attr global port 7072 # our TCP/IP port (localhost only) -attr global modpath /usr/local/lib # where our FHEM directory is +attr global modpath . # where our FHEM directory is define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC diff --git a/fhem/examples/02_fs20 b/fhem/examples/02_fs20 index 2599e54f9..7962d1f76 100644 --- a/fhem/examples/02_fs20 +++ b/fhem/examples/02_fs20 @@ -1,8 +1,9 @@ # # fhem.pl configfile # -# We have 2 rollades (which are connected via the FS20MS). Button 3 on the -# FS20S20 should activate both rollades. There are three solutions: +# The challange: We have 2 rollades (which are connected via the FS20MS). +# Button 3 on the FS20S20 should activate both rollades. There are three +# solutions: # 1. Builtin commands # 2. Perl expression # 3. Shell script (realized via external script at the end of this file) @@ -13,7 +14,7 @@ attr global logfile /tmp/fhem-%Y-%m.log attr global statefile /tmp/fhem.save # where to save the state of the devices attr global verbose 3 # "normal" verbosity attr global port 7072 # our TCP/IP port (localhost only) -attr global modpath /usr/local/lib # where our FHEM directory is +attr global modpath . # where our FHEM directory is define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC @@ -30,7 +31,7 @@ define n_1a notify btn3 set roll1 %;; set roll2 % # Method 1b: shorter: define n_1b notify btn3 set roll1,roll2 % -# Method 2a: perl. +# Method 2a: the same in perl. Everything between {} is evaluated as perl code define n_2a notify btn3 { fhem "set roll1,roll2 %" } # Method 2b: perl. open the rollades only to a certain amount if they are @@ -44,7 +45,8 @@ define n_2b notify btn3 {\ } \ } -# Method 3: shell. The script follows after "quit". Dont forget to chmod u+x it. +# Method 3: shell. Everything between "" is evaluated as a shell command. The +# script follows after "quit". Dont forget to chmod u+x it. define n_3 notify btn3 "/usr/local/bin/roll.sh %" quit # Ignore the rest of this file @@ -64,8 +66,8 @@ quit # Ignore the rest of this file fhem=/usr/local/bin/fhem.pl if test $1 = "on"; then - $fhem 7072 "set roll1 on-for-timer 10 - $fhem 7072 "set roll2 on-for-timer 16 + $fhem 7072 "set roll1 on-for-timer 10" + $fhem 7072 "set roll2 on-for-timer 16" else $fhem 7072 "set roll1,roll2 off" fi diff --git a/fhem/examples/03_fht b/fhem/examples/03_fht index 209048c3a..3ff482b01 100644 --- a/fhem/examples/03_fht +++ b/fhem/examples/03_fht @@ -8,11 +8,11 @@ # After about 5-10 minutes, check if "list wz" returns something meaningful # -attr global logfile /tmp/fhem-%Y-%m.log -attr global statefile /tmp/fhem.save # where to save the state of the devices +attr global logfile /var/log/fhem/fhem-%Y-%m.log +attr global statefile /var/log/fhem/fhem.save # where to save the state of the devices attr global verbose 3 # "normal" verbosity attr global port 7072 # our TCP/IP port (localhost only) -attr global modpath /usr/local/lib # where our FHEM directory is +attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC define wz FHT 3232 # type FHT, transmitter code 3232 (default value) diff --git a/fhem/examples/04_log b/fhem/examples/04_log index ea836c05b..62b911eb0 100644 --- a/fhem/examples/04_log +++ b/fhem/examples/04_log @@ -4,11 +4,11 @@ # contrib/91_DbLog.pm # -attr global logfile /tmp/fhem-%Y-%m.log -attr global statefile /tmp/fhem.save # where to save the state of the devices +attr global logfile /var/log/fhem/fhem-%Y-%m.log +attr global statefile /var/log/fhem/fhem.save # where to save the state of the devices attr global verbose 3 # "normal" verbosity attr global port 7072 # our TCP/IP port (localhost only) -attr global modpath /usr/local/lib # where our FHEM directory is +attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC define wz FHT 3232 # type FHT, transmitter code 3232 (default value) @@ -17,7 +17,7 @@ define ks1 KS300 1234 250 # type KS300, with 250ml rain / counter ######################### # Log temperature and actuator changes into a file, its name changes weekly -define wzlog FileLog /var/tmp/wz-%Y-%U.log wz:.*(temp|actuator).* +define wzlog FileLog /var/var/log/fhem/wz-%Y-%U.log wz:.*(temp|actuator).* # Make it accessible from 01_FHEMWEB.pm (webpgm2) # Note: for FHEMWEB large logfiles (one per year) are recommended to be able to diff --git a/fhem/examples/05_rm100 b/fhem/examples/05_rm100 index ed06e4635..8112e1f22 100644 --- a/fhem/examples/05_rm100 +++ b/fhem/examples/05_rm100 @@ -8,11 +8,11 @@ # if there is no definition for it. Check the commandref.html define, Type HMS # section for details -attr global logfile /tmp/fhem-%Y-%m.log -attr global statefile /tmp/fhem.save # where to save the state of the devices +attr global logfile /var/log/fhem/fhem-%Y-%m.log +attr global statefile /var/log/fhem/fhem.save # where to save the state of the devices attr global verbose 3 # "normal" verbosity (min 1, max 5) attr global port 7072 # our TCP/IP port (localhost only) -attr global modpath /usr/local/lib # where our FHEM directory is +attr global modpath /usr/local/libusr/local/lib # where our FHEM directory is define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC diff --git a/fhem/examples/06_at b/fhem/examples/06_at index c03a8837f..fa3295a58 100644 --- a/fhem/examples/06_at +++ b/fhem/examples/06_at @@ -1,6 +1,5 @@ # These are only examples for the at and notify command - ################################## # absolute ones: define a1 at 17:00:00 set lamp on # fhem command @@ -14,11 +13,14 @@ define a5 at +00:00:10 set lamp on # switch the lamp on in 10 seconds define a6 at +00:00:02 set lamp on-for-timer 1 # Blink once in 2 seconds define a7 at +*{3}00:00:02 set lamp on-for-timer 1 # Blink 3 times +# For correct sunrise/sunset values, put the following line (with your +# coordinates in it) in your fhem.cfg +{ sunrise_coord("8.686", "50.112", "") } + ################################## # Switch the lamp on from sunset to 11 PM each day -# You have to install 99_SUNRISE_EL.pm in the FHEM directory to have sunset() # We have to use the relative versions, as the next event is computed now -{ sunrise_coord("8.686", "50.112", "") } +# and absolute values would cause problems in the spring define a8 at +*{sunset_rel()} set lamp on define a9 at *23:00:00 set lamp off @@ -27,7 +29,7 @@ define a9 at *23:00:00 set lamp off define a10 at +*{sunset_rel()} set lamp on-till 23:00 ################################## -# Only do this on weekend. For the preset perl variables see commandref.html +# Only do this at weekend. For the preset perl variables see commandref.html define a11 at +*{sunset_rel()} { fhem("set lamp on-till 23:00") if($we) } ################################## @@ -36,7 +38,6 @@ define a12 at *07:00 set lamp1,lamp2 on-till {sunrise_abs(+600)} ################################## # Switch lamp1 on at sunrise, but not before 07:00 -# Note: you have to put 99_Utils.pm in the FHEM modules directory define a13 at +*{max(abstime2rel("07:00"),sunrise_rel())} set lamp1 on ################################## diff --git a/fhem/examples/07_sunset_windowed b/fhem/examples/07_sunset_windowed index e8dbce016..cb94b7d0b 100755 --- a/fhem/examples/07_sunset_windowed +++ b/fhem/examples/07_sunset_windowed @@ -70,7 +70,7 @@ attr global statefile /var/cache/fhem/fhem.save attr global pidfilename /var/run/fhem.pid attr global verbose 3 attr global port 7072 -attr global modpath /usr/local/lib +attr global modpath /usr/local/libusr/local/lib # Die Definition des Attributs "freigabe" # definition of attribute "freigabe" @@ -90,23 +90,28 @@ define roll_eg_wz1 FS20 fb02 0c fg f2 lm 8f # timed jobs ########################################################################## -define roll_wz1_off1 at *20:00:00 { if( $value{roll_eg_wz1} ne "off" ) { \ - if( $attr{roll_eg_wz1}{freigabe} ) { \ - fhem("set roll_eg_wz1 off");; \ - fhem("deleteattr roll_eg_wz1 freigabe") \ - } else { \ - fhem("attr roll_eg_wz1 freigabe") \ - } \ - } } +define roll_wz1_off1 at *20:00:00 { \ + if( $value{roll_eg_wz1} ne "off" ) { \ + if( $attr{roll_eg_wz1}{freigabe} ) { \ + fhem("set roll_eg_wz1 off");; \ + fhem("deleteattr roll_eg_wz1 freigabe") \ + } else { \ + fhem("attr roll_eg_wz1 freigabe") \ + } \ + } \ +} -define roll_wz1_off2 at +*{sunset_rel(+3600)} { if( $value{roll_eg_wz1} ne "off" ) { \ - if( $attr{roll_eg_wz1}{freigabe} ) { \ - fhem("set roll_eg_wz1 off");; \ - fhem("deleteattr roll_eg_wz1 freigabe") \ - } else { \ - fhem("attr roll_eg_wz1 freigabe") \ - } \ - } } +define roll_wz1_off2 at +*{sunset_rel(+3600)} {\ + if( $value{roll_eg_wz1} ne "off" ) { \ + if( $attr{roll_eg_wz1}{freigabe} ) { \ + fhem("set roll_eg_wz1 off");; \ + fhem("deleteattr roll_eg_wz1 freigabe") \ + } else { \ + fhem("attr roll_eg_wz1 freigabe") \ + } \ + } \ +} -define roll_wz1_off3 at *22:00:00 { fhem("set roll_eg_wz1 off") if($value{roll_eg_wz1} ne "off");; \ - fhem("deleteattr roll_eg_wz1 freigabe") } +define roll_wz1_off3 at *22:00:00 {\ + fhem("set roll_eg_wz1 off") if($value{roll_eg_wz1} ne "off");; \ + fhem("deleteattr roll_eg_wz1 freigabe") } diff --git a/fhem/examples/sample_fhem b/fhem/examples/sample_fhem new file mode 100644 index 000000000..1db3333ab --- /dev/null +++ b/fhem/examples/sample_fhem @@ -0,0 +1,8 @@ +# +# Minimalistic fhem.pl configfile. Take a look at the other examples for more. +# +attr global logfile /tmp/fhem-%Y-%m.log +attr global statefile /tmp/fhem.save # where to save the state of the devices +attr global verbose 3 # "normal" verbosity (min 1, max 5) +attr global port 7072 # our TCP/IP port (localhost only) +attr global modpath . # where our FHEM directory is diff --git a/fhem/examples/sample_pgm2 b/fhem/examples/sample_pgm2 new file mode 100644 index 000000000..b3bc0d233 --- /dev/null +++ b/fhem/examples/sample_pgm2 @@ -0,0 +1,12 @@ +# +# Minimalistic fhem.pl & pgm2 configfile. Take a look at the other examples for +# more. +# +attr global logfile /tmp/fhem-%Y-%m.log +attr global statefile /tmp/fhem.save # where to save the state of the devices +attr global verbose 3 # "normal" verbosity (min 1, max 5) +attr global port 7072 # our TCP/IP port (localhost only) +attr global modpath . # where our FHEM directory is + +define WEB FHEMWEB 8083 +attr WEB plotmode SVG