# Home Assistant アップグレード・インストール

**URL:** https://forum.ficusonline.com/t/topic/292
**Category:** Automation
**Created:** [2019 年 4 月 12 日午前 6:28 UTC](https://forum.ficusonline.com/t/topic/292 "2019-04-12T06:28:10Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2019 年 9 月 22 日午前 1:57 UTC](https://forum.ficusonline.com/t/topic/292/2 "2019-09-22T01:57:26Z")

</div>

## 新規インストール後、従来の設定を引継ぐ場合

python3.7（推奨バージョン）へアップグレード後python3仮想環境ディレクトリhomeassistantへインストール。

python3.7へのアップグレードについては以下参照。

> [@Python3.7のインストール](https://forum.ficusonline.com/t/topic/322):
>
> Ubuntu18.04サーバのpython3バージョンは3.6の為、最新版3.7をインストールします。 "python3"コマンド入力の際、この最新バージョンが選択されるように"update-alternatives"コマンドで指定します。 上記参照元にも注意書きがありますが、デスクトップ環境でpython3のリンク先を変更した場合、3.6と関連する一部GUIアプリに影響が出る可能性が有り…

```auto
$ python3 -m venv homeassistant

$ cd homeassistant

$ source bin/activate

$ python3 -m pip install homeassistant

仮想環境内で起動する場合（起動ログを確認する場合など）

$ hass --open-ui

```

## Home Assistantのサービスデーモンを作成（python仮想環境にインストールした場合）

> **[Autostart using systemd](https://community.home-assistant.io/t/autostart-using-systemd/199497)**
>
> Newer Linux distributions are trending towards using systemd for managing daemons. Typically, systems based on Fedora, ArchLinux, or Debian (8 or later) use systemd. This includes Ubuntu releases including and after 15.04, CentOS, and Red Hat. If...

```auto
$ sudo nano -w /etc/systemd/system/home-assistant@YOUR_USER.service

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/xxx/homeassistant/bin/hass -c "/home/%i/.homeassistant"

[Install]
WantedBy=multi-user.target

```

**サービスデーモンのロード・有効化**

```auto
$ sudo systemctl --system daemon-reload

$ sudo systemctl enable home-assistant@YOUR_USER

$ sudo systemctl start home-assistant@YOUR_USER

```

## 設定ファイルのコピー

Home Assistant停止後、以下フォルダ内の選択部分をコピーします。選択されていないファイル・フォルダは全て削除して下さい。

**DB、logファイルは削除して新規作成**

 ![hass_config](https://forum.ficusonline.com/uploads/default/original/1X/852dddc3fd3228c19516a00fe30aa6eff05572cf.png)

**UIの設定ファイルのみ選択**

 ![hass_storage](https://forum.ficusonline.com/uploads/default/original/1X/15f3ba57b619fc36407ffcc4e395d9af6d13d850.png)

起動してユーザを再設定して下さい。

注）configuration.yaml内のhomeassistant:カテゴリの以下項目は.strage/core.configに移行したため削除可能\*\*

**configuration.yaml :**

```auto
homeassistant:
  latitude: 32.87336
  longitude: 117.22743
  elevation: 430
  unit_system: metric
  time_zone: America/Los_Angeles
  name: Home
# 上記省略可

# その他項目は従来通り
  customize: !include customize.yaml
  customize_domain:
  customize_glob:

```

**.strage/core.config（起動後作成されます）**

```auto
{
    "data": {
        "elevation": 0,
        "latitude": 35.xxxx,
        "location_name": "Home",
        "longitude": 139.xxxx,
        "time_zone": "Asia/Tokyo",
        "unit_system": "metric"
    },
    "key": "core.config",
    "version": 1
}

```

> **[Customizing entities](https://www.home-assistant.io/docs/configuration/customizing-devices/)**
>
> Simple customization for entities.

---

_[View the full topic](https://forum.ficusonline.com/t/topic/292)._
