Featured

Hello world!

ha.qx.cx – a guide on how to run, maintain and operate a cloud free home automation system.

Welcome to ha.qx.cx – this blog exists as a gx project and is a guide on how to run, maintain and operate a cloud free home automation system.

The structure will be simple:

  • Strides – a small collection of steps (and footsteps) that achieve a particular goal.
  • Steps – core steps that will most likely need to be followed to build the system.
  • Footsteps – optional or expansion to steps that extend the system and can be tweaked for personal use.

The contents page will be kept up-to-date with links to the whole guide.

Start: Step 1: Engine

Step 12: External

Just because this is a cloud free setup does not mean that you won’t be able to access your system while you are out and about. Problem is, depending on your requirements and budget, there are a plethora of ways to achieve this.

So, lets look at two base options: domain name with a static (or relatively) IP address and the dynamic dns option. After that you can choose between direct firewall access to port 8123 or push through a reverse proxy, don’t worry Home Assistant can help with lots of this.

Ultimately, you want to be able to login to your home Home Assistant system via the mobile app or browser to manage and monitor your home.

  • Domain Name
    • get an awesome domain name with a basic DNS
    • point the domain at your home IP address with an A record
    • prove you can access http://<domain>:8123
  • Dynamic DNS
    • get a duck dns account
    • install duckDNS via the Supervisor:
      • Supervisor -> Add-on Store
    • configure with token and subdomain
      • here you can use the LetsEncrypt option but don’t if you choose to go for the reverse proxy
    • prove you can access http://<subdomain>.duckdns.org:8123

Now the question of the reverse proxy, if you run multiple services/domains you will probably benefit from having a single entry point to proxy all web requests through, otherwise all it will seem is that you are hiding the port number from the web address.

  • No proxy
    • done – nothing else to do!
  • Proxy
    • install Nginx Proxy Manager via the Supervisor:
      • Supervisor -> Add-on Store
    • configure with domain/subdomain
    • add LetEncrypt SSL and email address
    • save and wait for the SSL setup to complete
    • prove you can access: https://<domain> or https://<subdomain>.duckdns.org

Now the mobile app can report back to your own server over a HTTPS connection your phones location, battery level and WiFi connection name – all things you can base automations from!

Next: Step 13: Moremation

Step 11: Automation

So, you finally have all the building blocks for automation: a sensor to activate a switch or set of switches.

The original initial goal of this blog was to setup a cloud free home automation system, this got extended with the ability to control the lights a house without ever manually having to switch them on or off.

This is starting to be achievable! If you only have the one sensor then you will only be able to control one room, but the principles will be exactly the same.

There are example automation scripts that can do this, but lets build our own simple one. Please bear in mind that the setup described will only work with one actor i.e. one person within the home.

First you’ll need to start a new automation script via the big plus button within the automation configuration section.

Configuration -> Automations -> +

Give it a suitable name like “lounge lights” or whatever is appropriate, and set the motion sensor as a trigger event and then add a condition on the sensors luminance to ensure it is dark enough to warrant triggering the lights.

Then add all the light switches/devices that you want to turn off – such as all the ones outside of the room where the motion sensor for the trigger is – and then also add the lights switches/devices that you want to turn on as actions at the bottom of the automation screen.

Another option here is to call the scene.turn_on service and have a scene setup with the lights you want turning on. Unfortunately with this setup you do not want to simply create an all lights off scene and add that too as every-time motion is detected all the lights will turn off then the ones you want on will turn back on, so you want to set it as described to stop potential light flickering or make a collection of scenes – one for each room to control.

There are tons more automations capable and there will be a couple more covered in this stride, but first you will need to be able to access your system via the mobile app out and about for some real fun…

Next: Step 12: External

Stride 2: Lights, Camera …

That completes Stride 2: Lights, Camera …, in this stride you learnt:

  • about custom components and how to install them along with HACS to make it easier in Step 6: Components
  • sensors and switches through wi-fi or z-wave in Step 7: Senses
  • how easy it is to include new devices into your z-wave mesh network in Step 8: Entities
  • to rename your sensor and switch devices to make it easier to manage in Footstep 3: Rename
  • about the Lovelace UI and how to configure through the built in interface and through the code editor in Step 9: Dash
  • that you can extend the frontend interface to have an amazing floorplan design to place your entities in Footstep 4: Floor
  • how to pull all the parts of automation enabling functions can provide in Step 10: Detail

This stride has given an overview of the systems to help you automate your home, the next stride will put everything into action.

Next: Step 11: Automation

Step 10: Detail

To wrap up everything that helps enable automation you need to know about three more core functions within Home Assistant:

  • zones
  • areas
  • scenes

You have one zone setup from the beginning which is your Home zone, you can add other zones and areas directly through the Configuration panel.

Configurations -> Zones

Entering or leaving a zone can be used to trigger automations in your home. To take full advantage of this you need a device tracker linked to your user – this will be covered in the next stride.

