「Home Assistant」の版間の差分
細 (typo修正) |
Kusanaginoturugi (トーク | 投稿記録) (→使用方法: === Using MariaDB === を追加) |
||
20行目: | 20行目: | ||
なお、初回起動には20分程度かかる場合があります。[https://www.home-assistant.io/docs/installation/]依存ソフトウエアがダウンロード・インストールされるためです。なお、[[journalctl]] を使うと起動処理の状況を確認できます: |
なお、初回起動には20分程度かかる場合があります。[https://www.home-assistant.io/docs/installation/]依存ソフトウエアがダウンロード・インストールされるためです。なお、[[journalctl]] を使うと起動処理の状況を確認できます: |
||
$ journalctl -fu home-assistant |
$ journalctl -fu home-assistant |
||
+ | |||
+ | === Using MariaDB === |
||
+ | |
||
+ | By default, SQLite is used for the recorder/history integration within Home Assistant. A noticeable performance boost is achievable by using MariaDB (especially for larger setups). Home assistant uses SQLAlchemy which means that any backend is supported, like MySQL, MariaDB, PostgreSQL, or MS SQL Server. Here we only discuss MariaDb, for others please refer to the [https://www.home-assistant.io/integrations/recorder/ recorder integration documentation]. |
||
+ | |
||
+ | If not already installed, please refer to [[MariaDB]] for installation details. |
||
+ | |
||
+ | [[Install]] the {{Pkg|python-mysqlclient}} package dependency. |
||
+ | |
||
+ | Create a new database, the example below shows a single username per service, with wildcard access to all databases having the username as a prefix e.g.: |
||
+ | {{hc|$ mysql -u root -p|<nowiki> |
||
+ | CREATE USER 'username'@'localhost' IDENTIFIED BY 'some_pass'; |
||
+ | CREATE DATABASE username; |
||
+ | GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; |
||
+ | FLUSH PRIVILEGES; |
||
+ | quit; |
||
+ | </nowiki>}} |
||
+ | |
||
+ | Add to your configuration file: |
||
+ | {{hc|/var/lib/hass/configuration.yaml|<nowiki> |
||
+ | recorder: |
||
+ | db_url: !secret recorder_mariadb_url |
||
+ | </nowiki>}} |
||
+ | |
||
+ | Add to your secrets file (if not using a Unix socket, see the [https://www.home-assistant.io/integrations/recorder/ recorder integration documentation] for alternative URLs): |
||
+ | {{hc|/var/lib/hass/secrets.yaml|<nowiki> |
||
+ | recorder_mariadb_url: "mysql://USER:PASSWORD@localhost/DATABASE?unix_socket=/var/run/mysqld/mysqld.sock&charset=utf8mb4" |
||
+ | </nowiki>}} |
||
+ | |
||
+ | Finally, [[restart]] the {{ic|home-assistant.service}}. The database should now start to populate. For more information refer to the [https://www.home-assistant.io/integrations/recorder/ recorder integration documentation]. |
||
== 参照 == |
== 参照 == |
2021年7月21日 (水) 12:02時点における版
Home Assistant はオープンソースのホームオートメーションソフトウェアです。ローカル制御とプライバシー優先を志しています。ハッカーや DIY マニアの世界的なコミュニティによって運営されています。
インストール
home-assistant パッケージをインストールしてください。
設定
設定ファイルは /var/lib/hass/
に保存されます。設定ファイルが存在しない場合、デフォルトの設定が起動時に書き込まれます。
使用方法
Home Assistant を起動するには home-assistant.service
を起動・有効化してください。
デフォルトでは、http://localhost:8123
からウェブインタフェースを開けます。
なお、初回起動には20分程度かかる場合があります。[1]依存ソフトウエアがダウンロード・インストールされるためです。なお、journalctl を使うと起動処理の状況を確認できます:
$ journalctl -fu home-assistant
Using MariaDB
By default, SQLite is used for the recorder/history integration within Home Assistant. A noticeable performance boost is achievable by using MariaDB (especially for larger setups). Home assistant uses SQLAlchemy which means that any backend is supported, like MySQL, MariaDB, PostgreSQL, or MS SQL Server. Here we only discuss MariaDb, for others please refer to the recorder integration documentation. If not already installed, please refer to MariaDB for installation details. Install the python-mysqlclient package dependency. Create a new database, the example below shows a single username per service, with wildcard access to all databases having the username as a prefix e.g.:
$ mysql -u root -p
CREATE USER 'username'@'localhost' IDENTIFIED BY 'some_pass'; CREATE DATABASE username; GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; FLUSH PRIVILEGES; quit;
Add to your configuration file:
/var/lib/hass/configuration.yaml
recorder: db_url: !secret recorder_mariadb_url
Add to your secrets file (if not using a Unix socket, see the recorder integration documentation for alternative URLs):
/var/lib/hass/secrets.yaml
recorder_mariadb_url: "mysql://USER:PASSWORD@localhost/DATABASE?unix_socket=/var/run/mysqld/mysqld.sock&charset=utf8mb4"
Finally, restart the home-assistant.service
. The database should now start to populate. For more information refer to the recorder integration documentation.