Setting up a Raspberry Pi as a Home Assistant Kiosk

In this project, we will set up our Raspberry Pi to act as a Home Assistant kiosk.

Raspberry Pi Home Assistant Kiosk

A kiosk is a great way of interacting with your Home Assistant setup. It can give the user access to a wealth of information on a single screen, or with the addition of a touch screen, it can actually be used to control things around your home.

There are many different ways that you can set up a kiosk for the Home Assistant software. However, many of these ends up feeling either incredibly unstable, buggy or just super unresponsive. For example, we used to use a couple of Android tablets to act as our kiosks, but there were just continual random and unexplained issues. You would walk away for the tablet to randomly get stuck on a lock screen that you have previously disabled.

Needing something more reliable and with more control, we decided to grab one of our Raspberry Pis and use it as a kiosk instead. This setup lets you easily lock your kiosk to the Home Assistant web interface.

Best of all, thanks to the Raspberry Pi being a low-powered device, we don’t have to stress about it adding too much to the power bill if we were to keep them running 24/7.

For this guide, we are assuming that you already have Home Assistant set up on a device.

Equipment

Below is a list of equipment we used to set up our Raspberry Pi powered Home Assistant Kiosk.

Recommended

Optional

We last tested this tutorial on a Raspberry Pi 5 running the latest version of Raspberry Pi OS Bookworm Lite Edition.

Building a Home Assistant Kiosk with your Raspberry Pi

Over the following sections, we will show you how to easily set your Raspberry Pi to act as a Home Assistant Kiosk.

For this guide, we will be expecting you to be running the lite version of Raspberry Pi OS. The advantage of the lite edition is that it has significantly less overhead to worry about. Also, with less apps installed by default, there is simply less to go wrong.

Additionally, you must have your Raspberry Pi configured to use an SSH connection. With the way we are configuring the Pi, you won’t be able to access the terminal properly after setting up the kiosk.

Preparing your Raspberry Pi’s Operating System

1. Before we can begin to set up our Raspberry Pi as a Home Assistant kiosk, we should ensure that we are running an updated operating system,

You can update the package list cache and upgrade any out-of-date packages by running the following command.

sudo apt update
sudo apt upgrade -y

2. Your next step is to install the three main packages we require to set up our kiosk for Home Assistant.

  • xserver-org: Since we are using the lite version of Raspberry Pi OS, it is missing a window system. XServer is great, as it is still well-supported and has fewer issues than Wayland.
  • lightdm: On top of needing a window system, we must install a desktop manager. LightDM is a great choice for this as it is super lightweight and doesn’t require us to be running a full desktop experience.
  • chromium: The final piece of the puzzle is the Chromium web browser. This is one of the best browsers for the choice because it is incredibly well-supported and has a kiosk and app feature built directly into it.
  • onboard: Onboard is a virtual keyboard that we can use to allow you to type into your Home Assistant Kiosk without needing to attach a keyboard to your Raspberry Pi.
  • sed: The “sed” package will allow us to easily replace text within configuration files. Saving you from having to open it with a text editor.

Please note that this installation process can take some time. There is a considerable number of packages your Raspberry Pi will need to install.

sudo apt install xserver-xorg lightdm onboard chromium sed

Configuring your Pi to Launch a Light Desktop

3. Now that we have installed all the required packages, we need to configure a few more things.

The first of these tasks is to get our system to start up LightDM when it boots. This is as simple as setting the default behaviour of our system to start any service with “graphical.target“.

sudo systemctl --quiet set-default graphical.target

4. To stop you from having to log in to your account every time you want to use the Home Assistant kiosk on your Raspberry Pi, we will use the following line to add the current user to the “autologin-user” option.

We can make this whole process incredibly straightforward by using sed to search and edit the “/etc/lightdm/lightdm.conf” config file.

sudo sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-user=.*/autologin-user=$USER/"

5. Our next task is to get our Home Assistant kiosk to use the right screen resolution on our Raspberry Pi. Due to how we have set up this kiosk, we currently rely on the Pi to pick the right resolution correctly every time.

To make the next step easier, set a bash variable called “RESOLUTION” which holds your screen resolution using the width-by-height format. These values are in pixels.

RESOLUTION=<WIDTH>x<HEIGHT>

For example, since we are using a screen with a resolution of 1920 by 1080, we would use the following on our machine.

RESOLUTION=1920x1080

6. With the resolution environment variable set, we can use the sed tool to again adjust the settings for LightDM.

This time, the following command will reconfigure your system to set your screen resolution on boot.

sudo sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)display-setup-script=.*/display-setup-script=xrandr -s $RESOLUTION/"

7. With the resolution now set, our next step is to disable the screen blanking functionality. Screen blanking is a protocol for stopping the video output of your Raspberry Pi, which will put your monitor on standby.

