HowTo: FHEM – Structure, Modules & Worth Knowing

After installing FHEM for the first time and the configuration page was reachable, the euphoria was great. After I had clicked on it a bit, this euphoria was quickly replaced by helplessness. FHEM is a powerful and very well maintained tool to connect different home automation devices. Unfortunately, it’s one thing not: Intuitive.

In my opinion, this is the only disadvantage of FHEM or open source projects in general: you have to invest time and deal with the project. Unfortunately, it is often not something that you can easily assemble or plug-and-play on one evening.

That is why I have made in this article to summarize and explain the most important basics of FHEM.

Ideally, you will be able to set up a functional and secure FHEM configuration without having to torment yourself for days through forum posts and wiki pages.

I will first write a little bit about the structure and the configuration of FHEM and in the further course I will introduce some useful (and partly also important) configuration snippets.

Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/


Requirements

Before you start with this article, you should have prepared the RaspberryPi so far that it can be reached via the network and controlled by SSH.

The following three articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH
FHEM – Installation on the RaspberryPi

Required tools:
-none-

Required materials:

In the following list you will find all the parts you need to implement this article.


Overview of the FHEM web interface

The following pictures should give you a small overview of the different functions of the FHEM webinterface.

1. The command line:
Here you can enter commands to create or configure new modules

2. “Save config” does in principle exactly what it says. Any changes to your FHEM instance will be saved in a large configuration file. However, this only happens after clicking on the “Save config” button. Unsaved changes will be indicated by a red question mark next to “Save config”. Unsaved changes will be lost by restarting the FHEM server.

3., 4. and 5. “MAX”, “unsorted” and “Everything” are “rooms” you can create to group your configured sensors and actuators. For example, you can create a room “living room” and put all devices together that are important for controlling the living room. Only the rooms “unsorted” and “Everything” are created automatically and are always present. The room “unsorted” lists all configured modules which are not yet linked to any other room. In the “Everything” room, all configured modules are listed, regardless of whether they are already linked to another room.

6. “Logfile” shows you the entries of the logfile

7. “Commandref” displays the local command library. Here you will find all available commands and partial details.

8. “Remote doc” is similar to “Commandred” only, that you will be redirected to the current version of the available commands on the FHEM website.

9. “Edit Files” allows you to edit the various style and configuration files of FHEM. Here you have many options, but can also break a lot. Therefore always work here carefully and preferably with a previous backup.

10. Under “Select Style” you can change the look of your FHEM instance.

11. The Event Monitor allows you to view current live events, such as events such as received switching commands.

View of the room “MAX”: This room contains all devices of the MAX-module for the MAX!-Heatthermostats. Some rooms (like this one) are automatically created as soon as a corresponding device of this module is configured.
View of the room “Unsorted”: This room contains all the configured modules that are not yet in another room.
View of the room “Everything”: All configured modules are listed in this room. So, if you’re looking for a specific configured module, you’ll definitely find it here.
View of the logfile: Various past activities are shown here. In this example, you can see that multiple connection attempts to a particular server have failed. Each info is logged with a timestamp. This is very helpful for troubleshooting.
View of the “Commandref”: Here you will find all available commands of the installed modules.
View of “Edit files”: Here you will find all FHEM files. You can also view and edit them here. Especially with the configuration files but you should be careful. An incorrect setting can lead to FHEM not starting properly anymore.
View of “Select Style”: Here you can edit the appearance of the FHEM interface. In “Styles” prefabricated styles are also offered. Just try it. Here you can break (almost) nothing.
View of the Event Monitor: Various activities are shown live here. In this example, you can see that the connection to the configured MQTT server is active. This and other states/events are monitored and displayed here regularly.

Modules

The great thing about FHEM is that its functions can be extended and refined with all sorts of modules. Exactly this property makes it so powerful, because it also new sensors or actuators can be integrated in FHEM.

A great overview of the structure of FHEM can be found at https://wiki.fhem.de/wiki/System%C3%BCbersicht


Start and stop

To start and stop Putty from the console, the following commands are helpful.

Starting FHEM:

sudo /etc/init.d/fhem start

or

systemctl start fhem.service
In the last case, you may be asked under which user this action should be performed. Here you normally select the user “pi”, ie number 1, and confirm this by entering the respective user password.

Stop FHEM:

sudo /etc/init.d/fhem stop

or

systemctl stop fhem.service
In the last case, you may be asked under which user this action should be performed. Here you normally select the user “pi”, ie number 1, and confirm this by entering the respective user password.

Display current status of FHEM

To display the current system messages of your FHEM instance, the following command is sufficient.

sudo /etc/init.d/fhem status

or

systemctl status fhem.service
Interesting here are the last two lines. These show you that FHEM has been started and is now running. If FHEM does not start it will very likely be an error message that can help you with troubleshooting.

Additional information

https://wiki.fhem.de/wiki/System%C3%BCbersicht


I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *