Installation Home Assistant on Docker

docker 是个好东西,想着Raspbian 是基于 Debian的系统,那定然是支持 docker的。

而有了docker,再raspberry pi上安装 Home Assistant就有了一种极其简单的方法。

1. 在Raspberry Pi 上安装docker

curl -sSL https://get.docker.com | sh

参考:https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/

2. 验证docker的安装是否正确

pi@raspberrypi:~ $ sudo docker --version
Docker version 18.06.0-ce, build 0ffa825
pi@raspberrypi:~ $ sudo docker info
Containers: 3
 Running: 2
 Paused: 0
 Stopped: 1
Images: 2
Server Version: 18.06.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
...

参考:https://docs.docker.com/get-started/#prepare-your-docker-environment

3. 在Raspberry Pi上基于Docker安装 Home Assistant

$ docker run -d --name="home-assistant" -v /path/to/your/config:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/raspberrypi3-homeassistant:0.XX.x
注意:
1. /path/to/your/config 指的是你本地的HA配置目录,用来在本地存放你要运行的 HA 配置,比如  configuration.yaml 等配置文件

2. :/config 这里的config指的是你 docker 镜像中HA的配置目录,如果/path/to/your/config 这个目录在本地存在,则HA启动时会读取本地的配置,入伏哦/path/to/your/config 在本地不存在,则读取docker镜像中HA的配置目录

3. 0.XX.x 指的是要指定的HA版本,比如0.72.0,具体版本可以到HA官网查询 https://www.home-assistant.io/

实际在本机安装案例:

mkdir /home/pi/workplace/config -p

sudo
docker run -d --name="home-assistant" -v /home/pi/workplace/config:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/raspberrypi3-homeassistant:0.72.0

安装成功后验证

pi@raspberrypi:~ $ sudo docker image ls
REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
homeassistant/raspberrypi3-homeassistant   0.72.0              df8da8840c1d        8 weeks ago         1.06GB

4. 在Raspberry Pi 上启动Docker中的 

homeassistant/raspberrypi3-homeassistant, 注意要指定版本0.72.0,不然docker会提示本地不存在,然后又重新去docker hup去下载
pi@raspberrypi:~ $ sudo docker run -v /home/pi/workplace/config:/config homeassistant/raspberrypi3-homeassistant:0.72.0
starting version 3.2.4
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=toggle>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=restart>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=check_config>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=reload_core_config>
2018-08-18 07:33:44 INFO (MainThread) [homeassistant.bootstrap] Home Assistant core initialized
2018-08-18 07:33:45 INFO (MainThread) [homeassistant.loader] Loaded frontend from homeassistant.components.frontend
2018-08-18 07:33:46 INFO (MainThread) [homeassistant.loader] Loaded api from homeassistant.components.api2018-08-18 07:33:46 INFO (MainThread) [homeassistant.loader] Loaded introduction from homeassistant.components.introduction
2018-08-18 07:33:46 INFO (MainThread) [homeassistant.setup] Setting up introduction
2018-08-18 07:33:46 INFO (MainThread) [homeassistant.components.introduction] 

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        Hello, and welcome to Home Assistant!

        We'll hope that we can make all your dreams come true.

        Here are some resources to get started:

         - Configuring Home Assistant:
           https://home-assistant.io/getting-started/configuration/

         - Available components:
           https://home-assistant.io/components/

         - Troubleshooting your configuration:
           https://home-assistant.io/getting-started/troubleshooting-configuration/

         - Getting help:
           https://home-assistant.io/help/

        This message is generated by the introduction component. You can
        disable it in configuration.yaml.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5. 登陆HAweb查看

http://192.168.1.x:8123

注意: 该ip是装docker的宿主ip,也就是你的本机ip

6. 修改配置文件,定制你喜欢的智能家居系统

pi@raspberrypi:~/workplace/config $ ls /home/pi/workplace/config
automations.yaml  configuration.yaml  customize.yaml  deps  groups.yaml  home-assistant_v2.db  scripts.yaml  secrets.yaml  tts

 

posted @ 2018-08-18 15:42 Dream_2017 阅读(...) 评论(...) 编辑 收藏