2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 07:19:24 +00:00
fhem-mirror/fhem/examples/04_log

56 lines
1.9 KiB
Plaintext
Raw Normal View History

#
# fhem.pl configfile
# Logging FS20/KS300 data into files. For database logging see the
# 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 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
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)
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).*
# Make it accessible from 01_FHEMWEB.pm (webpgm2)
# Note: for FHEMWEB large logfiles (one per year) are recommended to be able to
# navigate
attr wzlog logtype fht:Temp
# ks300 log
define kslog FileLog /var/log/wz-%Y-%U.log ks1:.*H:.*
define avglog FileLog /var/log/avg.log ks1:.*avg.*
attr kslog logtype ks300_1:Temp/Hum,ks300_2:Rain/Wind
##############################
# Alternative log method. It does the same, but it is somewhat slower as it
# starts the shellscript below. Don't forget the "", as some values contain
# paranthesis, and your shell will probably bark.
define tmplog notifyon wz:temp.* "/usr/local/bin/log.sh @ "@ %""
##############################
# If using the frontends pgm2 or pgm3, then you can put the devices
# into separate rooms, see the corresponding README:
attr wz room InDoor
attr wzlog room InDoor
attr ks1 room OutDoor
attr kslog room OutDoor
attr avglog room OutDoor
quit
#########################
And here is /usr/local/bin/log.sh, don't forget chmod +x
#!/bin/sh
fname=$1
shift
echo `date +"%Y-%m-%d_%H:%M:%S"` "$*" >> /var/log/$fname.log