数据组件的配置、mysql数据库及其它
操作步骤
- 组件
recorder
、history
、logbook
配置中的include
/exclude
recorder
组件的配置- 安装mysql数据库
- 使用mysql数据库
- 其它的一些数据相关组件
参考
- 数据组件配置介绍页面
https://www.home-assistant.io/integrations/history
https://www.home-assistant.io/integrations/logbook
https://www.home-assistant.io/integrations/recorder
-
include
/exclude
配置样式样例history: include: domains: - sensor - switch - media_player exclude: entities: - sensor.last_boot - sensor.date
-
recorder组件配置样例
recorder: purge_interval: 1 purge_keep_days: 10 # db_url: sqlite:////home/pi/.homeassistant/home-assistant_v2.db db_url: mysql://pi:hachina1234@127.0.0.1/my_homeassistant?charset=utf8 exclude: entities: - sun.sun
-
mysql安装与初始化
-
服务器端安装
sudo apt-get install mysql-server
-
客户端:
sudo apt-get install libmariadbclient-dev libssl-dev
sudo pip3 install mysqlclient
-
MYSQL中创建数据库、用户、授权SQL命令:
CREATE DATABASE my_homeassistant;
USE mysql;
CREATE user 'pi' IDENTIFIED BY 'hachina1234';
UPDATE user SET plugin='mysql_native_password' WHERE User='pi';
GRANT ALL PRIVILEGES ON my_homeassistant.* TO 'pi';
FLUSH PRIVILEGES;
-
历史数据相关组件