Configuration -> Areas

Areas can be setup to group entities into an area or most likely a room. That way you can affect entities in a particular area. Devices will need to be configured to know what area it exists within.

Configuration -> Scenes

Finally scenes can put a set of entities into a particular pre-configured state, such as having a night mode scene that turns all lights out and disables motion detection in the bedrooms.

Complete: Stride 2: Lights, Camera, …

Footstep 4: Floor

Another really cool option for visual control of your house is the Floorplan component, this will be covered in a stride of its own to get into the nitty gritty. But as a quick overview by:

  1. installing and enabling the component
  2. creating an image for your floorplan(s)
  3. adding entities to the image(s)

You will be able to control the elements of your home automation from a panel resembling your home layout linking the lounge light to the lounge area of your image, for example.

For some inspiration on what is achievable check out these search results. Everything from elegant top-down views to amazing three dimensional views.

The three simple overview steps above do make it seem simple to achieve this, but unfortunately it can be a bit fiddly. Once you get the hang of the process it’ll become second nature soon enough! It will be a good idea to have renamed your entities as the links required in the image itself need the name of the entity.

Next: Step 10: Detail

Step 9: Dash

Let’s start making your Home Assistant setup looking a bit more friendly. By default you will just have one page showing all the active sensors and integrations not in any particular order.

You can choose to manually manage the front end interface – known as the Lovelace UI – and for the most part you can configure this through the interface itself via the three vertical dots in the top right corner.

When you first select ‘Configure UI’ it will warn you that entities would be automatically placed as they are discovered and integrated, but once you manually start to control the UI you will have to add new entities and elements when and where you want them.

You’ll want to take a moment to think about how you want to interact with your home automation system and even how you want to layout your interface. Do you want a panel per floor of the house or per room? Do you want an overview page that summarises the status of the house? Do you want all that and more?

It is recommended to have a bit of a play to work out how you want to laydown the UI elements. Lovelace UI breaks items into ‘tabs’ which can have ‘badges’ and ‘cards’.

You can add as many tabs as you like and tabs can have multiple badges and cards within, you can even place cards inside of other cards such as the horizontal and vertical stack cards. You can also include custom cards that you have installed through HACS.

Conditional cards are really handy to show cards only when certain conditions are true or false. For example, you can setup your Chromecast to only show when powered or playing:

card:
   entity: media_player.cc
   type: media-control
conditions:
  - entity: media_player.cc
    state_not: 'off'
  - entity: media_player.cc
    state_not: unavailable
type: conditional 

The above card will show the control card for the ‘media_player.cc’ entity but only when it is not ‘off’ or ‘unavailable’.

The Android IP Webcam that was previously added to the Home Assistant can be directly viewed through a Picture Entity card and the sensors and switches managed through an entities card:

entities:
  - entity: sensor.cam_1_battery_level
    name: Cam Battery
  - entity: sensor.cam_1_battery_temperature
    name: Cam Temperature
  - entity: switch.cam_1_torch
    name: Cam Torch
  - entity: switch.cam_1_video_recording
    name: Cam Video Recording
type: entities 

The above entities card will show the battery and temperature levels and provide toggle switches for the torch and option to video record.

You can also use Glance cards to have a quick overview of a selection of entities. Remember all these elements can be used within horizontal and vertical stack cards for ultimate layout control.

entities:
  - entity: binary_sensor.motion_sensor_1_sensor
    name: Motion
  - entity: sun.sun
  - entity: sensor.moon
  - entity: sensor.phone_battery
    name: Phone
  - entity: sensor.tablet_battery
    name: Tablet
title: Overview
type: glance

All of the above code views of the Lovelace UI layout cards are just for demonstration purposes as these are all cards available directly through the interface configuration and can be added visually with drop down selections and manually edited if wished.

Don’t forget to add a card for controlling the dimmer switch and cards to view the temperature and/or luminance of the sensor.

Next: Step 10: Detail via Footstep 4: Floor

Footstep 3: Rename

You will have probably noticed that all the devices have a ridiculously long and inappropriate name. The motion sensor and it’s associated entities can amalgamate a massively long and cumbersome name .

Fret not, these names can be changed. In fact a good chunk of details can be customised through the built-in management interface provided by Home Assistant.

Configuration -> Customization

Through the customisation interface you can not only change the devices represented name, but the unit of measurement or any attribute the device has.

You can also edit just the names of entities through the entitity registry interface.

Configuration -> Entities

Renaming your devices and sensors makes sense, especially if you are expecting to buy multiple of the same type of sensor. In a couple of years time will you remember that fgms001-zw5_motion_sensor_1 is in the lounge and that fgms001-zw5_motion_sensor_2 is in the hallway!? You possibly will, but a way of guaranteeing that is to rename the devices to have a suitable and appropriate name.

Next: Step 9: Dash

Step 8: Entities

