Home Assistant

Tasmota, web interfaceRecently I’ve been working on a small craft project: extending an IKEA Vindriktning air quality sensor with a D1 Mini to read the data and forward it to a server via MQTT.

See also Sören Beye’s Github repository for the conversion. However, instead of this firmware, I use Tasmota based on these instructions from Blakadder, which is much more convenient to set up and configure. See also the Tasmotizer on Github.

When I was looking for a suitable server, I quickly ended up at Home Assistant. This is a free software solution for integrating numerous smart home devices and can also be used on a Raspberry Pi 3 or 4. In my case this is a Raspberry Pi 4.

Update 2022-08-14: In the meantime I have expanded this with another sensor for CO2, relative humidity and temperature, see the article here.

Installation of Home Assistant on the Raspberry Pi

The simplest solution is to use the Raspberry Pi Imager. The system can be found there in the category “Other specific-purpose OS” and then “Home assistants and home automation”:

Raspberry Pi Imager with Home Assistant

After an SD card is prepared with the system, you start the Raspberry Pi and should then wait a few minutes for Home Assistant to complete the initial setup. Updates to newer versions can later be carried out in Home Assistant itself. I prefer a wired connection to the LAN for connecting to the network, but it is in principle also possible to configure a WLAN connection after the initial setup.

The entire operation takes place via the web interface, which can be reached at the address http://homeassistant:8123 (if the router can resolve the host name correctly, otherwise you may have to check with the router which address was assigned via DHCP). To ensure that the IP address does not change, a permanent address assignment must be set up in the router. This is necessary so that the IP address can be used to transmit data via MQTT. With Fritz!OS this is the option “Always assign the same IPv4 address to this network device.” in the properties of the network device.

Fritz!Box, DHCP settings

For MQTT you need a broker. With Home Assistant you can use the AddOn “Mosquitto broker”. Contrary to some setup instructions, in the current version it is no longer necessary to specify the users for MQTT devices, the add-on can be used immediately after setup.

Home Assistant, Mosquitto broker

In order for data to be sent to Home Assistant, you still have to enter the IP address of the server and the user name and password for MQTT in Tasmota. You can leave the information for Port, Client, Topic and Full Topic as they are.

Tasmota, MQTT configuration

Configuring Home Assistant

There is extensive documentation for Home Assistant. Therefore I focus on the points that are essential to me.


The basis for every device used in Home Assistant is an “integration”. In my case, the FRITZ!Box 7590 is the Mosquitto broker for MQTT and Tasmota, which is used to transmit the data from the air quality sensor.

Each “integration” in turn provides one or more “devices” and within each “device” there can be multiple “entities”. For example, a switch socket offers measurement data such as temperature and power consumption as well as the switching function as entities.

After starting, Home Assistant determines for which devices an integration is available and offers this for automatic setup. However, it is also possible to add additional integrations manually at any time.

User interface

The user interface is divided into several levels:

Dashboard – these are listed in the left sidebar. In addition to the standard dashboards, you can also add your own with a freely definable title and icon. I have created two dashboards for “Air Quality” and “Heating”.

View – within a dashboard you can create one or more views, which can be switched using the navigation at the top. Each view can contain either a single item or multiple items as a grid.

I have set up my own view for displaying the air quality, in which the data is displayed as a diagram. For this I have included a “History Graph” element, which uses the readings from Tasmota as a data source and is updated every five minutes:

Home Assistent, data from IKEA Vindriktning

Integrating the Fritz!Box 7590

Home Assistant also offers integration for Fritz!OS smart home features. This means that I can use both the radiator controls and the data from the switch sockets regarding power consumption. I also created my own dashboard for the radiator controllers. The energy display, on the other hand, is an integral part of Home Assistant.

For security reasons, it is recommended to create a separate user account that only has access to the smart home functions:

Fritz!Box, user configuration

You enter this data when you activate the Fritz!Box integration in Home Assistant:

Home Assistant, Fritz!Box login data

If you ever have to change the login data for the Fritz!Box, this can only be done by removing the integration and adding it again immediately afterwards. In my experience, existing devices and the data already recorded about them are not deleted.

