X[DEPRECATED] old Dev Setup - thomasloven/hass-config GitHub Wiki

WIP

Here's a short description on how I run my development setup for Home Assistant.

I run everything in docker using docker-compose.

Directory structure

My development root directory contains:

docker-compose.yml

version: '3'
services:
  hass:
    container_name: homeassistant-hass
    image: homeassistant/home-assistant:dev
    volumes:
      - ./home-assistant:/usr/src/app
      - ./config:/config
      - ./home-assistant-polymer:/frontend
    environment:
      TS: Europe/Stockholm # adjust this to your liking, obviously
    restart: always
    ports:
      - "8123:8123"
  polymer:
    container_name: homeassistant-polymer
    build: ./home-assistant-polymer
    image: home-assistant-polymer:latest
    volumes:
      - ./home-assistant-polymer:/frontend
    restart: always
    command: script/develop

Setting up

To get started; in your root directory, run

$ docker-compose build
$ docker-compose run polymer script/bootstrap
$ docker-compose up

Configuring Home Assistant

Once home-assistant and home-assistant-polymer has finished booting, stop everything with ctrl+c and set up config/configuration.yaml. It will have been created by Home Assistant.

The important setting in the Home Assistant configuration is to add

frontend:
  development_repo: /frontend

But you may also want to add:

demo:

to get some demo entities to experiment with.

Using

To start the dev server, simply run

$ docker-compose up -d

If you wish to see the log output, either omit the -d or run

$ docker-compose logs -f

Maintenance

To get the latest version of the backend or frontend, simply perform a git pull.

Since ./home-assistant is bound to /usr/src/app in the container, you will always run whatever code you currently have checked out, rather than the version installed in the container.

After changes to the backend you can restart the service with

$ docker-compose stop hass
$ docker-compose up -d hass

If there have been any changes to the node modules of the home-assistant-polymer repo, you may need to run script/bootstrap or yarn inside that container. If it's already running, this can be done with

$ docker-compose execute polymer script/bootstrap
$ docker-compose execute polymer yarn

If not, use

$ docker-compose run polymer script/bootstrap
$ docker-compose run polymer yarn

About git linting

The home-assistant-polymer repo has a number of git hooks installed that runs various linters and code formaters when many actions are performed. If you don't have the correct dependencies installed on your system, you will get an error message but the command will go through.

To make sure you're not pushing any code that hasn't gone through the formaters, make sure to run:

$ docker-compose execute polymer git commit --amend

before pushing your code. This will open vim to allow you to edit the latest commit message. Accept it without changes by pressing ZZ.