Starting
First install the Device::SerialPort (or Win32::SerialPort) perl module
with the command "cpan -i Device::SerialPort"
The default configuration will install fhem into /usr/local/bin,
/usr/local/lib/FHEM and /var/log/fhem. Edit the Makefile to change
this.
To install & start fhem type:
make install-pgm2
perl /usr/local/bin/fhem.pl /var/log/fhem/fhem.cfg
After starting, the logfile should look like:
2008.06.15 16:17:03 2: FHEMWEB port 8083 opened
2008.06.15 16:17:03 2: FHEMWEB port 8084 opened
2008.06.15 16:17:03 0: Server started (version ...)
Connect to fhem with an internet browser:
http://localhost:8083/fhem
or
http://localhost:8084/fhem if
you are using a small-screen browser (e.g a smartphone).
Attaching an FHZ/CUL
Attach the FHZ1000 or FHZ1300 to your computer, and look for a file named
/dev/ttyUSB0 or /dev/tts/USB0 (or /var/elv on the Fritz!Box).
Define it for fhem (by typing it in the
"Fhem cmd" input field in the browser):
define FHZ1 FHZ /dev/ttyUSB0
You can find details
here and
here. Instead of an FHZ you can also
use a
CUL with slightly different
parameters (define CUL CUL /dev/ttyACM0 1234).
Note: Don't forget to type "save" in the "Fhem cmd" input field of
the browser after defining a device or setting its attribute. Otherwise
the changes will disappear after the next start.
Automatically creating transmitters
The sample configuration file installed via "make install-pgm2" has
configured an autocreate
instance. This will automatically create fhem devices upon reception
of a message from this device (typically a sensor like S300 or FHT).
Just wait for a while, watch the log and re-check your browser for newly
appeared devices. You can use
rename to rename the automatically created device, e.g. type in the
input field of the web frontend:
rename FHT_1234 fht.kitchen
Misc. RF transmitters (FS20/EM/S300 etc.)
autocreate will create
automatically fhem FS20/EM/S300/HMS devices, the following description is
for doing it manually.
Wait a while, until the transmitter sent some data. In the logfile
(Browser window: "All together" -> Logs:Logfile:text) a line
will appear:
FS20 Unknown device <HOUSECODE, Button <BTN> Code <CDE>, please define it
Now define a device:
define piri1 FS20 <HOUSECODE> <BTN>
Set the model attribute of the device:
attr lamp1 model fs20piri
to get only the commands available for this device.
Here is a complete list of FS20
models.
For other device-types similar messages should appear.
Configuring FS20 receivers
Configure the FS20 device in
fhem first with:
define lamp1 FS20 1234 56
Now press the button on the device for a while until its LED starts to
blink. Click on the "on" link in the fhem window to send a command. The
LED should terminate blinking, the device is programmed to housecode
1234, device code 56. You can also use the 4-base ELV notation.
Now set the model attribute of the device:
attr lamp1 model fs20st
to get only the commands available for this device.
Here is a complete list of models.
Configuring FHT devices
Note: Creating a fhem FHT device automatically or manually does
not imply that the CUL or the FHZ is paired with it. For this purpose you
have to set the FHT to accept new "Cent" devices, and send a command to
it (e.g. set fht.kitchen desired-temp 20)
autocreate will create
automatically FHT devices, the following description is for
doing it manually.
Wait for a while (2-5 mins) till the FHT is sending some signals. In the
logfile ("All together" -> Logs:LogFile:text) a line should
appear:
FHZ1: Unknown FHT device detected, define one to get detailed information
Define your FHT device with an arbitrary code in order to load the FHT
module, see
this link for details:
define MyFHT FHT 1111
The next message in the log will contain more details:
FHT Unknown device <HOUSECODE>, please define it
Delete and create your device again:
delete MyFHT
define MyFHT FHT <HOUSECODE>
If there is no signal for a while, then check
this FAQ entry.
Timed commands / Notification
To execute commands at a given time / periodically, you have to define
devices of the type at. See the definition
here and the examples here The last link
only works if you are reading this HOWTO from your fhem Web.
To execute commands if a device sent a message you have to define
devices of the type notify or
watchdog. In order to understand
the fhem events better you can open a telnet session to your fhem
telnet localhost 7072
and type
inform timer
Now you will receive in this telnet session all events, just like the
notifies/watchdogs do. You can even simulate events by using the
trigger command:
trigger lamp1 on
FHEMWEB (pgm2) look and feel
It makes sense to group your devices into rooms by setting the room
attribute. FHEMWEB puts devices without a room attribute into the
"Unsorted" room. Devices in the room "hidden" will not be shown.
Set the title of the webpage by setting the title attribute of the global
device ("All together" -> global)
Edit the colors / fonts by changing the style.css ("Edit files" ->
style.css)
Further FHEMWEB attributes:
webname,
plotmode,
plotsize.
Logging data
To log messages into files, define devices of the type FileLog. Autocreate will create
logfiles for newly detected devices. To log messages into a
database, see the contrib/dblog directory in the fhem
distribution.
FHEMWEB has builtin support for displaying FileLog type logs as plots,
see the plot section below.
The size of each logfile will be determined by its wildcard characters
(year/month/week/day), look at the
FileLog definition.
Don't forget to enable archiving with the nrarchive or archivecmd attributes.
Plotting logs
Autocreate will create weblinks (i.e. plots) for newly detected devices.
The following section describes how to do it manually.
To convert a log into a plot in FHEMWEB, set the
logtype attribute of the
corresponding FileLog. Take a look at the available gnuplot files in the
"Edit files" section, they contain the corresponding FileLog definition
example.
Note that the .gplot files are also used if you use SVG output and
not the gnuplot backend!
When displaying the plot, you can convert it into a "weblink", which can
in turn have a room attribute to group more than one Plot together. If
the weblink refers to the current logfile, then it will be stored as a
CURRENT weblink, and it will always display the most recent log (you do
not have to redefine it if the logfile changes due to year/month/date
parameters in its name).
The logs can be converted to a plot either with gnuplot (which must be
installed and in your PATH), or via the builtin SVG module, in this case
your internet browser must support SVG. Firefox, opera and the
iPhone/Android borwser support SVG out of the box, Internet Explorer does
it via the Adobe "SVG viewer" plugin. SVG mode is the default, to change
it set the plotmode attribute to
gnuplot or gnuplot-scroll.
In order to look at historic data, you can either convert at the
archive entries to weblink in "plotmode=gnuplot" mode, or use the
"plotmode=gnuplot-scroll" or "plotmode=SVG" modes. In the latter case
you'll get the possibility to zoom or scroll in the plot.
Use the zoom and scroll icons at the top of the page.
The current time scope (day, week, month..) set at the overview
page (containing weblinks) will also be used for graphics you open via
links (current log or archive) - there are no zoom and scroll icons
there.
Note: the gnuplot files must have #FileLog entries in order to be
useable with scrolling, as the filtering happens with the FileLog get
function, see the supplied gnuplot files for an example.
The order of the #FileLog lines need to match the corresponding
'awk'-(double-)lines!
It make sense to build large logfiles for scrolling in them (year
resolution), or smaller ones if you do not want to use the zoom/scroll
feature. The size of the logfiles will be determined by its wildcard
characters (year/month/week/day), look at the FileLog definition.
Don't forget to enable archiving with the archivedir or archivecmd
attributes.
FHEMWEB tips
Click on the State link on the device page to get a documentation of
all its settable values, similarly clicking on Attributes will guide you
to the documentation of its attributes.
Password/HTTPS
These features are implemented by apache, and apache must be configured
to redirect the page to 01_FHEMWEB.pm. For this purpose add the following
lines to your httpd.conf:
<Proxy *>
AuthType Basic
AuthName "Password Required"
AuthUserFile /home/httpd/etc/passwd
Require valid-user
Allow from 127.0.0.1
</Proxy>
ProxyPass /fhem http://localhost:8083/fhem
ProxyPassReverse /fhem http://localhost:8083/fhem
and then restart httpd with apachectl graceful. To create the password
file, execute
htpasswd -c /home/httpd/etc/passwd <username>
To enable HTTPS, please check the web. In essence:
To display "foreign" (non fhem) files as a plot or a just as plain text,
configure a fake logfile with the correct filename and an unused regexp,
e.g.
define messages FileLog /var/log/messages fakelog
Complex structures
Put your devices in different rooms. You can now use the
room=<roomname> specification to set different devices at once.
See the devspec paragraph for details.
For more complex scenarios consider the
structure module. You can define different structure levels like
floors, buildings, etc. and set all elements of a gives structure at once.