All you need to do to ensure this occurs is use the following command. This adjusts the command to start the X Server to include the “-s 0 DPMS” option. Simply put, we are ensuring screen blanking is disabled before the server even starts.

sudo sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)xserver-command=.*/xserver-command=X -s 0 dpms/"

8. For all of these changes to take effect, we will need to restart our Raspberry Pi, which you can do by running the following command.

sudo reboot

Configuring the On-Screen Keyboard for your Kiosk

9. If you use a touchscreen for your Raspberry Pi powered Home Assistant Kiosk you will want to configure Onboard.

Onboard is one of the few virtual keyboards we found to work properly on the Raspberry Pi, Chromium, and Home Assistant.

To make this keyboard useful, we need to open its settings by running the following command.

DISPLAY=:0 onboard-settings

10. With the Onboard setting open, toggle the “Auto-show when editing text” option to allow Onboard to open within the Home Assistant interface.

The screen might look a bit weird due to the way we are handling the desktop on our kiosk.

Enable Keyboard Auto Show for Raspberry Pi Home Assistant virtual keyboard

11. You will see a warning that for the auto-show functionality to work, Gnome Accessibility will need to be enabled.

To proceed, click the “Yes” button to continue.

Enable accessibility mode

12. To save this settings change, you simply need to click the “Close” button.

Close out of Onboard Settings

13. We must restart the Raspberry Pi again to ensure that Onboard is working correctly.

You can restart your Pi by running the following command in the terminal.

sudo reboot

Writing a Script to Run your Home Assistant Kiosk on the Raspberry Pi

14. We next need to write a small script to launch your Home Assistant Kiosk on your Raspberry Pi.

The first part of this process is using the mkdir command to create a directory to store our script.

sudo mkdir -p /opt/kiosk/

15. With the directory created, we can move on to write a script called “kiosk.sh“.

You can begin writing this script using Nano by running the following command within the terminal.

sudo nano /opt/kiosk/kiosk.sh

16. Within this script, you must type out the following lines.

While filling out this file, you must fill out some key details.

  • <HOMEASSISTANTURL>: Replace this with the URL to where you access your Home Assistant dashboard.
  • <WIDTH>: With this value, you must specify your screen resolution width in pixels. For example, with a 1080p screen you would set this to 1920.
  • <HEIGHT>: Here you must set the screen resolution height in pixels. If you are using a 1080p screen, this will likely need to be set to 1080.
#!/bin/bash
/usr/bin/dbus-run-session /usr/bin/onboard &
/usr/bin/chromium --app=<HOMEASSISTANTURL>  --noerrdialogs --disable-infobars --kiosk --window-position=0,0 --window-size=<WIDTH>,<HEIGHT>

If you don’t want the on-screen keyboard to help control your Raspberry Pi Home Assistant keyboard, remove the script’s line that starts Onboard.

17. After filling out the file’s contents, save and quit by pressing CTRL + X, Y, and then ENTER.

18. Since we want our standard user to be able to use this script to start up the Home Assistant kiosk, you will want to give it execute privileges by using the chmod command in the terminal.

sudo chmod +x /opt/kiosk/kiosk.sh

Setting up your Raspberry Pi Home Assistant Kiosk Service

19. To ensure that your Home Assistant dashboard is loaded on your Raspberry Pi Kiosk at boot, we will write a service file. The other advantage of using a service is that it will automatically be restarted if the system crashes for any reason.

You can begin to write this service file using Nano by running the following command.

sudo nano /lib/systemd/system/kiosk.service

20. You will want to add the following lines within this service file. These lines tell the service to run the “kiosk.sh” script we wrote earlier. This is also where we will get your Home Assistant kiosk working on your Raspberry Pi.

While filling out this file, you will be required to replace “<USER>” with your username. For example, if your user is called “pi“, you would type in “pi” in place of “<USER>“.

[Unit]
Description=Home Assistant Kiosk
Wants=graphical.target
After=graphical.target

[Service]
Environment=DISPLAY=:0
ExecStart=/usr/bin/bash /opt/kiosk/kiosk.sh
Restart=always
User=<USER>
Group=<USER>

[Install]
WantedBy=graphical.target

21. After filling out this file, you can save and quit by pressing CTRL + X, Y, and then ENTER.

22. With the service now written, we will want to enable it so that our Raspberry Pi will boot straight into the Home Assistant Kiosk.

Enabling the service is as easy as using the following command.

sudo systemctl enable kiosk

23. After enabling the service, you can start your Home Assistant kiosk immediately by running the following command within the terminal.

sudo systemctl start kiosk

24. If everything has worked correctly, you should now have a Home Assistant Kiosk up and running on your Raspberry Pi.

Everything should work just like how you would expect it to. Remember that if you are setting up a kiosk you will want to ensure that you tick the “Keep me logged in” checkbox.

