Home Assistant: New Starter Tips

Overview

These are the things I wish I knew at the start of Home Assistant to save time and re-doing various setup related changes. It purely focuses on configurable points within Home Assistant as opposed to choices of eco systems, hubs, etc.

Naming Convention


Establish a naming convention. This applies to all aspects in Home Assistant. From entity IDs (see below) to names of automation. The key is consistency rather than one way is better than another.

Names are used all over the place. From entity IDs (details below) through to how they are presented and used in voice assistants.

For my own naming convention, I have used the location of the devices and the sensor. For example
light.bedroom_left.

Where it has multiple sensors in one device e.g SmartThing Multipurpose Sensor then tack on the sensor.
binary_sensor.bedroom_window
sensor.bedroom_window_temperature
SmartThings Multipurpose Sensor

If I have multiple sensors in the same room then I would append a number to the sensor.
This would describe the second window in the bedroom:
binary_sensor.bedroom_window_2
sensor.bedroom_window_2_temperature

Thus would describe a second temperature on the second window in the bedroom:
sensor.bedroom_window_2_temperature_2

If I had the same sensor in a different bedroom then it would go after the bedroom:
binary_sensor.bedroom_2_window

Entity ID’s

Entity IDs are key. They are used in the Lovelace dashboard through to automation. the naming convention I use allow me to quickly identify the device without having to look up their friendly name or figure out what sensor.philips_hue_motion1 is.

There have been instances where I’ve had to remove and add the integration back in because they stopped working. When you do this, it may not have the same entity IDs any more which means anything relying on them (dashboard, automations, etc) will not work either. This can be easily fixed with the below steps to get them working again.

To name your entities, go to Configuration > Entities > [find and select your entity] > Entity ID

Example where the ID appears:

Bonus: There are other customisable attributes on entities as well. See here.

Backup

Home assistant comes with a handy snapshotting feature right out of the box (as long as you’re using it in Supervised mode). Ensure you have set this up because it is a hobby project and it will break.

This is available in the Supervisor > Snapshots These snapshots are still on the same system so if the drive dies, then your snapshots goes as well.

To supercharge this, install Hass.io Google Drive Backup. This will automatically take snapshots and upload them to Google Drive. You can configure how many are stored locally and how many are stored in the cloud.

If you’re not using Supervisor then make sure you backup all your configuration files from configuration.yaml to all other references like secrets.yaml.

Bear in mind. Anything where your configuration file lives will be captured in the snapshot. This includes images to addons which may increase the time it takes to create the snapshot and the size of the snapshots. This includes your secret file with your passwords.

Separate Configuration files

The configuration files are at the heart of Home Assistant. Even if it’s configured in the web, it will usually end up in the configuration file.

As your integration grows so will your configuration file. The first one to do is separating any sensitive information such as tokens or passwords. These should be saved in the secrets.yaml file. In the configuration file, you can substitute the information using the name of the placeholder from the secrets file. For example:

secrets.yaml:
ifttt: myPassword

configuration.yaml:
ifttt:
key: !secret ifttt

where:
!secret – tells Home Assistant to look up the vbalue in the secret file.
ifttt – the name of the value from secrets.yaml.

This way, if you accidentaly show anyone your configuration file then it will not contain your password. You can also change the secret file permissions although Home Assistant will still need to read the file.

Everything can be put into a separate file. From ifttt (although I would question this because it has very little configuration) to files like groups.

The best thing is you can put them into the configuration file at first and if the setting gets too big then cut the content to an appropriately named yaml file and then refer to them. Here are my list so far:
automation: !include automations.yaml
binary_sensor: !include binary_sensor.yaml
group: !include groups.yaml
notify: !include notify.yaml
scene: !include scenes.yaml
script: !include scripts.yaml
sensor: !include sensor.yaml

More on this here.

Switch Database

The default database Home Assistant uses is Sqlite. This is an embedded database designed to be self contained which makes setup and backup easier. As your Home Assistant grows from entities to historical data, you’ll quickly see the limitations of this database. From long loading times in particular history and logbook tabs.

If you setup an external database from the start, you will not have to migrate from Sqlite or you can choose to not port historical data. I went with the former and it was painful (time and getting the data out). To do this, the configuration option is called Recorder.

Groups For Multiple Sensors

Where a room may / has multiple sensors such as a motion sensor then use groups. That way, if you add more of the same sensor then your automations will trigger if any one of the devices change state. When the group state changes can be found in the documentation.

As an example, I have two motion sensors in the lounge. I want the lights to come on regardless of which one picks up movement so I create a group:

group:
lounge_motion:
name: Lounge Motion
icon: mdi:walk
entities:
- binary_sensor.lounge_motion
- binary_sensor.lounge_motion_2

In the automation, I use group.lounge_motion as the trigger.

Messaging Platform

Home Assistant Slack
A standardised messaging platform where Home Assistant can post to. It’s a good idea for people to know where notifications can be seen especially for key events like if your home alarm has been triggered.

Another idea is to have a debugging log of events. Whilst Home Assistant has a history which you can display in a log file, I found it easier (and prettier) to use a chat system to view logs of what happened. Home Assistant UI isn’t always that performant and layout in LoveLace between web and mobile doesn’t scale as well as a dedicate app. I personally use Slack but others have used telegram with success. Within Slack, I have created a private channel (so it does not bother others with lots of message) as well as mute the channel so I don’t get a notification for each message. For every automation, I have it post to slack channel so I can see what is being triggered. Message detail varies but the idea is to be able to go back and see / figure out something was triggered or why did my lights not turn off.

Summary

I hope some of the ideas and things I have learnt help others to get started and minimise any redo down the line.

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Home Automation, Infrastructure, IOT and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

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

All comments must go through an approval and anti-spam process before appearing on the website. Please be patience and do not re-submit your comment if it does not appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.