GithubHelp home page GithubHelp logo

home-assistant-docker-compose's Introduction

Home Assistant docker-compose

This is my setup for home assistant using docker-compose. This is tested and runs fine on any Ubuntu distribution from 16.04 onwards.

It contains the following components:

  • Home Assistant (duh)
  • Postgresql. The database Home Assistant should use
  • InfluxDB. The database Home Assistant writes sensory information to such that Grafana can read it
  • Grafana. Dashboarding
  • LetsEncrypt. Service to setup and maintain SSL for Home Assistant
  • Node Red: Alternative for the yaml automations in Home Assistant

A brief setup, requirements and list of quirks is compiled below per service. Most of these are a culmination of many forum posts of which is was unable to find all resources. Might you find the root post, please let me know and I will attribute it :).

Home Assistant

Doesn't require much setup. The home directory will be /home/<user>/.homeassistant. Change <user> to your username. To leverage all components you must have at least the following in your configuration.yaml.

http:
  api_password: !secret http_password
  base_url: !secret base_url
api:

influxdb:
  host: localhost
  port: 8086
  database: homeassistant
  username: !secret influxdb_username
  password: !secret influxdb_password
  
recorder:
  db_url: !secret postgres_url 

The postgres_url should be in this format:

postgresql://username:password@host/db

For example

postgresql://homeassistant:mypass@localhost/home-assistant

Postgresql

Should run without issues. Must be in host network mode for Home Assitant to be able to connect. You could setup a docker network, but this setup exposes Home Assistant to the outside world. The persistent directory will be /home/<user>/.postgres. Change <user> to your username.

InfluxDB

Should run without issues. Must be in host network mode for Home Assitant to be able to connect The persistent directory will be /home/<user>/.influxdb. Change <user> to your username.

Grafana

The persistent directory will be /home/<user>/.grafana. Change <user> to your username. The grafana docker container runs on user:group 472:472. The persistent volume must therefor be chmod as that user. Use sudo chown -R 472:472 /home/<user>/.grafana to achieve that.

LetsEncrypt

This is the most annoying one. It doesn't work out the box as described on their website The persistent directory will be /home/<user>/.letsencrypt. Change <user> to your username.

Also in the docker-compose.yml change <email> and <url> to your email address and your DNS name. Register one for free at https://www.duckdns.org/

After starting the LetsEncrypt once you have to modify /home/<user>/.letsencrypt/config/nginx/site-confs to add this:

### HOMEASSISTANT ##############################################################
server {
        listen 443 ssl;

        root /config/www;
        index index.html index.htm index.php;

        server_name <your-dns>;

        include /config/nginx/ssl.conf;

        client_max_body_size 0;

        location / {
                proxy_set_header Host $host;
                proxy_redirect http:// https://;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_buffering               off;
                proxy_ssl_verify              off;
                proxy_pass http://<host-ip>:8123;
        }
}

Without this nginx won't forward the DNS subdomain to Home Assistant. Replace <your-dns> and <host-ip> with your values. For every subdomain (perhaps you want to expose mqtt!?) you can add above configuration for each subdomain and add it to the SUBDOMAINS list, i.e.:

- SUBDOMAINS=hass,mqtt,other

Restart the container and if everything is right home assistant should be available on your own DNS address.

Node Red

Runs as user 1000 in the docker container. For some docker might run as root. The docker user for Node Red has therefor been configured as root such that Node Red has rights to read/write the persistent storage. The persistent directory will be /home/<user>/.nodered. Change <user> to your username.

After running the container, step into the container with docker exec -it nodered bash and run

cd /data
npm install node-red-contrib-home-assistant

exit the container and restart the container.

home-assistant-docker-compose's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

home-assistant-docker-compose's Issues

wrong port used for postgres

This is a great little docker compose that I think others will find really useful. I just wanted to point out that I think you've accidently swapped the port numbers around for postgres. The port exposed to the host should be 5432: 5432 .
Great work though! You've done really well in documenting it all.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.