Let’s have a look at what devices can be controlled and connected to Home Assistant with the Z-Wave integration. First you need a Z-Wave hub/controller, in this case an AEON Labs ZW090 Z-Stick Gen5 EU is connected directly via USB into the Raspberry Pi running the Home Assistant software.

To enable Z-Wave within the Home Assistant you’ll need to go to the Integrations section and configure the device.

Configuration -> Integrations

To complete the configuration you’ll need the:

  • usb_path: most likely /dev/ttyACM0
  • network_key: if you want to make use of Z-Wave Plus and the extra security it can provide. Due to the extra bandwidth and battery requirement this is only recommended for certain devices such as locks.

You can generate the network key following the steps included at Home Assistants own documentation they also have a great getting started section with links to many useful resources.

Now Z-Wave compatible devices can be added, managed and removed via the newly enabled Z-Wave configuration panel.

Configuration -> Z-Wave

With this guides initial goal of automatic lighting focus will be given on motion sensors and switches. in this case the following specifics will be utilised:

  • Fibaro FGMS001-ZW5 Motion Sensor – a motion, temperature and luminance sensor
  • Everspring AD142 Plug-in Dimmer Module – a dimmer based pass-through plug socket

These devices have simple pairing functions and can be added via the Z-Wave Configuration panel, with some devices you need to ensure your are registered to receive the sensors outputs through the ‘group associations’. Home Assistant should do this for you automatically, but your experience could differ depending on the controller and devices.

Next: Step 9: Dash via Footstep 3: Rename

Step 7: Senses

Home automation relies on ‘senses’ to be able to understand the situation and apply your rules to. Home Assistant achieves this through Integrations. Devices have entities which need integrating to Home Assistant in order to take advantage of them.

A quick example: Android IP Webcam (available through the Play Store) can be integrated into Home Assistant through the ‘configuration.yaml’ file. In this case there is an old Android phone with a static IP on the local Wi-Fi network running the IP Webcam software.

android_ip_webcam:
  - host: 192.168.10.100
    port: 8080
    name: 'Cam 1'
    sensors:
      - battery_level
      - battery_temp
    switches:
      - torch
      - video_recording 

Add the above configuration and restart Home Assistant to enable two sensors and two switches. The Home Assistant integration documentation shows all the available sensors.

Generally speaking integration devices are going to either connect directly to the host running Home Assistant or wirelessly. When you work out what kind of home automations you want to achieve you can then work out what solutions are going to be best. In this series the simple idea of automating the light switches to not need to manually ever switch a light on or off is the initial goal.

There is loads of choice when it comes to wireless devices that you can connect for home automation. If you are trying to do this in a complete cloud free way it can be tricky, so many systems come with their own cloud account to allow you to remotely manage. This is unnecessary with Home Assistant as this acts as the ‘cloud’ for your home automation giving you one interface to control everything. So you just need to have the devices connect to Home Assistant and then only allow access to Home Assistant externally via a web browser and/or the mobile app. This external and mobile access will be covered in a mini-stride soon, it can also enable your phone as a location tracker for automation.

For this guide and setup it was decided upon utilising Z-Wave wireless mesh technology over Wi-Fi to completely eliminate the potential for cloud based connected devices, ensuring the system will still operate and be locally controllable without Internet connectivity. This requires a Z-Wave hub or controller to manage the mesh network that the devices form.

Next: Step 8: Entities

Step 6: Components

Home Assistant accepts add-ons and custom components to expand the functionality and provide complete customisation by being able to write a new component if one does not exist already.

Custom components are uploaded to a folder within the ‘config’ directory of the Home Assistant installation and add integrations, custom cards and themes. There is a system available to make this process easier called the Home Assistant Community Store or HACS for short, which allows you to install community made components in a couple of clicks.

Before we get to HACS lets look at the built in Add-On store available via the Supervisor, from here you can install updates, take snapshots of the system and install items that expand Home Assistant itself, such as dns services, reverse proxy, smb and ftp access and many more.

Some add-ons can open ports and access to your system and depending on your specific setup on how in-secure this can make you. Thankfully Home Assistant make this very clear with badges detailing the requirements and security level of the add-on. This even covers items such as the ftp and smb as they allow access to the ‘config’ folder’, but you can simply stop the service, ensure that it is not set to run at startup of Home Assistant and only run it when you need to use it.

HACS itself needs to be added via the manual method and requires a GitHub access token, but has well documented the process on their site hacs.xyz, but the run down is:

  1. download HACS from github
  2. upload the contents of hacs.zip to the custom_configuration folder within your ‘config’ folder
  3. restart Home Assistant
    Configuration -> Server Controls -> Server management -> Restart
  4. add HACS from the Integration panel
    Configuration -> Integrations
  5. enter your GitHub access token
  6. access HACS
    HACS

As mentioned, HACS allows you to add integrations, plugins and themes with just a few clicks and prompts you if a restart of Home Assistant is needed to complete the install of the new component to take advantage of.

Next: Step 7: Senses