fhem.pl ~/.fhem
attr global logfile /tmp/fhem.log attr global statefile /tmp/fhem.save attr global verbose 3 attr global port 7072 attr global modpath /usr/share/fhem define FHZ FHZ /dev/tts/USB0 define lamp FS20 8765 01For other configuration files see the examples subdirectory.
telnet localhost 7072
<NL>
(This newline switches into "prompt" mode)
<command>...
quit
fhem.pl 7072 "set lamp off"
set lamp1 on
set lamp1,lamp2,lamp3 on
set lamp[1-3] on
set lamp.* on
set lamp1-lamp3 on
set lamp1-lamp3,lamp3 on
set room=kitchen off
list disabled=
list TYPE=FS20
?
help
attr <devspec> <attrname> [<value>]
attr global verbose 3
attr lamp room kitchen
attr lamp loglevel 6
setdefaultattr [<attrname> [<value>]]
setdefaultattr room kitchen
setdefaultattr loglevel 4
define lamp1 FS20 1234 11
define lamp2 FS20 1234 12
define lamp3 FS20 1234 13
setdefaultattr
define <name> <type> <type-specific>
deleteattr <devspec> [<attrname>]
deleteattr lamp follow-on-for-timer
deleteattr lamp
delete <devspec>
delete lamp
get <devspec> <type-specific>
get <device> ?
getstate <devspec>
getstate lamp
state:1
getstate fl
ack:0 actuator:2 day-temp:21.5 desired-temp:22.5 [...] measured-temp:22.9 [...]
Note: to use this command copy the file contrib/getstate/99_getstate.pm into
your FHEM directory.
include <filename>
inform [on|off|timer|raw]
updatefhem [backup] [filename]
CULflash <CUL-Name> <CUL-Version>
CULflash CUL CUL_V3
list [devspec] [value]
fhem> list
Type list for detailed info.
Internal:
global (Internal)
FHZ:
FHZ (fhtbuf: 23)
FS20:
Btn4 (on-old-for-timer)
Roll1 (on)
Stehlampe (off)
FHT:
fl (measured-temp: 21.1 (Celsius))
KS300:
out1 (T: 2.9 H: 74 W: 2.2 R: 8.2 IR: no)
at:
at_rollup (Next: 07:00:00)
notify:
ntfy_btn4 (active)
FileLog:
avglog (active)
If specifying name
, then a detailed status for name
will be displayed, e.g.:
fhem> list fl
Internals:
CODE 5102
DEF 5102
NAME fl
NR 15
STATE measured-temp: 21.1 (Celsius)
TYPE FHT
IODev FHZ
Attributes:
room Heizung
Readings:
2006-11-02 09:45:56 actuator 19%
[...]
modify <name> <type-dependent-options>
define lampon at 19:00 set lamp on
modify lampon *19:00
modify lampon 19:00 set lamp on-for-timer 16
quit
quit
reload <module>
reload 99_PRIV
rename <oldname> <newname>
rename FHT_1234 fht.kitchen
rereadcfg
rereadcfg
save [<configfile>]
set <devspec> <type-specific>
set <name> ?
setstate <devspec> <value>
<name>
as shown in paranthesis in the
list command
to <value>
without sending any signals to the device
itself. This command is also used in the statefile.
See the Device specification section for details on
<devspec>.
shutdown
shutdown
trigger <devspec> <state>
trigger btn3 on
sleep <sec>
sleep 0.5
notify btn3 set lamp toggle;;sleep 0.5;;set lamp toggle
xmllist
fhem> xmllist <FHZINFO> <internal_LIST> <internal name="global" state="internal" sets="" attrs="room configfile logfile ..."> <INT key="DEF" value="<no definition>"/> <INT key="NR" value="0"/> <INT key="STATE" value="internal"/> [...]
FHEM
. The path
does not contain the directory FHEM. Upon setting the
attribute, the directory will be scanned for filenames of the form
NN_<NAME>.pm, and make them available for device definition under
<NAME>. If the first device of type <NAME> is defined, the
module will be loaded, and its function with the name
<NAME>_Initialize will be called. Exception to this rule are
modules with NN=99, these are considered to be utility modules
containing only perl helper functions, they are loaded at startup (i.e.
modpath attribute definition time).
<number>
for incoming
connections. To offer at least a little bit of security, the server
will only listen for connections from the localhost per default. If
there is a second value "global" then the server will listen for
non-localhost connections too.define <name> FHZ <serial-device>
define
<name> FHZ <serial-device> strangetty
set FHZ <variable> [<value>]
value
is one of:define fhz_timer at +*00:01:00 set FHZ time
set FHZ initfull
set FHZ reopen
initfull
issues the initialization sequence for the FHZ
device:get FHZ init2 get FHZ serial set FHZ initHMS set FHZ initFS20 set FHZ time set FHZ raw 04 01010100010000
reopen
closes and reopens the serial device port. This
implicitly initializes the FHZ and issues the
initfull
command sequence.stopHMS
probably is the inverse of initHMS
(I don't have authoritative info on what exactly it does).close
closes and frees the serial device port until you open
it again with open
, e.g. useful if you need to temporarily
unload the ftdi_sio kernel module to use the bit-bang mode.get FHZ <value>
value
is one of:list FHZ
fhtbuf
returns the free memory in this buffer (in hex),
an empty buffer in the FHZ1000 is 2c (42 bytes), in the FHZ1300 is 4a
(74 bytes). A message occupies 3 + 2x(number of FHT commands) bytes,
this is the second reason why sending multiple FHT commands with one
set is a good idea. The first reason is, that
these FHT commands are sent at once to the FHT.
define <name> FS20 <housecode> <button>
[fg <fgaddr>] [lm <lmaddr>] [gm FF]
<housecode>
is a 4 digit hex or 8 digit ELV4 number,
corresponding to the housecode address.<button>
is a 2 digit hex or 4 digit ELV4 number,
corresponding to a button of the transmitter.<fgaddr>
specifies the function group.
It is a 2 digit hex or 4 digit ELV address. The first digit of the hex
address must be F or the first 2 digits of the ELV4 address must be
44.<lmaddr>
specifies the local
master. It is a 2 digit hex or 4 digit ELV address. The last digit of the
hex address must be F or the last 2 digits of the ELV4 address must be
44.define lamp FS20 7777 00 fg F1 gm F
define roll1 FS20 7777 01
define otherlamp FS20 24242424 1111 fg 4412 gm 4444
define otherroll1 FS20 24242424 1114
set <name> <value> [<time>]
value
is one of:dim06% dim12% dim18% dim25% dim31% dim37% dim43% dim50% dim56% dim62% dim68% dim75% dim81% dim87% dim93% dim100% dimdown dimup dimupdown off off-for-timer on # dimmer: set to value before switching it off on-for-timer # see the note on-old-for-timer # set to previous (before switching it on) ramp-on-time # time to reach the desired dim value on dimmers ramp-off-time # time to reach the off state on dimmers reset sendstate timer toggle # between off and previous dim val on-till # Special, see the noteExamples:
set lamp on
set lamp1,lamp2,lamp3 on
set lamp1-lamp3 on
set lamp on-for-timer 12
time
argument ranges from 0.25sec to 4 hours and
16 minutes.
As the time is encoded in one byte there are only 112 distinct
values, the resolution gets coarse with larger values. The program
will report the used timeout if the specified one cannot be set
exactly. The resolution is 0.25 sec from 0 to 4 sec, 0.5 sec from 4
to 8 sec, 1 sec from 8 to 16 sec and so on. If you need better
precision for large values, use at which has a 1
sec resolution.
attr store eventMap on:open off:closed
attr store eventMap /on-for-timer 10:open/off:closed/
set store open
a-z 0-9
and -
(dash),
other characters should be ommited. Here is a list of "official"
devices:define <name> FHT <housecode>
<housecode>
is a four digit hex number,
corresponding to the address of the FHT80b device.
define wz FHT 3232
set <name> <valuetype> <value>
value
is one of:desired-temp day-temp night-temp report1 report2 refreshvalues mode holiday1 holiday2 # Not verified manu-temp # No clue what it does. year month day hour minute time date lowtemp-offset # Alarm-Temp.-Differenz windowopen-temp mon-from1 mon-to1 mon-from2 mon-to2 tue-from1 tue-to1 tue-from2 tue-to2 wed-from1 wed-to1 wed-from2 wed-to2 thu-from1 thu-to1 thu-from2 thu-to2 fri-from1 fri-to1 fri-from2 fri-to2 sat-from1 sat-to1 sat-from2 sat-to2 sun-from1 sun-to1 sun-from2 sun-to2Examples:
set wz desired-temp 22.5
set fl desired-temp 20.5 day-temp 19.0 night-temp 16.0
measured-temp actuator actuator1...actuator8
warnings
fhtbuf
entry in the
get
section.*-temp
values need a temperature
as argument, which will be rounded to 0.5 Celsius.mode
is one of auto, manual, holiday or
holiday_short.
*-from1/*-from2/*-to1/*-to2
valuetypes need a time
spec as argument in the HH:MM format. They define the periods, where
the day-temp is valid. The minute (MM) will be rounded to 10, and
24:00 means off.
define fht_sync at +*3:30 set TYPE=FHT time
report1
with parameter 255 requests all settings for
monday till sunday to be sent. The argument is a bitfield, to request
unique values add up the following:
report2
with parameter 255 requests the following
settings to be reported: day-temp night-temp windowopen-temp
lowtemp-offset desired-temp measured-temp mode warnings.
The argument is (more or less) a bitfield, to request unique values
add up the following:
lowtemp-offset
needs a temperature as argument, valid
values must be between 1.0 and 5.0 Celsius.desired-temp - measured-temp >
lowtemp-offset
in a room for at least 1.5 hours after the last
desired-temp change. desired-temp,mode,report1,report2,
holiday1,holiday2,day-temp,night-temp, [all other commands]
retrycount
times if after 240 seconds
no confirmation message is received from the corresponding FHT
device.define <name> FHT <housecode> [IODev]
<housecode>
is a four digit hex number,
and must have the following relation to the housecode of the corresponding CUL
device:
<IODev>
must be specified if the last defined CUL device
is not the one to use. Usually this is done voa the IODev attribute, but as the address checked is performed
at the definition, we must use an exception here.
define wz FHT8V 3232
define <name> PID sensor[:reading:regexp] actor[:cmd:min:max] [p i d]
sensor[:reading:regexp]
specifies the sensor, which is an
already defined fhem device, e.g. a S300TH temperature sensor. The reading
and regexp fields are necessary only for unknown devices (currently CUL_WS and HMS devices are "known").
Reading specifies the READINGS field of the sensor, and the regexp extracts
the number from this field. E.g. for the complete definition for a CUL_WS
device is: s300th_dev:temperature:([\d\.]*)
actor[:cmd:min:max]
specifies the actor, which is an
already defined fhem device, e.g. an FHT8V valve. The cmd, min and max
fields are necessary only for unknown devices (currently FHT8V is "known"). cmd specifies the command name for the
actor, min the minimum value and max the maximum value. The complete
definition for an FHT8V device is:fht8v_dev:valve:0:100
define wz_pid PID wz_th wz_fht8v
define <name> CUL_FHTTK <devicecode>
<devicecode>
is a six digit hex number, given to the FHT80 TF during
production, i. e. it is not changeable. (Yes, it keeps this code after changing batteries
as well.)define TK_TEST CUL_FHTTK 965AB0
define <name> HMS <housecode>
<housecode>
is a four digit hex number,
corresponding to the address of the HMS device.
define temp HMS 1234
define <name> HMLAN <ip-address>[:port]
The CUL/CUR/CUN is a family of RF devices sold by busware.de.
With the opensource firmware (see this link) they are capable
to receive and send different 868MHz protocols (FS20/FHT/S300/EM/HMS).
It is even possible to use these devices as range extenders/routers, see the
CUL_RFR module for details.
Some protocols (FS20, FHT and KS300) are converted by this module so that the same logical device can be used, irrespective if the radio telegram is received by a CUL or an FHZ device. Other protocols (S300/EM) need their own modules. E.g. S300 devices are processed by the CUL_WS module if the signals are received by the CUL, similarly EMWZ/EMGZ/EMEM is handled by the CUL_EM module. It is possible to attach more than one device in order to get better reception, fhem will filter out duplicate messages. Note: this module may require the Device::SerialPort or Win32::SerialPort module if you attach the device via USB and the OS sets strange default parameters for serial devices. |
define <name> CUL <device> <housecode>
fhtbuf
returns the free memory in this buffer (in hex),
an empty buffer in the CUL-V2 is 74 bytes, in CUL-V3/CUN 200 Bytes.
A message occupies 3 + 2x(number of FHT commands) bytes,
this is the second reason why sending multiple FHT commands with one
set is a good idea. The first reason is, that
these FHT commands are sent at once to the FHT.
define <name> CUL_WS <code> [corr1...corr4]
define <name> CUL_TX <code> [corr]
define <name> CUL_EM <code> [corr1 corr2
CostPerUnit BasicFeePerMonth]
define emwz 1 75 900 0.15 12.50and the Log looks like:
CUM_DAY: 6.849 CUM: 60123.4 COST: 1.02 CUM_MONTH: 212.319 CUM: 60123.4 COST: 44.34Tipp: You can configure your EMWZ device to show in the CUM column of the STATE reading the current reading of your meter. For this purpose: multiply the current reading (from the real device) with the corr1 value (RperKW), and substract the RAW CUM value from it. Now set the basis reading of your EMWZ device (named emwz) to this value.
The CUL_IR module interprets Infrared messages received by the CUN/CUNO/CUNOv2/TuxRadio.
Those devices can receive Infrared Signals from basically any Remote controller and will transform
that information in a so called Button-Code Define define <name> CUL_IR <IODev> <IODev> is the devicename of the IR-receivung device, e.g. CUNO1. Your definition should look like E.g.: define IR-Dev CUL_IR CUNO1Set
ESA2000
Define define <name> ESA2000 <code>
[base1 base2] <code> is the 4 digit HEX code identifying the devices. base1/2 is added to the total kwh as a base (Hoch- und Niedertarifzählerstand). Set
Get
Attributes CUL_HM
Prerequisites: Define define <name> CUL_HM <6-digit-hex-code>
Normally this command is generated by the autocreate module, together with the necessary hmClass and subType attributes. Usually you issue a hmPairForSec command and press the corresponding button on the device to be paired, or issue a hmPairSerial set command if the device is a receiver and you know its serial number. Autocreate will then create a fhem device and set all necessary attributes. Without pairing the device will not accept messages from fhem. If you cannot use autocreate, then you have to specify: Set
General commands (available to most hm devices): subType (i.e family) dependent commands: Debugging: Get
Attributes Generated events: CUL_HOERMANN
Define define <name> CUL_HOERMANNEM <10-digit-hex-code>
Set
Get
Attributes CUL_RFR
Define define <name> CUL_RFR <own-id> <base-id> <own-id> is the id of the RFR CUL not connected to the PC, <base-id> is the id of the CUL connected to the PC. Both parameters have two characters, each representing a one byte hex number. Example: set MyCUL raw ui0100 # Now replace the base CUL with the RFR CUL set MyCUL raw ui0201 # Reattach the base CUL to the PC and attach the RFR CUL to a USB power supply define MyRFR CUL_RFR 02 01 Set
Get
Attributes EnOcean
Define define <name> EnOcean <ID>
Define an EnOcean device, connected via a TCM. The <ID> parameter is an 8 digit hex number. For remotes and sensors the autocreate module may help you. Example: define switch1 EnOcean ffc54500 Set Get
Attributes
Generated events:
EM
define <name> EM <em1010pc-device>
Define a EM1010PC USB device. As the EM1010PC was not designed to be used with a PC attached to it all the time, it won't transmit received signals automatically, fhem has to poll it every 5 minutes. Currently there is no way to read the internal log of the EM1010PC with fhem, use the program em1010.pl in the contrib directory for this purpose. Examples: define em EM /dev/elv_em1010pc Set set EM <value>
where value is either time or reset.If time has arguments of the form YYYY-MM-DD HH:MM:SS, then the specified time will be set, else the time from the host. Note: after reset you should set the time. Get get EM <value>
where value is either version or time.
EMWZ
define <name> EMWZ <device-number>
Define up to 4 EM1000WZ attached to the EM1010PC. The device number must be between 1 and 4. Defining an EMWZ will schedule an internal task, which reads the status of the device every 5 minutes, and triggers notify/filelog commands. Example: define emwz EMWZ 1 Set set EMWZdevice <param> <value> where param is one of: Get get EMWZ status
This is the same command which is scheduled every 5 minutes internally. Attributes EMGZ
define <name> EMGZ <device-number>
Define up to 4 EM1000GZ attached to the EM1010PC. The device number must be between 9 and 12. Defining an EMGZ will schedule an internal task, which reads the status of the device every 5 minutes, and triggers notify/filelog commands. Example: define emgz EMGZ 9 set EMGZdevice <param> <value> where param is: Get get EMGZ status
This is the same command which is scheduled every 5 minutes internally. Attributes EMEMDefine define <name> EMEM <device-number>
Define up to 4 EM1000EM attached to the EM1010PC. The device number must be between 5 and 8. Defining an EMEM will schedule an internal task, which reads the status of the device every 5 minutes, and triggers notify/filelog commands. Note: Currently this device does not support a "set" function. Example: define emem EMEM 5 Set
Get get EMEM status
This is the same command which is scheduled every 5 minutes internally. Attributes KM271
Note: this module requires the Device::SerialPort or Win32::SerialPort module. Define define <name> KM271 <serial-device-name>
Example: define KM271 KM271 /dev/ttyS0 Set set KM271 <param> [<value>] where param is one of: Get
Attributes Generated events: As I cannot explain all the values, I logged data for a period and plotted each received value in the following logs: All of these events are reported directly after initialization (or after requesting logmode), along with some 60 configuration records (6byte long each). About 20 parameters from these records are reverse engeneered, they all start with CFG_. KS300
This module services messages received by the FHZ device, if you use one of the other alternetives, see the WS300 or CUL_WS entries. Note: The KS555 is also reported to work. Define define <name> KS300 <housecode> [ml/raincounter [wind-factor]]
<housecode> is a four digit hex number,
corresponding to the address of the KS300 device, right now it is ignored.
The ml/raincounter defaults to 255 ml, but it must be specified if you wish
to set the wind factor, which defaults to 1.0.
Examples: define ks1 KS300 1234 Set
Get
Attributes CM11
Define define <name> CM11 <serial-device>
CM11 is the X10 module to interface X10 devices with the PC. The current implementation can evaluate incoming data on the powerline of any kind. It can send on, off, dimdown and dimup commands. The name of the serial-device depends on your distribution. If serial-device is none, then no device will be opened, so you can experiment without hardware attached. If you experience problems (for verbose 4 you get a lot of "Bad CRC message" in the log), then try to define your device as define <name> FHZ <serial-device> strangetty Example: define x10if CM11 /dev/ttyUSB3 set <name> reopen
Reopens the serial port. Get get <name> fwrev
Reads the firmware revision of the CM11 device. Returns error
if the serial connection to the device times out. Can be used for error
detection.
get <name> time
Reads the internal time of the device which is the total uptime (modulo one year), since fhem sets the time to 0.00:00:00 if the device requests the time to be set after being powered on. Returns error
if the serial connection to the device times out. Can be used for error
detection.
Attributes X10
define <name> X10 <model> <housecode>
<unitcode>
Defines an X10 device via its model, housecode and unitcode. Notes: Examples: define lamp1 X10 lm12 N 10 define pump X10 am12 B 7 define lamp2 X10 lm15 N 11 Set set <name> <value> [<argument>]
where value is one of:dimdown # requires argument, see the note dimup # requires argument, see the note off on on-till # Special, see the note on-for-timer # Special, see the noteExamples: set lamp1 dimup 10 set lamp1,lamp2 off set pump off set lamp2 on-till 19:59 set lamp2 on-for-timer 00:02:30 Notes:
Get
Attributes LIRC
Note: this module needs the Lirc::Client perl module. Define
Example:
begin prog = fhem button = pwr config = IrPower endand you press the pwr button the IrPower toggle event occures at fhem. define IrPower01 notify IrPower set lamp toggleturns the lamp on and off. If you want a faster reaction to keypresses you have to change the defaultvalue of readytimeout from 5 seconds to e.g. 1 second in fhem.pl Set
Get
Attributes
WS300Define define WS300Device WS300 <serial device> or define <devname> WS300 [0-9] The first line is mandatory if you have a WS300 device: it defines the input device with its USB port. The name of this device is fixed and must be WS300Device. It must be the first defined WS300 device. For each additional device (with number 0 to 9) you have to define another WS300 device, with an arbitrary name. The WS300 device which reports the readings will be defined with the port number 9, an optional KS300 with the port number 8. Examples: define WS300Device WS300 /dev/ttyUSB1 define ash2200.1 WS300 0 define ks300 WS300 8 define ws300 WS300 9 Set set WS300Device <interval(min.)> <height(m)> <rainvalume(ml)>
Set some WS300 configuration parameters.
Attributes
WeatherDefine define <name> Weather <location> [<interval> [en|de|fr|es]] Defines a virtual device for weather forecasts. You need to have the perl module Weather::Google installed to use this device. If you do not have it, use cpan -i Weather::Google to install it. A Weather device periodically gathers current and forecast weather conditions from the Google Weather API. The parameter location is any string that is recognized as a
location, either a town name or a zip code. Browse to the URL
http://www.google.de/ig/api?weather=location&hl=en
to see the raw output for your location.The optional parameter interval is the time between subsequent updates
in seconds. It defaults to 3600 (1 hour).The optional language parameter may be one of en , de , fr ,
es . It determines the natural language in which the forecast information appears.
It defaults to en. If you want to set the language you also have to set the interval.Examples: define MyWeather Weather "Frankfurt,HE" define Forecast Weather "Amsterdam,NL" 1800 define weather Weather "30000,France" 3600 fr Set
Get get <name> <reading> Valid readings and their meaning (? can be one of 0, 1, 2, 3 and stands for today, tomorrow, ...):
Attributes
USF1000
Define define <name> USF1000 <geometry>
<geometry> determines the form of the tank and the
position of the sensor. The following geometries are currently
supported:cub stands for a cuboid whose base is <length> × <width>.
cylv stands for a vertical cylinder whose diameter is <diameter>.
<height> is the distance of the surface of the liquid from the ground
if the tank is full. <offset> is the distance of the sensor relative to
the surface of the liquid. All quantities are expressed in meters.Example: define MyTank USF1000 cylv 2 1 0.3 : a cylindrical water tank with
2 meters diameter. The water stands 1 meter high if the tank is full. The
sensor is fixed 1,3 meters above ground.Set
Get
Attributes WEBCOUNT
Define define <name> WEBCOUNT <ip-address> <port> <delay>
Defines an WEBCOUNT device (Box with 6 count pulses, www.wut.de) via ip address. The device is pooled (delay interval). Examples: define pump WEBCOUNT 192.168.8.200 1 60 WEBIO
Define define <name> WEBIO <ip-address> <port> <delay>
Defines an Web-IO device (Box with 2 Analog-In/Out 0..10V, www.wut.de) via ip address. The status of the device is also pooled (delay interval). Examples: define pumpspeed WEBIO 192.168.8.200 1 60 Set set <name> <value>
where value is one of:0.00 - 10.00Examples: set pumpspeed 6.75 WEBIO_12DIGITAL
Define define <name> WEBIO_12DIGITAL <ip-address> <outputport> <delay>
Defines an Web-IO-Digital device (Box with up to 12 digital in/outputs, www.wut.de) via ip address. The status of the device is also pooled (delay interval). Examples: define motor1 WEBIO_12DIGITAL 192.168.8.200 1 60 Set set <name> <value>
where value is one of:on offExamples: set motor1 on VantagePro2
Define define <name> <ip-address> <port> <delay>
Defines a Davis VantagePro2 weatherstation attached on transparent ethernet/usb|serial server accessable by telnet. Examples: define AUSSEN.wetterstation VantagePro2 192.168.8.127 4999 60
fhem> list AUSSEN.wetterstation ALL3076
Define define <name> ALL3076 <ip-address>
Defines an Allnet 3076 device (Dimmable lightswitch) via its ip address or dns name Examples: define lamp1 ALL3076 192.168.1.200 Set set <name> <value>
where value is one of:dimdown dim10% dim20% dim30% dim40% dim50% dim60% dim70% dim80% dim90% dim100% dim[0-100]% dimup off on toggleExamples: set lamp1 on set lamp1 dim11% set lamp2 toggle Notes:
ALL4000T
Define define <name> ALL4000T <ip-address> <port> <delay>
Defines a temperature sensor connected on an Allnet 4000 device via its ip address and port. Use the delay argument to define the delay between polls. Examples: define AUSSEN.POOL.TEMP.vorlauf ALL4000T 192.168.68.20 t2 120 ALL4027
Define define <name> ALL4027 <ip-address> <port> <relay_nr> <delay>
Defines an Allnet 4027 device (Box with 8 relays) connected to an ALL4000 via its ip address. The status of the device is also pooled (delay interval), because someone else is able to change the state via the webinterface of the device. Examples: define lamp1 ALL4027 192.168.8.200 0 7 60 Set set <name> <value>
where value is one of:off on on-for-timer <Seconds> toggleExamples: set poolpump on Notes:
BS
The state contains the brightness in % (reading brightness ) and
the brightness in lux (reading lux ). The flags
reading is always zero. The meaning of these readings is explained in more
detail on the above mentioned wiki page.Define define <name> BS <sensor#> [<RExt>]
<sensor#> is the number of sensor in the brightness
sensor address system that runs from 1 to 9.<RExt> is the value of the resistor on your brightness
sensor in Ω (Ohm). The brightness reading in % is proportional to the resistance, the
lux reading is proportional to the resistance squared. The value is
optional. The default resistance is RExt= 50.000Ω.Example: define bs1 BS 1 40000 Set
Get
Attributes SCIVTDefine define <name> SCIVT <SCD-device>
Define a SCD series solar controler device. Details see here. You probably need a Serial to USB controller like the PL2303. Defining an SCIVT device will schedule an internal task, which reads the status of the device every 5 minutes, and triggers notify/filelog commands. Note: Currently this device does not support a "set" function, only a single get function which reads the device status immediately. Example: define scd SCIVT /dev/ttyUSB2
Get get SCVIT data
Attributes ECMD
A physical ECMD device can host any number of logical ECMD devices. Logical devices are defined as ECMDDevices in fhem. ADC 0 to 3 and I/O port 0 to 3 of the above mentioned board are examples of such logical devices. ADC 0 to 3 all belong to the same device class ADC (analog/digital converter). I/O port 0 to 3 belong to the device class I/O port. By means of extension boards you can make your physical device drive as many logical devices as you can imagine, e.g. IR receivers, LC displays, RF receivers/transmitters, 1-wire devices, etc.
Defining one fhem module for any device class would create an unmanageable
number of modules. Thus, an abstraction layer is used. You create a device class
on the fly and assign it to a logical ECMD device. The
class definition
names the parameters of the logical device, e.g. a placeholder for the number
of the ADC or port, as well as the get and set capabilities. Worked examples
are to be found in the documentation of the ECMDDevice device.
define <name> ECMD telnet <IPAddress:Port> or define <name> ECMD serial <SerialDevice>[<@BaudRate>]
Defines a physical ECMD device. The keywords telnet or
serial are fixed.Examples: define AVRNETIO ECMD telnet 192.168.0.91:2701 define AVRNETIO ECMD serial /dev/ttyS0 define AVRNETIO ECMD serial /sev/ttyUSB0@38400 set <name> classdef <classname> <filename>
Creates a new device class <classname> for logical devices.
The class definition is in the file <filename> . You must
create the device class before you create a logical device that adheres to
that definition.
Example: define AVRNETIO classdef /etc/fhem/ADC.classdef set <name> reopen
Closes and reopens the device. Could be handy if connection is lost and cannot be reestablished automatically. get <name> raw <command>
Sends the command <command> to the physical ECMD device
<name> and reads the response.
Attributes Class definition
The following commands are recognized in the device class definition: ECMDDeviceDefine define <name> ECMDDevice <classname> [<parameter1> [<parameter2> [<parameter3> ... ]]]
Defines a logical ECMD device. The number of given parameters must match those given in the class definition of the device class <classname> .
Examples: define myADC ECMDDevice ADC define myRelais1 ECMDDevice relais 8 set <name> <commandname> [<parameter1> [<parameter2> [<parameter3> ... ]]]
The number of given parameters must match those given for the set command <commandname> definition in
the class definition.If set <commandname> is invoked the perl special in curly brackets from the command definition
is evaluated and the result is sent to the physical ECMD device.
Example: set myRelais1 on get <name> <commandname> [<parameter1> [<parameter2> [<parameter3> ... ]]]
The number of given parameters must match those given for the get command <commandname> definition in
the class definition.If get <commandname> is invoked the perl special in curly brackets from the command definition
is evaluated and the result is sent to the physical ECMD device. The response from the physical ECMD device is returned
and the state of the logical ECMD device is updated accordingly.
Example: get myADC value 3
The class definition file /etc/fhem/ADC.classdef looks as follows:
get value cmd {"adc get %channel"}
In the fhem configuration file or on the fhem command line we do the following:
define AVRNETIO telnet 192.168.0.91:2701 # define the physical device
The get command is evaluated as follows: get value has one named parameter
channel . In the example the literal 1 is given and thus %channel
is replaced by 1 to yield "adc get 1" after macro substitution. Perl
evaluates this to a literal string which is send as a plain ethersex command to the AVR-NET-IO. The
board returns something like 024 for the current value of analog/digital converter number 1.
The class definition file /etc/fhem/relais.classdef looks as follows:
params pinmask
In the fhem configuration file or on the fhem command line we do the following:
define AVRNETIO telnet 192.168.0.91:2701 # define the physical device
The set command is evaluated as follows: %pinmask
is replaced by 8 to yield
"io set ddr 2 ff\nioset port 2 08\nwait 1000\nio set port 2 00" after macro substitution. Perl
evaluates this to a literal string which is send as a plain ethersex command to the AVR-NET-IO line by line.
M232Define define <name> M232 <m232-device>
Define a M232 device. You can attach as many M232 devices as you like. A M232 device provides 6 analog inputs (voltage 0..5V with 10 bit resolution) and 8 bidirectional digital ports. The eighth digital port can be used as a 16 bit counter (maximum frequency 3kHz). The M232 device needs to be connected to a 25pin sub-d RS232 serial port. A USB-to-serial converter works fine if no serial port is available. Examples: define m232 M232 /dev/ttyUSB2 set <name> stop
Stops the counter. set <name> start
Resets the counter to zero and starts it. set <name> octet
Sets the state of all digital ports at once, value is 0..255. set <name> io0..io7 0|1
Turns digital port 0..7 off or on. get <name> [an0..an5]
Gets the reading of analog input 0..5 in volts. get <name> [io0..io7]
Gets the state of digital ports 0..7, result is 0 or 1. get <name> octet
Gets the state of all digital ports at once, result is 0..255. get <name> counter
Gets the number of ticks of the counter since the last reset. The counter wraps around from 65,535 to 0 and then stops. See M232Counter for how we care about this. M232Counter
define <name> M232Counter [unit [factor [deltaunit [deltafactor]]]]
Define at most one M232Counter for a M232 device. Defining a M232Counter will schedule an internal task, which periodically reads the status of the counter, and triggers notify/filelog commands. unit is the unit
name, factor is used to calculate the reading of the counter
from the number of ticks. deltaunit is the unit name of the counter
differential per second, deltafactor is used to calculate the
counter differential per second from the number of ticks per second.Default values: Note: the parameters in square brackets are optional. If you wish to specify an optional parameter, all preceding parameters must be specified as well. Examples: define counter M232Counter turns define counter M232Counter kWh 0.0008 kW 2.88
(one tick equals 1/1250th kWh)Do not forget to start the counter (with set .. start for
M232) or to start the counter and set the reading to a specified value
(with set ... value for M232Counter).To avoid issues with the tick count reaching the end point, the device's internal counter is automatically reset to 0 when the tick count is 64,000 or above and the reading basis is adjusted accordingly. set <name> value <value>
Sets the reading of the counter to the given value. The counter is reset and started and the offset is adjusted to value/unit. set <name> interval <interval>
Sets the status polling interval in seconds to the given value. The default is 60 seconds. get <name> status
Gets the reading of the counter multiplied by the factor from the define statement. Wraparounds of the counter are accounted for
by an offset (see reading basis in the output of the
list statement for the device).
M232VoltageDefine define <name> M232Voltage [an0..an5] [unit [factor]]
Define as many M232Voltages as you like for a M232 device. Defining a M232Voltage will schedule an internal task, which reads the status of the analog input every minute, and triggers notify/filelog commands. unit is the unit name, factor is used to
calibrate the reading of the analog input.Note: the unit defaults to the string "volts", but it must be specified if you wish to set the factor, which defaults to 1.0. Example: define volt M232Voltage an0 define brightness M232Voltage an5 lx 200.0
Get get <name> status
xxLG7000
Define define <name> xxLG7000 <serial-device>
Defines a serial link to a TV set of LG's xxLG70yy (e. g. 47LG7000) series and similar TV sets from LG. As of January 2010, the following TV sets should be compatible: These TV sets feature a serial connector which can officially be used to control the TV set (see your Onwer's Manual, there's an Appendix labelled "External Control Device setup", referening to cabling and command set). The xxLG7000 module is the FHEM module to actually utilize this. (BTW, those TVs run Linux internally ;)) To exercise control over your TV set, use the LGTV module and bind it ("attr <LGTV-name> IODev <xxLG7000-name>") to xxLG7000. Examples: define myLG7k xxLG7000 /dev/ttyUSB1
LGTV
define <name> LGTV
This module is expected to work with xxLG7000 as it's IODev. With LGTV and a compatible hardware module (currently, there's only xxLG7000), you are able to power your TV set on and off, query it's power state, select the input (AV, RGB, Composites, analogue TV, DVB-T, HDMI) or mute/unmute the volume. Defining a LGTV device will schedule an internal task, which periodically reads the status of the TV set (power state; if power is on, query the selected input) and triggers notify/filelog commands. Example: define 47LG7000 LGTV attr 47LG7000 IODev myLG7k
set <name> <what> <value>
Currently, the following commands are defined; not all may be available on a given TV set. An error messages should be recorded if e. g. the input in question is not usable. power on power off input AV1 input AV2 input AV3 input AV3 input Component input RGB input HDMI1 input HDMI2 input HDMI3 input HDMI4 input DVBT input PAL audio mute audio normalGet get <name> <what>
Currently, the following commands are defined; not all may be available on a given TV set. An error messages should be recorded if e. g. the input in question is not usable. power input audioAttributes Implementator's note
OREGON
Define define <name> OREGON <deviceid> <deviceid> is the device identifier of the Oregon sensor. It consists of the sensors name and a one byte hex string (00-ff) that identifies the sensor. The define statement with the deviceid is generated automatically by autocreate. The following sensor names are used: BTHR918, BTHR918N, PCR800 RGR918, RTGR328N, THN132N, THGR228N, THGR328N, THGR918, THR128, THWR288A, THGR810, UV138, UVN800, WGR918, WGR800, WTGR800_A, WTGR800_T. The one byte hex string is generated by the Oregon sensor when is it powered on. The value seems to be randomly generated. This has the advantage that you may use more than one Oregon sensor of the same type even if it has no switch to set a sensor id. For exampple the author uses three BTHR918 sensors at the same time. All have different deviceids. The drawback is that the deviceid changes after changing batteries. Example: define Kaminzimmer OREGON BTHR918N_ab
Set
Get
OWFS
Note: You need the owperl module from http://owfs.org/. Define define <name> OWFS <owserver-ip:port> <model> [<id>]
Define a 1-wire device to communicate with an OWFS-Server. <owserver-ip:port>
<model>
DS1420, DS9097 (for passive Adapter)
<id>
If the owserver-ip:port is called none , then
no device will be opened, so you can experiment without hardware attached.Example: #define an active Adapter: #define a passive Adapter:
Get get <name> <value>
where value is one of (not supported by passive Devices e.g. DS9097):get DS9490R type DS9490R type => DS1420 get DS9490R address DS9490R address => 8193302D0000002B
OWTEMP
Note: Please define an OWFS device first. Define define <name> OWTEMP <id> [<interval>] [<alarminterval>]
Define a 1-wire Digital Thermometer device. <id>
Set <id> to none for demo mode.
<interval>
<alarminterval>
Currently supported type: DS18S20 .Example: define KG.hz.TF.01 OWTEMP 14B598010800 300 60 set <name> <value>
where value is one of:Get get <name> <value>
where value is one of:get KG.hz.TF.01 type KG.hz.TF.01 type => DS18S20 get KG.hz.TF.01 temperature KG.hz.TF.01 temperature => 38.2500 (Celsius)
RFXCOM
RFXMETER
Define define <name> RFXMETER <deviceid> [<scalefactor>] [<unitname>] <deviceid> is the device identifier of the RFXMeter sensor and is a one byte hexstring (00-ff). <scalefactor> is an optional scaling factor. It is multiplied to the value that is received from the RFXmeter sensor. <unitname> is an optional string that describes the value units. It is added to the Reading generated to describe the values. Example: define RFXWater RFXMETER 00 0.5 ltr
define RFXPower RFXMETER 01 0.001 kwh
define RFXGas RFXMETER 02 0.01 cu_m
Set
Get
RFXX10REC
Define define <name> RFXX10REC <type> <deviceid> <devicelog> [<deviceid> <devicelog>] <type>
X10 security devices: <deviceid>
<devicelog>
<deviceid2>
<devicelog2>
<deviceid2> .
Example: define livingroom_window RFXX10REC ds10a 72cd Window
define motion_sensor1 RFXX10REC ms10a 55c6 motion
define smoke_sensor1 RFXX10REC sd90 54d3 Smoke 54d3 Smoketest
define motion_sensor2 RFXX10REC ms14a A1 motion A2 light
Set
Get
WS2000
Define define <name> WS2000 <device_to_connect>
Define a WS2000 series raw receiver device sold by ELV. Details see here. Unlike 86_FS10.pm it will handle the complete device communication itself and doesnt require an external program. For this reason you can now use this also on windows. This Device will be usually connect to a serial port, but you can also define a raw network redirector like lantronix XPORT(TM). Note: Currently this device does not support a "set" function Attributes: Example: define WS2000 WS2000 /dev/ttyS0 define WS2000 WS2000 xport:10001 attr WS2000 rain 366 : use factor 366 ml/count for rain sensor S2000R
Get get <name> list
Gets the last reading of all received sensord get <name> [TH0..TH7, T0..T7, I0..I7, R0..R7, W0..W7, L0..L7, P0..P7,LAST,RAW] get the last reading for the name sensor, LAST : Last received Sensor
RAW : original Data from interface
WS3600Define define <name> WS3600 </path/to/fetch3600>
Define a WS3600 series weather station (Europe Supplies, technotrade, etc; refer to Wetterstationen.info (german) for details on this model); the station is queried by means of an external program, fetch3600. It talks to the attached weather station (several WS do supply an RS323 interface but seem to use some kind of "morse code" on the RTS, CTS wires instead of using propper serial communication (RX, TX); it's no use to recode that crap into FHEM when there is a stable package of tools to talk to the station available: open3600) and delivers the current readings line by line as reading-value-pairs. These are read in and translated into more readable names for FHEM by the module WS3600.pm. As the WS3600 is rather similar to the WS2300 and open3600 basically is a modified offspring of open2300, by exchanging the /path/to/fetch3600 with /path/to/fetch2300 this module should be able to handle the WS2300 was well. Currently, it is expected that the WS is attached to the local computer and fetch3600 is run locally. Basically the executable called needs to supply on stdout an output similar to what fetch3600 returns; how to implement a "networked setup" is left as an excercise to the reader. For the records, this is an output of fetch3600: Date 14-Nov-2009 Time 10:50:22 Ti 22.8 Timin 20.8 Timax 27.9 TTimin 10:27 DTimin 15-10-2009 TTimax 23:31 DTimax 20-08-2009 To 14.2 Tomin -0.4 Tomax 35.6 TTomin 07:03 DTomin 15-10-2009 TTomax 16:52 DTomax 20-08-2009 DP 9.2 DPmin -2.2 DPmax 20.3 TDPmin 07:03 DDPmin 15-10-2009 TDPmax 11:58 DDPmax 20-08-2009 RHi 48 RHimin 32 RHimax 57 TRHimin 17:03 DRHimin 21-10-2009 TRHimax 22:24 DRHimax 07-10-2009 RHo 72 RHomin 27 RHomax 96 TRHomin 16:41 DRHomin 20-08-2009 TRHomax 06:28 DRHomax 02-11-2009 WS 0.0 DIRtext WSW DIR0 247.5 DIR1 247.5 DIR2 247.5 DIR3 247.5 DIR4 247.5 DIR5 247.5 WC 14.2 WCmin -0.4 WCmax 35.6 TWCmin 07:03 DWCmin 15-10-2009 TWCmax 16:52 DWCmax 20-08-2009 WSmin 0.0 WSmax 25.6 TWSmin 10:44 DWSmin 14-11-2009 TWSmax 19:08 DWSmax 24-09-2009 R1h 0.00 R1hmax 24.34 TR1hmax 22:34 DR1hmax 07-10-2009 R24h 0.00 R24hmax 55.42 TR24hmax 07:11 DR24hmax 08-10-2009 R1w 29.00 R1wmax 95.83 TR1wmax 00:00 DR1wmax 12-10-2009 R1m 117.58 R1mmax 117.58 TR1mmax 00:00 DR1mmax 01-11-2009 Rtot 3028.70 TRtot 03:29 DRtot 18-09-2005 RP 992.200 AP 995.900 RPmin 970.300 RPmax 1020.000 TRPmin 05:25 DRPmin 04-11-2009 TRPmax 09:19 DRPmax 11-09-2009 Tendency Falling Forecast CloudyThere is no expectation on the readings received from the fetch3600 binary; so, in essence, if you have a similar setup (unsupported, attached weather station and a means to get it's reading into an output similar to above's), you should be able to use WS3600.pm with a custom written script to interface FHEM with your station as well. WS3600.pm only recognizes the above readings (and translates these into, e. g., Temp-inside for Ti for use within FHEM), other
lines are silently dropped on the floor.fetch3600 is available as binary for the Windows OS as well, but I haven't tested operation under that OS, use it at your own risk and you mileage may vary ... Note: Currently this device does not support a "set" function nor anything to "get". The later would be possible to implement if neccessary, though. Implementation of WS3600.pm tries to be nice, that is it reads from the pipe only non-blocking (== if there is data), so it should be safe even to use it via ssh or a netcat-pipe over the Internet, but this, as well, has not been tested yet. Attributes:
Example: define my3600 W36000 /usr/local/bin/fetch360 Set
Get
Attributes
SISPM
Define define <name> SISPM </path/to/sispmctl>
PLEASE NOTE: This module is still work in progess; please treat it as such.
(That is, don't but your central heating on SISPM in a cold winter just yet ;)) Further tests should be done regarding the interaction between "set" commands and the sheduled status reading. (Testing with FIFOs seems as if it's working without blocking nor interference, but that's on a mostly unloaded, fast system.) When using multiple SIS PMs on one host, sispmctl up to and including V 2.7 has a bug: plug-2:# sispmctl -v -s -d 1 -g all -d 2 -g all SiS PM Control for Linux 2.7 (C) 2004, 2005, 2006, 2007, 2008 by Mondrian Nuessle, (C) 2005, 2006 by Andreas Neuper. This program is free software. [...] Gembird #0 is USB device 013.This device is a 4-socket SiS-PM. [...] Gembird #1 is USB device 015.This device is a 4-socket SiS-PM. [...] Accessing Gembird #1 USB device 015 Status of outlet 1: on Status of outlet 2: on Status of outlet 3: on Status of outlet 4: on Error performing requested action Libusb error string: error sending control message: Invalid argument Terminating *** glibc detected *** sispmctl: double free or corruption (fasttop): 0x000251e0 *** [...]Well, the fix is simple and will be sent upstream, but in case it's not incorporated at the time you need it, here it is; it's easy to apply even by hand ;-) --- src/main.c-old 2010-01-19 16:56:15.000000000 +0100 +++ src/main.c 2010-01-19 16:54:56.000000000 +0100 @@ -441,7 +441,7 @@ } break; case 'd': // replace previous (first is default) device by selected one - if(udev!=NULL) usb_close (udev); + if(udev!=NULL) { usb_close (udev); udev=NULL; } devnum = atoi(optarg); if(devnum>=count) devnum=count-1; break; Defines a path to the program "sispmctl", which is used to control (locally attached) "Silver Shield Power Manager" devices. Usually these are connected to the local computer via USB, more than one "sispm" device per computer is supported. (Please note that, due to neglections in their USB driver, AVM's Fritz!Box 7170 (and derivates, like Deutsche Telekom's Speedport W901V) is not able to talk to these devices ...) The communication between FHEM and the Power Manager device is done by using the open source sispmctl program. Thus, for the time being, THIS functionality is only available running FHEM on Linux (or any other platform where you can get the sispmctl program compiled and running). On the bright side: by interfacing via commandline, it is possible to define multiple SISPM devices, e. g. with a wrapper that does execute sispmctl on a remote (Linux) system. And: sispmctl runs happily on Marvells SheevaPlug ;) Please note: if you're not running FHEM as root, you most likely have to make sispmctl setuid root ( chmod 4755 /path/to/sispmctl ) or fiddle with
udev so that the devices of the Power Manager are owned by the user running FHEM.
After defining a SISPM device, a first test is done, identifying attached PMs. If this
succeeds, an internal task is scheduled to read the status every 30 seconds. (Reason
being that someone else could have switched sockets externally to FHEM.)
To actually control any power sockets, you need to define a SIS_PMS
device ;) If autocreate is enabled, those should be autocreated for your convenience as
soon as the first scan took place (30 seconds after the define).
Implementation of SISPM.pm tries to be nice, that is it reads from the pipe only
non-blocking (== if there is data), so it should be safe even to use it via ssh or
a netcat-pipe over the Internet, but this, as well, has not been tested extensively yet.
Attributes: Example: define PMS_Terrarium SISPM /usr/bin/sispmctl
Get
Attributes SIS_PMS
Define define <name> SIS_PMS <serial> <socket>
To securely distinguish multiple attached Power Manager devices, the serial number of those is used. You get these with "sispmctl -s" - or just let autocreate define the sockets attached for you. Examples: define lamp SIS_PMS 01:02:03:04:05 1 define otherlamp SIS_PMS 01:02:03:04:05 3 define tv SIS_PMS 01:01:38:44:55 1
Set set <name> <value> [<time>]
where value is one of:off on toggle on-till # Special, see the note off-till # Special, see the noteExamples: set lamp on set lamp1,lamp2,lamp3 on set lamp1-lamp3 on set hql_lamp on-till 18:45 Notes:
Get
Attributes
IPWE
Define define <name> IPWE <hostname> [<delay>]
Define a IPWE network attached weather data receiver device sold by ELV. Details see here. It's intended to receive the same sensors as WS300 (8 T/H-Sensors and one kombi sensor), but can be accessed via http and telnet. For unknown reason, my try to use the telnet interface was not working neither with raw sockets nor with Net::Telnet module. Therefore i choosed here the "easy" way to simple readout the http page and extract all data from the offered table. For this reason this module doesnt contain any option to configure this device. Note: You should give your sensors a name within the web interface, once they a received the first time. To extract a single sensor simply match for this name or sensor id Attributes: Example: define ipwe IPWE ipwe1 120 attr ipwe delay 600 : 10min between readouts
Get get <name> status
Gets actual data from device for sensors with data get <name> <sensorname>
will grep output from device for this sensorname ITACH_RELAY
Define define <name> ITACH_RELAY <ip-address> <port>
Defines an Global Cache iTach Relay device (Box with 3 relays) via its ip address. Examples: define motor1 ITACH_RELAY 192.168.8.200 1 Set set <name> <value>
where value is one of:off on toggleExamples: set motor1 on Notes:
USBWX
This module was tested with ELV S300TH, ELV ASH2200, ELV KS300, Conrad S555TH and Conrad KS555. Readings and STATE of temperature/humidity sensors are compatible with the CUL_WS module. For KS300/KS555 sensors STATE is compatible with the KS300 module. The module is integrated into autocreate to generate the appropriate filelogs and weblinks automatically. Note: this module requires the Device::SerialPort or Win32::SerialPort module if the devices is connected via USB or a serial port. Define define <name> USBWX <serial device>
Defines USB-WDE1 attached via usb. define <name> USBWX <code> [corr1...corr4] <code> is the code which must be set on the sensor. Valid values are 1 through 8. 9 is used as the sensor id of the ks300 sensor. corr1..corr4 are up to 4 numerical correction factors, which will be added to the respective value to calibrate the device. Note: rain-values will be multiplied and not added to the correction factor. Example: define USBWDE1 USBWX /dev/ttyUSB0 define USBWX_1 USBWX 1 define USBWX_livingroom USBWX 2 define USBWX_ks300 USBWX 9Set
Get
Attributes TCM
As the TCM120 and the TCM310 speak completely different protocols, this module implements 2 drivers in one. It is the "physical" part for the EnOcean module. Define define <name> TCM [120|310] <device> First you have to specify the type of the EnOcean Transceiver Chip , i.e either 120 for the TCM120 or 310 for the TCM310. device can take the same parameters (@baudrate, @directio,
TCP/IP, none) like the CUL, but you probably have
to specify the baudrate: the TCM120 should be opened with 9600 Baud, the
TCM310 with 57600 baud.
Example:
define BscBor TCM 120 /dev/ttyACM0@9600 Set weblink
define <name> weblink [link|fileplot|image|iframe]
<argument>
This is a placeholder used with webpgm2 to be able to integrate links into it, and to be able to put more than one gnuplot/SVG picture on one page. It has no set or get methods. Examples: define homepage weblink link http://www.fhem.de define webcam_picture weblink image http://w.x.y.z/current.jpg define interactive_webcam weblink iframe http://w.x.y.z/webcam.cgi define MyPlot weblink fileplot <logdevice>:<gnuplot-file>:<logfile> Notes:
Get
Attributes FHEM2FHEM
Define define <name> FHEM2FHEM <host:portnr> [LOG:regexp|RAW:devicename]
Connect to the remote fhem on host. portnr is the global port attribute of the remote fhem. The next parameter specifies the connection type: Examples: define ds1 FHEM2FHEM 192.168.0.1:7072 LOG:.* define ds2 FHEM2FHEM 192.168.0.1:7072 RAW:CUL Set
Get
Attributes FHEMWEB
Define define <name> FHEMWEB <tcp-portnr> [global]
Enable the webfrontend on port <tcp-portnr>. If global is specified, then requests from all interfaces (not only localhost / 127.0.0.1) are serviced. To enable listening on IPV6 see the comments here. Feature: http://host:port/fhem/icons/<devicename> will return the icon associated with the current status of <devicename>. Set
Get
Attributes at
Define define <name> at <timespec> <command> <timespec> format: [+][*{N}]<timedet>
+ indicates that the specification is
relative(i.e. it will be added to the current time).The optional * indicates that the command should be
executed repeatedly.The optional {N} after the * indicates,that the command
should be repeated N-times only.<timedet> is either HH:MM, HH:MM:SS or {perlfunc()}, where perlfunc must return a HH:MM or HH:MM:SS date. Examples: # absolute ones: define a1 at 17:00:00 set lamp on # fhem command define a2 at 17:00:00 { Log 1, "Teatime" } # Perl command define a3 at 17:00:00 "/bin/echo "Teatime" > /dev/console" # shell command define a4 at *17:00:00 set lamp on # every day # relative ones 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 # Blink 3 times if the piri sends a command define n1 notify piri:on.* define a8 at +*{3}00:00:02 set lamp on-for-timer 1 # Switch the lamp on from sunset to 11 PM define a9 at +*{sunset_rel()} set lamp on define a10 at *23:00:00 set lamp off # More elegant version, works for sunset > 23:00 too define a11 at +*{sunset_rel()} set lamp on-till 23:00 # Only do this on weekend define a12 at +*{sunset_rel()} { fhem("set lamp on-till 23:00") if($we) } # Switch lamp1 and lamp2 on from 7:00 till 10 minutes after sunrise define a13 at *07:00 set lamp1,lamp2 on-till {sunrise(+600)} # Switch the lamp off 2 minutes after sunrise each day define a14 at +{sunrise(+120)} set lamp on # Switch lamp1 on at sunset, not before 18:00 and not after 21:00 define a15 at *{sunset(0,"18:00","21:00")} set lamp1 onNotes:
Set
Get
Attributes
autocreate
Define define <name> autocreate
Note 1: devices will be created with a unique name, which contains the type and a unique id for this type. When renaming the device, the automatically created filelog and weblink devices will also be renamed. Note 2: you can disable the automatic creation by setting the disable attribute, in this case only the rename hook is active, and you can use the createlog command to add FileLog and weblink to an already defined device. Example: define autocreate autocreate attr autocreate autosave attr autocreate device_room %TYPE attr autocreate filelog test2/log/%NAME-%Y.log attr autocreate weblink attr autocreate weblink_room PlotsSet
Get
Attributes
createlog
average
Define define <name> average <regexp>
If it matches, and the event is of the form "eventname number", then this module computes the daily and monthly average, and generates an event of the form
The current average and the cumulated values are stored in the device readings. Example: # Compute the average for the temperature events of the ws1 device define avg_temp_ws1 average ws1:temperature.* # Compute the average for each temperature event define avg_temp_ws1 average .*:temperature.* # Compute the average for all temperature and humidity events define avg_temp_ws1 average .*:(temperature|humidity).*Set
Get
Attributes Generated events:
holiday
define <name> holiday
Define a set of holidays. The module will try to open the file <name>.holiday in the modpath/FHEM directory. If an entry in the holiday file matches the current day, then the STATE of this holiday instance displayed in the list command will be set to the holiday, else the state is set to the text none. Most probably you'll want to query this value in some perl script: see Value() in the perl section or the global attribute holiday2we. The file will be reread once every night, to compute the value for the current day, and by each get command (see below). Holiday file definition: The file may contain comments (beginning with #) or empty lines. Significant lines begin with a number (type) and contain some space separated words, depending on the type. The different types are: Set
Get get <name> <MM-DD>
Return the holiday name of the specified date or the text none. Attributes
notify
Define define <name> notify <pattern> <command>
Execute a command when received an event for the definition <pattern> . If
<command> is enclosed in {}, then it is a perl expression, if it is
enclosed in "", then it is a shell command, else it is a "plain" fhem.pl
command (chain). See the trigger command for
testing it.
Examples:
define b3lampV1 notify btn3 set lamp % define b3lampV2 notify btn3 { fhem "set lamp %" } define b3lampV3 notify btn3 "/usr/local/bin/setlamp "%"" define b3lampV3 notify btn3 set lamp1 %;;set lamp2 % define wzMessLg notify wz:measured.* "/usr/local/bin/logfht @ "%"" define LogUndef notify global:UNDEFINED.* "send-me-mail.sh "%"" Notes: Set
Get
Attributes sequenceDefine define <name> sequence <re1> <timeout1> <re2> [<timeout2> <re3> ...]
A sequence is used to allow to trigger events for a certain combination of button presses on a remote. E.g. to switch on a lamp when pressing the Btn1:on, then Btn2:off and at last Btn1:on one after the other you could define the following:
define lampseq sequence Btn1:on 0.5 Btn2:off 0.5 Btn1 on
Set
Get
Attributes structure
Define define <name> structure <struct_type> <dev1> <dev2> ...
The structure device is used to organize/structure a devices in order to set groups of them at once (e.g. switching everything off in a house). The list of attached devices can be modified through the addstruct / delstruct commands. Each attached device will get the attribute <struct_type>=<name> when it is added to the list, and the attribute will be deleted if the device is deleted from the structure. The structure devices can also be added to a structure, e.g. you can have a building consisting of levels which consists of rooms of devices. Example: Set
Get
Attributes watchdogDefine define <name> watchdog <regexp1> <timespec> <regexp2> <command> Start an arbitrary fhem.pl command if after <timespec> receiving an event matching <regexp1> no event matching <regexp2> is received. The syntax for <regexp1> and <regexp2> is the same as the regexp for notify. <timespec> is HH:MM[:SS] <command> is a usual fhem command like used int the at or notify Examples: # Talk to the FHT80 if we do not receive any message for 15 Minutes define w watchdog FHT80 00:15:00 SAME set FHT80 time # Shout if the HMS100-FIT is not alive define w watchdog HMS100-FIT 01:00:00 SAME "alarm-fit.sh"Notes:
Set
Get
Attributes DbLog
Define define <name> DbLog <configfilename> <regexp>
Log events to a database. The database connection is defined in <configfilename> (see sample configuration file
db.conf ). The configuration is stored in a separate file
to avoid storing the password in the main configuration file and to have it
visible in the output of the list command.
You must have 93_DbLog.pm in the FHEM subdirectory
to make this work. Additionally, the modules DBI and
DBD::<dbtype> need to be installed (use
cpan -i <module> if your distribution does not have it).
<regexp> is the same as in FileLog.
Sample code to create a MySQL database is in fhemdb_create.sql .
The database contains two tables: current and
history . The latter contains all events whereas the former only
contains the last event for any given reading and device.
The columns have the following meaning:
yes is translated to 1 .
The current values can be retrieved by means of the perl script fhemdb_get.pl . Its output is adapted to what a
Cacti data input method expects.
Call fhemdb_get.pl without parameters to see the usage
information.
Examples: # log everything to database define logdb DbLog /etc/fhem/db.conf .*:.*
Get
Attributes
FileLogYYYY:MM:DD_HH:MM:SS <device> <event>The regexp will be checked against the (complete!) device name or against the (complete!) devicename:event combination. <filename> may contain one or more of the following
wildcards (a subset of the Unix date command arguments):
define lamplog FileLog /var/tmp/lamp.log lamp define wzlog FileLog /var/tmp/wz-%Y-%U.log
wz:(measured-temp|actuator).* Set set <name> reopen Used to reopen a FileLog after making some manual changes to the logfile. Get
get <name> <infile> <outfile> <from>
<to> <column_spec>
Read data from the logfile, used by frontends to plot data without direct access to the file. Example: get outlog out-2008.log - 2008-01-01 2008-01-08 4:IR:int: 9:IR:: Attributes
dummy
Define define <name> dummy
Example: define myvar dummy set myvar 7 Set set <name> <value> Set any value. Get
Attributes SUNRISE_EL
sunrise, sunset, sunrise_rel, sunset_rel sunrise_abs, sunset_abs isdayperl functions, to be used in at or FS20 on-till commands. First you should set the longitude and latitude global attributes to the exact longitude and latitude values (see e.g. maps.google.com for the exact values, which should be in the form of a floating point value). The default value is Frankfurt am Main, Germany. The default altitude ($altit in SUNRISE_EL.pm) defines the sunrise/sunset for Civil twilight (i.e. one can no longer read outside without artificial illumination), which differs from sunrise/sunset times found on different websites. See perldoc "DateTime::Event::Sunrise" for alternatives. sunrise()/sunset() returns the absolute time of the next sunrise/sunset, adding 24 hours if the next event is tomorrow, to use it in the timespec of an at device or for the on-till command for FS20 devices. sunrise_rel()/sunset_rel() returns the relative time to the next sunrise/sunset. sunrise_abs()/sunset_abs() return the absolute time of the corresponding event today (no 24 hours added). All functions take up to three arguments:
isday() can be used in some notify or at commands to check if the sun is up or down. Define
Set
Get
Attributes
Note: these are global attributes, e.g.
attr global longitude 8.686 FHEMRENDERER
Define define <name> FHEMRENDERER [global]
This defines a new "device", that is of type FHEMRENDERER. The option 'global' can be used if needed for sorting reasons. Otherwise this option has no real meaning for FHEMRENDERER. As a side-effect of defining this "device" the following attributes will be set for this "device": plotmode gnuplot plotsize 800,200 refresh 00:10:00 room Unsorted status off tmpfile /tmp/ multiprocess off NOTE: The Logfile will report (with LogLevel 2) that the FHEMRENDERER has been defined. Set set <name> <value> Set either on or off. This switches the timer-based rendering on/off. The attribute 'status' will be modified accordingly. NOTE: only WebLink based graphics will be rendered. Get get <name> <[[file-name] device type logfile [pos=zoom=XX&off=YY]]> The get function supports different sets of arguments: Arguments: NONE: all WebLink based FilePlots will be rerendered The resulting filename will be ' THREE: device type logfile In this case only one specific graphic will be rendered: A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile' The resulting filename will be 'attr-tmpfile logfile.png' FOUR: file-name device type logfile In this case only one specific graphic will be rendered: A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile' The resulting filename will be 'attr-tmpfile file-name.png' FIVE: file-name device type logfile pos=zoom=XX&off=YYY 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 resulting filename will be 'attr-tmpfile file-name.png' NOTE: If you want to use zoom AND offset then you have to concatenate via '&' !! NOTE: combinations are possible in limited ranges: meaning: you can add the 'pos=zoom=XX&off=YY' to any of the first three sets. This may e.g. result in rendering all WebLinks with a specific zoom or offset (if you just pass the 'pos=zoom=xx&off=yy' parameter); Any rendered image (one or all WebLinks) will be stored in 'attr-tmpfile' followed by a 'filename.png'. The filename will be either derived (from weblink-name or logfile-name) or, for single files, can be assigend. Attributes PachLog
Note: this module needs the HTTP::Request and LWP::UserAgent perl modules. Define define <name> PachLog <Pachube-API-Key> <Pachube-API-Key>: The Pachube-API-Key however is what you need in your code to authenticate your application's access the Pachube service. Don't share this with anyone: it's just like any other password. www.pachube.com Set Add a new Device for Logging to www.pachube.com set <NAME> ADD <FHEM-DEVICENAME> FEED-NR:ID:READING:ID:READING Example: KS300-Weather-Data READINGS: temperature humidity wind rain 1. Generate Input-Feed on www.pachube.com => Yout get your FEED-NR: 1234 2. Add Datastreams to the Feed:
set <NAME> ADD <My-KS300> 1234:0temperature:1:humidity:2:wind:3:rain Delete a Device form Logging to www.pachube.com set <NAME> DEL <FHEM-DEVICENAME> Get
Attributes dumpdefdumpdef <options>
Data::Dumper for FHEM-Devices/Hashes Dumps the content of <options> to FHEMWEB Options:
Example: dumpdef TEST CALLER => main: /opt/fhz/FHEM/01_FHEMWEB.pm LINE: 194 SUB: main::FW_AnswerCall SUB-NAME: main::Commanddumpdef DUMP-DEVICE: TEST $VAR1 = { 'IODev' => {}, 'NAME' => 'TEST', 'NR' => 64, 'STATE' => '???', 'TYPE' => 'dummy' }; DUMP-DEVICE-ATTR $VAR1 = { 'room' => 'DEF_DUMMY,GRP.TEST' }; Perl specialsIf 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-script or a perl "oneliner" as the at/notify argument. This chapter gives some tips in using the perl oneliners.
{ 1+3*4 } { `ls /etc` } { Log 1, "Hello" }
define n1 notify piri:on { fhem "set light on" }
trigger MyMacro define MacroWithArg notify MyMacro { Log 1, "Hello %"} trigger MyMacro MyArg 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 roll_en *07:45:00 { fhem "trigger SwitchAllRoll on" if(!$we) } define roll_en *08:30:00 { fhem "trigger SwitchAllRoll on" if($we) }
sunset_abs($offset, $min, $max) sunrise_rel($offset, $min, $max) sunrise_abs($offset, $min, $max) isday() |