Home Assistant Kiosk up and Running

Conclusion

If you have got this far in the project, you should now have successfully set up your Raspberry Pi to act as a versatile Home Assistant Kiosk.

The Raspberry Pi makes a great device to power your home assistant kiosk, especially when you pair it with a touch screen. You have significantly more control over many other solutions, such as using an Android tablet.

Please feel free to post a comment below if you have had any issues with setting up this kiosk on your Pi.

If you liked this project, we recommend you check out our many other Raspberry Pi projects. We also have plenty of guides covering improving your Home Assistant setup.

Leave a Reply

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

13 Comments

  1. Avatar for Phil
    Phil on

    Hi I get as far as step 9 – open ONBOARD settings. I get this…
    Invalid MIT-MAGIC-COOKIE-1 key
    Invalid MIT-MAGIC-COOKIE-1 key
    Invalid MIT-MAGIC-COOKIE-1 key
    (onboard-settings:942): Gdk-WARNING **: 22:26:47.193:

    Can you suggest any way to rectify this please

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi Phil,

      I’m unable to reproduce this issue on my end. Are you running this over SSH or running this locally on the terminal of your machine?

      You can try seeing what the “DISPLAY” value is set to by default by using the following command.

      echo $DISPLAY

      Kind regards,
      Emmet

  2. Avatar for 4ordy
    4ordy on

    Thanks for this article.

    I cannot seem to get autologin to work, I just get a prompt on the screen and even if I input my account details screen goes blank and then login reappears.

    Any ideas?
    Thanks in Advance

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi 4ordy,

      That is definitely unusual. Can you please try editing the “lightdm.conf” configuration file directly by using the following command.

      sudo nano /etc/lightdm/lightdm.conf

      Within this file, you should see an option called “autologin-user”. It should be set to your username and the hashtag on it should have been removed. Can you please verify this?

      Kind regards,
      Emmet

    2. Avatar for Phil James
      Phil James on

      Same issue here.

      I can confirm that /etc/lightdm/lightdm.conf has autologin-user=myname and it still does not login

    3. Avatar for Emmet
      Emmet on
      Editor

      Hi Phil,

      Maybe we might have to try doing this the long way (Even though in theory i’m just replicating what this script does).

      1. Launch the Raspi-config tool by using the following command.

      sudo raspi-config

      2. Go to “System Options

      3. Select “Boot / Auto Login

      4. Finally choose “Desktop Autologin Desktop GUI“.

      5. Press “ESC” to exit out of the tool.

      6. Finally restart your Raspberry pi using the following command

      sudo reboot

      Please let me know if this solves your issue.

      Kind regards,
      Emmet

    4. Avatar for Phil
      Phil on

      Same issue. After completing the above instructions, boots to login, enter my login credentials, screen turns black, then back to a login prompt.

      Fresh download of rasp-pi lite yesterday installed on a rasp pi 3.

    5. Avatar for Emmet
      Emmet on
      Editor

      Hi Phil,

      Can you please try running the following two commands and let me know if it resolves the issue for you.

      sudo sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)user-session=.*/user-session=LXDE-pi-x/"
      sudo sed /etc/lightdm/lightdm.conf -i -e "s/^\(#\|\)autologin-session=.*/autologin-session=LXDE-pi-x/"

      Kind regards,
      Emmet

    6. Avatar for Phil James
      Phil James on

      Continuous loop just like 4ordy

  3. Avatar for 5ft24dave
    5ft24dave on

    Followed the instructions to the letter, ps -ef shows onboard running, but tapping in any box that reqires a text input does not bring the onboard keyboard to the front to use.

    1. Avatar for Emmet
      Emmet on
      Editor

      Hi 5ft24dave,

      Could you please re-run the “DISPLAY=:0 onboard-settings” command again and verify that the “Auto-show when editing text” option remained on? I have one weird situation where this randomly turned off on me.

      Another thing to possibly change is to re-adjust the Kiosk bash script so that onboard is launched after Chromium.

      /usr/bin/chromium --app=  --noerrdialogs --disable-infobars --kiosk --window-position=0,0 --window-size=, &
      /usr/bin/dbus-run-session /usr/bin/onboard

      Please let me know if this resolves the issue.

      Kind regards,
      Emmet

    2. Avatar for Randomdude
      Randomdude on

      Hi Emmet,

      I came here because of the same issue. All the onboard settings are correct, but no pop-up for login when the chromium kiosk mode is active.

      The switch of the startup order of the two processes seems not to work.
      In fact the onboard startup actually shuts down or crashes the chromium kiosk process and thus the service fails.

    3. Avatar for Lewis
      Lewis on

      Was able to figure out what was going on.

      In the Onboard settings, under Window, check “Force window to top”.

      Worked for me when Chromium was full screen and in kiosk mode.