As soon as the integration is activated, you can integrate all smart home devices from AVM, such as radiator controls or socket dashboards.

A small weakness: if you integrate switches for sockets in the interface, switching works well with a click, but the symbol changes back to the previous state after the switching process. The correct status is only displayed after some time. If you don’t want to wait that long, you can click on the switch symbol again beforehand. I can only assume that the symbol display is only updated when the current status of the socket is queried. In practice, however, this is not a problem for me, since I use wireless pushbuttons for operation anyway.

Update 2022-08-13

My assumption that the current switching status of the AVM DECT sockets is only updated after a certain pause has been confirmed.

See also the issue at Github: Home Assistant queries the data from the Fritz!Box every 30 seconds and the Fritz!Box does not actively report status changes. This means that after a switching action has been triggered, e.g. by a DECT button, it can take up to 30 seconds before the new switching status is known. For actions within Home Assistant, the new status should be determined without delay, but this is currently not working either.

Remote access

If you also want to access Home Assistant from outside your own network, there are several options depending on your router. The simplest variant is the Home Assistant Cloud, which is not free of charge – currently EUR 7.50 per month or EUR 75 as an annual subscription.

The other solution is to use DynDNS – that is, a domain whose IP address is automatically updated once the router is online. Fritz!OS supports several providers for this:

Fritz!Box, DynDNS settings

If access to the LAN is basically possible via your own domain, you can set up port forwarding in the router for HTTP and HTTPS to access Home Assistant. To do this, the use of HTTPS must be configured in the Home Assistant in combination with Let’s Encrypt, which can be installed as an add-on.

Home Assistant with direct access

As an alternative to direct access, a VPN connection would also be possible with the Fritz!Box, either on the end device, such as Android, or via a server that creates the VPN connection itself and then works as a proxy for Home Assistant. I implemented this solution because the server is used for various other services. I use Apache as a proxy and then reach the server with Home Assistant via a publicly accessible URL via HTTPS.

Home Assistant via proxy

For the VPN connection of a Linux server with Strongswan to the Fritz!Box, see the following instructions: FritzBox LAN 2 LAN VPN with StrongSwan. Essentially, you create a configuration file that you import into the Fritz!Box and a matching configuration for Strongswan.

The relevant configuration for the proxy in Apache is as following:

ProxyPreserveHost on
ProxyRequests off
ProxyPass /api/websocket ws://
ProxyPassReverse /api/websocket ws://
ProxyPass /
ProxyPassReverse /

RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*)$1 [P,L]

The IP address is just an example and needs to be replaced with the correct address of Home Assistant.

In order for Home Assistant to allow such access, you must add the following entries to /config/configuration.yaml (for editing the configuration, see also “Advanced configuration” in the Home Assistant documentation):

  use_x_forwarded_for: true

Instead of the address, enter the address to which the proxy connects. If the address is not correct, Home Assistant will deny access with HTTP error 400.

An advantage of the proxy server solution is that the URL via which Home Assistant can be reached is independent of whether you are currently in the LAN or not, so that you do not have to configure a local URL in the app.

Home Assistant App

The web interface of Home Assistant is responsive and can also be used with mobile browsers. Therefore, an app is not absolutely necessary. Nevertheless, there are some advantages with the app – here related to Android:

  • If enabled, the device also reports its location to Home Assistant – this information can be used for automation.
  • You can use NFC tags to trigger actions in Home Assistant.
  • Home Assistant elements can be placed on the home screen as widgets.

A note on the interface:

Unfortunately, the “System Settings” setting for the app’s theme does not affect the Home Assistant interface, only the elements generated by the app itself. If you want to have an automatic switch between the normal display and “dark” when you switch the device accordingly, you should use the “automatic” theme in the profile in Home Assistant and set the app to adopt the Home Assistant theme .

Update 2023-05-07

In the meantime, I use Wireguard for the VPN connection from the server to the Fritz!Box, which is now supported by Fritz!OS. This offers significantly better throughput and is also easier to set up.

Leave a public comment

Your email address will not be published. This is not a contact form! If you want to send me a personal message, use my e-mail address in the imprint.

You can use the following HTML tags in the comment:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>