Home Assistant is an Open source home automation tool that is constantly being updated and enhanced through contributions from a large DIY community. Home Assistant is perfect to run on a Raspberry Pi or a local server to bring together various different technologies for a cohesive ecosystem, create automation and rules and integrate with your smart speaker. This post is a Home Assistant Beginner’s Guide in 2022 and targeted to those who are planning to set up Home Assistant using for the first time and will cover the following topics:
- Installing Home Assistant – Basic install from scratch on a Raspberry Pi
- Understanding addons and top recommended Addons – Making use of the community and some of the great addons that are out there
- Adding devices – Installing an example device for each installation type
Refer to my Instruction video here or follow the detailed instructions below:
What will you need:
- Raspberry Pi (Model 3 or 4)
- Power Supply (make sure the power supply is sufficient to avoid stability issues)
- USB Cable for Raspberry Pi Power
- > 32GB microSD card
- Ethernet Cable
Installation
Step 1 – Determine which type of the Home Assistant build is correct for you.
Home Assistant is the program which we will be using and can pretty much be built to work on most key operating systems.
For the purposes of this article, we will be using Home Assistant for the Raspberry Pi.
Step 2 – Determine the correct image
Determine which device to which you will be deploying Home Assistant. For this guide, we will be installing onto a Raspberry Pi 3 Model B and have selected the Raspberry Pi 3 Model B and B+ 32bit image at the following link. You will need to copy the link to use in Step 4.
Step 3 – Download and install flashing software
You will need software to install the Home Assistant image onto your MicroSD card. Etcher is a good option which is a free, open source software to flash devices.
Step 4 – Flash Home Assistant image to MicroSD card
Use your preferred software to flash the image URL that you copied in Step 2.
Step 6 – Start up the Raspberry Pi
After inserting the MicroSD memory card, connecting Ethernet and power, you will need to wait for the device to initialise.
Step 7 – Connect to your Home Assistant installation
If all has gone well, you should now be able to connect to your Home Assistant installation through your browser. If your router supports mDNS then it will be accessible through http://homeassistant.local:8123 or else you will need to identify the IP address from your router e.g. http://192.168.x.x:8123. If it is not ready, then refresh and wait until you can see the “Preparing Home Assistant” screen.
The screen will then automatically change and allow you to configure locale settings and create an initial account and password and confirm any discovered devices.
You should then be presented with the initial overview screen and potentially some devices that have automatically been detected on your network.
The left sidebar has useful screens including:
- Overview: The main screen to configure cards and views for managing and using your automations.
- Energy: To view smart energy data
- Map: To view devices sharing location in the Home Assistant App
- Logbook: To view logs generated for Home Assistant system and linked services and devices
- History: To view a historical view of logs
- Media: To manage any configured media devices
Top Addons
Step 8 – Install Samba share add-on
You may already have some devices discovered, however you may need to edit configuration files to add additional devices and sensors. An easy way to do this is to add the Samba share add-on to allow editing outside of the browser. To do this:
- Go to the Settings link in the left-hand side navigation panel
- Click on Add-ons
- Click Add-on store button
- Click/search for Samba share and then Install
- Once installed, Click Start
- Click Edit Config and be sure to enter in a user name and password as Samba share will open your Home Assistant device to the network:
- Click Save and return to the previous screen.
- Click Start to enable Samba share
Step 9 – Edit your configuration files
Your configuration files should now be accessible through Windows Explorer e.g. \\homeassistant.local\config or an IP address (same IP as how you reached Home Assistant in the browser):
The key configuration files are:
- automations.yaml – Used to specify your automations and the underlying scripts that are executed. These can also be added from within the Home Assistant interface
- configuration.yaml – The key configuration file which is where you will add your manual components and key configurations
- scripts.yaml – Used to specify a sequence of actions to be executed by Home Assistant when turned on
- secrets.yaml – Used to store your user names, passwords, APIs and other sensitive information to avoid disclosing via the configuration.yaml file
Additional Hints:
- I use Visual Studio Code to edit my files as it helps maintain the strict formatting for the configurations and is free and open source.
- If you make changes to your configuration files, you can run a validation over the files to check if you have made any errors. Go to Developer Tools > Check Configuration.
Step 10 – Install Studio Code Server Addon
In the hint noted above, I use a locally installed version of Visual Studio Code, however there are new addons available to edit in-browser with Studio Code. To install, follow these steps:
- Go to the Settings link in the left-hand side navigation panel
- Click on Add-ons
- Click Add-on store button
- Click/search for Studio Code Server and then Install
- Once installed, Start the addon
- Select ‘Show in sidebar’ to make it visible
- You will now be able to edit your configuration files from the browser
Step 11 – Install MQTT Mosquito Broker
Local MQTT is one of the best options for communicating between devices and Home Assistant. Using MQTT locally will mean that in the event that you have power or internet issues, your devices can still communicate back and forth with Home Assistant. Toinstall, follow these steps:
- Go to the Settings link in the left-hand side navigation panel
- Click on Add-ons
- Click Add-on store button
- Click/search for MQTT Mosquito Broker and then Install
Installing MQTT takes a little bit more effort to set up and there are some additional steps.
- First you should create a separate user account for MQTT and to do this, go to Settings, People and create an account such as mqttuser. You will need to allow the person to login and set an appropriate
- You will need to select ‘allow login‘ to set a password and can further restrict this to allow log in from the local network.
- If you want to lock down the account further, you can remove login ability afterwards and MQTT will still work
- You now need to Configure the MQTT integration, so navigate to settings, configure button under MQTT
- Follow the prompts to initialise and then under settings, enter in the mqtt user name and password that was just created
Adding Devices
There are a few different ways to add devices including:
- Automatically Discover
- Installing Platform integration or Device
- Manual
There are also different device classifications based on how the device communicates with Home Assistant:
Classifier | Description | Pros | Cons |
Assumed State | We are unable to get the state of the device. Best we can do is to assume the state based on our last command. | N/A | N/A |
Cloud Polling | Integration of this device happens via the cloud. | Simple integration with cloud provider | – Polling the state means that an update might be noticed later. – Requires an active internet connection. |
Cloud Push | Integration of this device happens via the cloud. | – Simple integration with cloud provider – Home Assistant will be notified as soon as a new state is available. | – Requires an active internet connection. |
Local Polling | Offers direct communication with device. Polling the state means that an update might be noticed later. | – Does not require active internet connection – Limited lag between messaging – Privacy maintained as used within internal network | – Polling the state means that an update might be noticed later. – More complex setup for devices generally required |
Local Push | Offers direct communication with device. Home Assistant will be notified as soon as a new state is available. | – Does not require active internet connection – Limited lag between messaging – Privacy maintained as used within internal network – Home Assistant will be notified as soon as a new state is available. | More complex setup for devices generally required |
Step 12 – Adding an automatically discovered device
- First of all, go to the “Settings” and “Devices and Services”.
- Any discovered devices will have a blue heading noting ‘Discovered‘
- Home Assistant has picked up that I have an Epson printer on my network and shows on the screen.
- Click Configure to follow the prompts to add the device and location
Step 13 – Adding a device through the UI
Next we will go through how to install a device or platform integration through the user interface.
- Go back to Settings and “Device and Services”.
- Select “Add Integration” in the bottom right
- For this example, I’m going to add my Ring Doorbell
- Search for the device or platform and select it
- Enter in the associated account details including 2fA if this has been enabled.
- Select the area where the device is located and then finish. If you need to create an area, select add new area and then add.
- The Ring integration is now visible in the integration screen.
- If you go to the overview screen, you can now see the last image on the camera and key details on last ding and motion.
If you are interested in more Ring automations and details, check out my Ring integration post.
Step 14 – Adding a device manually
The final type of device is through manually adding it. This may be due to it not being supported or in the case I am about to show you, you want to add it through MQTT.
- We can use Studio Code Server to edit our configuration files and add in the details.
- For the example below, I have added in a Tasmota switch which will connect into my MQTT Broker
- Now that we have updated the configuration file, navigate to the “Developer Tools” screen, use the Check Configuration button to see if the changes we made are valid and then Restart the system.
- Once it has restarted, in the Overview switch, I can see my Switch called “Coffee Machine” and I am able to turn it off and on.
Hopefully you learnt something and enjoyed the Home Assistant Beginner’s Guide in 2022! If you haven’t checked out the video at the top of this page, please check it out and like and subscribe to my channel.
Good luck using Home Assistant!