Installing FHEM on the Raspberry Pi

Login and Password

The FHEM web interface can be divided into three areas. To the left below the FHEM logo, a sidebar shows the most important functions (Figure 5), including functions to save configuration settings, open logfiles, and monitor events. The white box at top center is for commands that are sent to FHEM. You will be using this command line often. Immediately below, FHEM displays current tasks that might be of interest, as well as all interface dialogs.

Figure 5: The FHEM web interface. In this case, the FHEM configuration file is being edited.

After installation, the web interface reports that you should secure the service with access data (Figure 6). This message can be ignored for the time being, because the router does not typically forward data from the Internet to the FHEM Rasp Pi. This message can be turned off by entering

attr global motd none
Figure 6: FHEM complains that you have not yet entered access data for the service.

in the FHEM command line. Alternatively, you can set secure passwords right away by entering

attr WEB editConfig 1

in the FHEM command line. Once this editing option is activated, you can edit the FHEM configuration files directly from the web interface by clicking Edit files in the sidebar, then open the FHEM configuration file by typing fhem.cfg in the next dialog.

You do not enter a password in plain text. Instead, it is encoded as a username:password Base64 pair. To get a private key, either log on to the Rasp Pi or another available computer via SSH and execute the command:

$ echo -n <username>:<password> | base64
cmFzcGk6Z2VoZWlt

You can also generate the Base64 access data online [6]. In either case, you then transfer the result as

attr WEB basicAuth <key>
attr WEBphone basicAuth <key>
attr WEBtablet basicAuth <key>

to the FHEM configuration (Listing 1). The lines under each server configuration also need to be entered and the file saved by clicking on Save fhem.cfg in the FHEM interface (see Figure 5).

Listing 1

Setting a Secure Password

§§nonnumber
define WEB FHEMWEB 8083 global
attr WEB basicAuth cmFzcGk6Z2VoZWlt
define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen
attr WEBphone basicAuth cmFzcGk6Z2VoZWlt
define WEBtablet FHEMWEB 8085 global
attr WEBtablet stylesheetPrefix touchpad
attr WEBtablet basicAuth cmFzcGk6Z2VoZWlt

To activate password protection, you should restart the FHEM service once with shutdown restart on the command line. From then on, getting to the FHEM web interface in the browser with the F5 shortcut key requires you to authenticate user identity with the access data you entered.

Control from the SSH Terminal

Generally, you do not really need to configure FHEM in the web interface because it writes all settings to the fhem.cfg file in the /opt/fhem installation directory. You can edit these directly in the SSH console with the text editor of your choice with a command like:

$ sudo nano /opt/fhem/fhem.cfg

To save the changes, press Ctrl+O and confirm the file name by pressing Enter. Get out of the nano editor by pressing Ctrl+X to return to the command prompt. Once the changes are complete, you should query the status and restart FHEM (Listing 2).

Listing 2

Restarting FHEM

§§nonnumber
ignored KT: @KT:Listing 2: Restarting FHEM
$ sudo service fhem status
+ fhem.service - LSB: FHEM server
   Loaded: loaded (/etc/init.d/fhem)
   Active: active (running) since Thu 2016-03-31 15:25:06 CEST; 15s ago
  Process: 9314 ExecStop=/etc/init.d/fhem stop (code=exited, status=0/SUCCESS)
  Process: 9325 ExecStart=/etc/init.d/fhem start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/fhem.service
           |-9333 perl fhem.pl fhem.cfg
Mar 31 15:25:05 raspberrypi fhem[9325]: Starting fhem...
Mar 31 15:25:06 raspberrypi systemd[1]: Started LSB: FHEM server.
$ sudo service fhem stop
$ sudo service fhem start
$ sudo service fhem restart

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content