Setting Up Easy Home Automation

In the previous post, Rebuilding a Solid Base Home Server, we explored setting up a solid base to build our home services on. Using what we have lets begin to explore a topic I’m sure is near and dear to your heart.

The Problem

I find that throughout my time as a functioning adult, I have accumulated many different smart things weather I wanted to or not. With every smart thing I get, I have to create a new account and use that specific app to control said thing. There are apps for my washing machine, dryer, smart bulbs and plugs for areas with weird light switches, exterior cameras/lights/doorbells, even my TV has an app I can use. I want to be able to have access to these things from a central location, and I’m getting tired of using Alexa to control what is connectable.

The Solution

In searching for a locally hosted product, I discovered Home Assistant. This is going to allow me to control all these things and more. And my personal favorite aspects: it is free, the configuration I have is on my home system versus hiding in a data center halfway around the world. Lets set this up and see what we can do!

The Implementation

First things first lets set a directory for our configuration to live. As we recall from our previous exercise, our custom config lives in /opt. So we will create our directory there, and since we prefer containerization we will have a place for Home Assistant (HA) to place what it needs within it.

mkdir -p /opt/home-assistant/config

Since we want the OS to control the container versus running it manually and letting docker control it, lets remember the lesson we learned previously and set this up as a service. We can do this by creating the file /etc/systemd/system/home-assistant.service.

[Unit]
Description=Home Assistant Service
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop home-assistant
ExecStartPre=-/usr/bin/docker rm home-assistant
ExecStartPre=/usr/bin/docker pull ghcr.io/home-assistant/home-assistant:stable
ExecStart=/usr/bin/docker run --rm --name home-assistant \
-v /opt/home-assistant/config:/config \
-p 8123:8123 \
ghcr.io/home-assistant/home-assistant:stable
ExecStop=/usr/bin/docker stop home-assistant

[Install]
WantedBy=default.target

Now that we have the service in place, we can start and enable it.

systemctl start home-assistant.service
systemctl enable home-assistant.service

Now when navigating in our browser to http://<server_ip>:8123 we get our lovely setup screen!

I leave setting up your server to your specific needs as an exercise for the user. Once you are set up though, we will want to begin adding some plugins for what we need. Now the plugins for HA can be tricky to install manually, however someone has created a wonderful plugin that can install most things for you. Enter HACS or the Home Assistant Community Store. Installing this is as easy as running a few lines on your terminal.

First we need to enter the container running HA.

docker exec -it <ha_container> bash

Then execute the download install script.

wget -O - https://get.hacs.xyz | bash -

Once that completes, exit the container. Then we simply restart HA.

systemctl restart home-assistant.service

Voila, HACS is now installed. There is some configuration that needs to happen as you need to log in with GitHub, you can access that on the official documentation.

For my purposes, I had to download the following plugins from HACS:

  • UI Lovelace Minimalist
  • layout-card
  • Tapo Controller
  • Kiosk Mode
  • GE Home (SmartHQ)

These are the integrations I have as well:

  • GE Home*+
  • HACS*+
  • Meteorologisk institutt (Met.no)+
  • Mobile App
  • Ring+
  • Sony Bravia TV
  • Sun
  • TP-Link Tapo*
  • Waze Travel Time+

* HACS or HACS installed
+ Cloud or Internet dependent

You can find a plugin for most things you wish to do, and with a little bit of trial and error you can come up with dashboards like this! (Code provided below.)

Obviously there is a log going on under the hood, combining entities, creating helpers, automations, and in some cases even changing the type of an item. But that is all a part of the fun of trying new things! I will say that you will still need all of the accounts for various smart things, depending on the brand, but this at least puts control in one central spot.

In my next article I will take what we have done here today, and turn it into kiosks to scatter around the house (to yours and my significant other’s dismay)!

Living Room Dashboard Code (Can be created by UI)

views:
  - title: Main
    icon: mdi:home-circle
    path: main
    cards:
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            cards:
              - show_name: true
                show_icon: true
                type: button
                tap_action:
                  action: toggle
                hold_action:
                  action: more-info
                icon_height: 250px
                entity: light.living_room_lights
              - type: horizontal-stack
                cards:
                  - show_name: true
                    show_icon: true
                    type: button
                    tap_action:
                      action: toggle
                    entity: media_player.sony_kd_65x77l
                    name: Living Room TV
                    show_state: false
                    icon_height: 50px
        title: Living Room Overview
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            cards:
              - type: entities
                entities:
                  - entity: sensor.ms320771n_laundry_machine_state
                    name: Washing Machine State
                  - entity: sensor.gt159812g_laundry_machine_state
                    name: Dryer State
                  - entity: light.exterior_lights
                  - entity: light.family_room_lights
                  - entity: light.networking_room_lights
                  - entity: switch.deep_fryer
                    name: Deep Fryer Status
              - type: horizontal-stack
                cards:
                  - show_name: true
                    show_icon: true
                    type: button
                    tap_action:
                      action: toggle
                    entity: input_button.turn_off_living_room
                    show_state: false
                    icon_height: 75px
                  - show_name: true
                    show_icon: true
                    type: button
                    tap_action:
                      action: toggle
                    icon_height: 75px
                    entity: input_button.turn_off_all
        title: Whole Home Overview
  - title: Laundry
    path: laundry
    icon: mdi:washing-machine
    cards:
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            cards:
              - type: entities
                entities:
                  - entity: sensor.ms320771n_laundry_machine_state
                    name: Running State
                  - entity: sensor.ms320771n_laundry_washer_soil_level
                    name: Soil Level
                  - entity: sensor.ms320771n_laundry_washer_spintime_level
                    name: Spin Speed
                  - entity: sensor.ms320771n_laundry_washer_washtemp_level
                    name: Temperature
                  - entity: binary_sensor.ms320771n_laundry_door
                    name: Door Status
                title: Status
                show_header_toggle: true
                state_color: true
              - type: entity
                entity: sensor.ms320771n_laundry_time_remaining
                name: Time Remaining
                state_color: true
        title: Washing Machine
      - type: horizontal-stack
        cards:
          - type: vertical-stack
            cards:
              - type: entities
                entities:
                  - entity: sensor.gt159812g_laundry_machine_state
                    name: Running State
                  - entity: sensor.gt159812g_laundry_dryer_drynessnew_level
                    name: Dryness Setting
                  - entity: sensor.gt159812g_laundry_dryer_temperaturenew_option
                    name: Temperature
                  - entity: binary_sensor.gt159812g_laundry_door
                    name: Door Status
                title: Status
                show_header_toggle: true
                state_color: true
              - type: custom:gap-card
                height: 40
              - type: entity
                entity: sensor.gt159812g_laundry_time_remaining
                name: Cycle Time Remaining
                state_color: true
            title: Dryer

Share and Enjoy !

Shares

Leave a Reply

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

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