hlcX's Blog
my note!
Toggle navigation
hlcX's Blog
2.学习
4.群晖
5.CentOS7
6.rasperryPI
linux-mint
关于
归档
标签
树莓系统的HASS时不时的就会坏,总是要重装,所以记录一下
重装
树莓
HASS
2022-10-16 14:52:54
16
0
1
hlcx
重装
树莓
HASS
# 一、选刷树莓系统 - [点击进入官网 https://www.raspberrypi.com/software/](https://www.raspberrypi.com/software/) - 下载安装工具 - 使用安装工具是注意:先设置SSH登录密码 ![title](/api/file/getImage?fileId=634babe33c9b99002e00000a) # 二、安装docker ``` sudo curl -sSL https://get.docker.com | sh ``` # 三、安装 Docker 图形化界面 portainer ``` #下载 Docker 图形化界面 portainer sudo docker pull portainer/portainer #创建 portainer 容器 sudo docker volume create portainer_data #运行 portainer sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer ``` # 四、安装 filebrowser 文件管理工具 - 用于访问HASS及nginx的挂载盘或文件 ``` sudo docker run --name=filebrowser \ -v /docker/fb:/srv \ #fb自己的主目录 -v /docker/hass:/srv/hass \ #HASS的config目录 -v /docker/nginx:/srv/nginx \ #nginx的conf文件有在目录 -v /docker/ssl:/srv/ssl \ #证书目录及nginx的html目录 -p 8394:80 \ --privileged --restart unless-stopped \ filebrowser/filebrowser ``` # 五、安装 nginx ## 1、安装 ``` docker run -it -d --name nginx --privileged --net=host -v /docker/ssl:/usr/share/nginx/html/ \ #挂载html空间 -v /docker/nginx/nginx.conf:/etc/nginx/nginx.conf \ #挂载nginx.conf文件 nginx ``` ## 2、nginx.conf(我的配置文件) ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server { listen 443 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/share/nginx/html; index index.html index.htm; } } server { listen 8384 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; charset UTF-8; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; location / { proxy_http_version 1.1; proxy_pass http://127.0.0.1:8394; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } server { listen 44490 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; charset UTF-8; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; location / { proxy_http_version 1.1; proxy_pass http://192.168.2.9:44490; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } server { listen 8124 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; charset UTF-8; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; location / { proxy_http_version 1.1; proxy_pass http://192.168.2.122:8123; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } server { listen 8999 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; charset UTF-8; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; location / { proxy_http_version 1.1; proxy_pass http://192.168.2.122:80; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } server { listen 18181 ssl; server_name 13ua.com; ssl on; ssl_certificate /usr/share/nginx/html/13.crt; ssl_certificate_key /usr/share/nginx/html/13.key; charset UTF-8; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; location / { proxy_http_version 1.1; proxy_pass http://192.168.2.1:80; proxy_set_header Host $host:$server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } } ``` ## 3、从阿里云下载免费证书,放到SSL目录中(略) # 六、安装 homeassistant ## 1、安装 ``` docker run -it -d --name homeassistant \ --privileged --net=host \ -v /docker/hass:/config \ #挂载config目录 homeassistant/home-assistant ``` ## 2、configuration.yaml(我的配置文件) ``` # Loads default set of integrations. Do not remove. default_config: # Text to speech tts: - platform: edge_tts language: zh-CN # Default language or voice (Optional) sonoff: username: '+8618017300756' password: '*********' scan_interval: 60 grace_period: 600 api_region: 'cn' entity_prefix: True debug: False automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml ``` # 七、安装 MQTT ## 1、安装 ``` apt-get update apt-get install mosquitto apt-get install mosquitto mosquitto-clients ``` ## 2、修改配置文件 /etc/mosquitto/mosquitto.conf 完成安装 ``` log_type error log_type warning log_type notice log_type information connection_messages true log_timestamp true #以上几句插入,以下这句是锚点 include_dir /etc/mosquitto/conf.d ``` # 八、安装 Edge TTS 插件 - [去原地址下载最新版本 https://github.com/hasscc/hass-edge-tts](https://github.com/hasscc/hass-edge-tts) - 下载并复制 edge_tts 目录放置 custom_components 目录中 # 九、安装 sonoff 插件 - [去原地址下载最新版本 https://github.com/AlexxIT/SonoffLAN](https://github.com/AlexxIT/SonoffLAN) - 下载并复制 sonoff 目录放置 custom_components 目录中 # 十、我自己的HASS自动化脚本 - 煮蛋器的定时器+16A插座定时器 (automations.yaml) ``` - id: '1665832136362' alias: 煮蛋器使用 description: '' trigger: - platform: state entity_id: - switch.sonoff_1000a7942d from: 'off' to: 'on' condition: [] action: - service: tts.edge_tts_say data: entity_id: media_player.qi_ju_shi message: 煮蛋器已开启,将在13分钟后关闭! - delay: hours: 0 minutes: 13 seconds: 0 milliseconds: 0 - service: switch.turn_off data: {} target: entity_id: switch.sonoff_1000a7942d - service: tts.edge_tts_say data: entity_id: media_player.qi_ju_shi message: 鸡蛋煮好啦~小心烫手啊!鸡蛋煮好啦~小心烫手啊! mode: single - id: '1665832449373' alias: MINI开始充电 description: '' trigger: - platform: mqtt topic: onoffphone payload: b20 condition: [] action: - service: switch.turn_on data: {} target: entity_id: switch.sonoff_10012799a0 mode: single - id: '1665832672491' alias: MINI停止充电 description: '' trigger: - platform: mqtt topic: onoffphone payload: overb20 condition: [] action: - service: switch.turn_off data: {} target: entity_id: switch.sonoff_10012799a0 mode: single ``` - 晚安和准备睡觉的场景 (scenes.yaml) ``` - id: '1665879595560' name: 晚安 entities: switch.sonoff_1000c25e4a: icon: mdi:ceiling-light-multiple friendly_name: 客厅灯1号 state: 'off' switch.sonoff_1000d70c8a: friendly_name: 客厅灯2号 state: 'off' switch.sonoff_1000d70ec9: friendly_name: 门厅灯 state: 'off' switch.sonoff_1000d71ba7: friendly_name: 好好的灯 state: 'off' switch.sonoff_1000d701ce: friendly_name: 阳台灯 state: 'off' switch.sonoff_1000d7224c: friendly_name: 主卧顶灯 state: 'off' switch.sonoff_1000d71bb8: friendly_name: 厨房筒灯 state: 'off' switch.sonoff_1000d70847: friendly_name: 厨房顶灯 state: 'off' switch.sonoff_1000d701bc: friendly_name: 镜前灯 state: 'off' switch.sonoff_1000d72248: friendly_name: 卫生间顶 state: 'off' metadata: {} - id: '1665879822736' name: 准备睡觉 entities: switch.sonoff_1000c25e4a: icon: mdi:ceiling-light-multiple friendly_name: 客厅灯1号 state: 'off' switch.sonoff_1000d70c8a: friendly_name: 客厅灯2号 state: 'off' switch.sonoff_1000d70ec9: friendly_name: 门厅灯 state: 'on' switch.sonoff_1000d71ba7: friendly_name: 好好的灯 state: 'off' switch.sonoff_1000d701ce: friendly_name: 阳台灯 state: 'off' switch.sonoff_1000d7224c: friendly_name: 主卧顶灯 state: 'on' switch.sonoff_1000d71bb8: friendly_name: 厨房筒灯 state: 'off' switch.sonoff_1000d70847: friendly_name: 厨房顶灯 state: 'off' switch.sonoff_1000d701bc: friendly_name: 镜前灯 state: 'off' switch.sonoff_1000d72248: friendly_name: 卫生间顶 state: 'on' metadata: {} ``` # 十一、homeassistant的仪表盘设置 - 点击右上角的【原始配置编辑器】如下图 ![title](/api/file/getImage?fileId=634bb4fa3c9b99002e00000b) - 复制如下内容 ``` title: '1606' views: - path: default_view title: Home cards: - type: entities entities: - entity: switch.sonoff_1000c25e4a icon: mdi:ceiling-light-multiple - entity: switch.sonoff_1000d70c8a icon: mdi:ceiling-light-multiple - entity: switch.sonoff_1000a6fa90 icon: mdi:ceiling-fan - entity: switch.sonoff_1000d70ec9 icon: mdi:light-recessed show_header_toggle: false state_color: true - type: entities entities: - entity: switch.sonoff_1000d70847 icon: mdi:light-recessed - entity: switch.sonoff_1000d71bb8 icon: mdi:track-light - entity: switch.sonoff_1000a7942d show_header_toggle: false state_color: true - type: entities entities: - entity: switch.sonoff_1000d7224c icon: mdi:spotlight show_header_toggle: false state_color: true - type: entities entities: - entity: switch.sonoff_1000d71ba7 icon: mdi:light-recessed - entity: switch.sonoff_1000d701ce icon: mdi:lightbulb-fluorescent-tube show_header_toggle: false state_color: true - type: entities entities: - entity: switch.sonoff_1000d72248 icon: mdi:globe-light - entity: switch.sonoff_1000d701bc icon: mdi:lightbulb-cfl - entity: switch.sonoff_1000d70c3b icon: mdi:fan show_header_toggle: false state_color: true - theme: Backend-selected title: 大图标 path: '' badges: [] cards: - square: true columns: 3 type: grid cards: - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000c25e4a image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d70c8a image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000a6fa90 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d71ba7 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d701ce image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d7224c image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d71bb8 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d70847 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000a7942d image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d72248 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d701bc image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d70c3b image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: true show_name: true camera_view: auto type: picture-entity entity: switch.sonoff_1000d70ec9 image: https://13ua.com:8999/1606/灯泡.png tap_action: action: toggle aspect_ratio: '1:1' - show_state: false show_name: false camera_view: auto type: picture-entity entity: scene.wan_an image: https://13ua.com:8999/1606/睡觉.png tap_action: action: toggle - show_state: false show_name: false camera_view: auto type: picture-entity entity: scene.zhun_bei_shui_jue image: https://13ua.com:8999/1606/沙发.png tap_action: action: toggle ``` # 十二、完 - 至此基本就完成了,重装至可用状态了。辛苦了。
上一篇:
第三方套件
下一篇:
用VBS脚本来实现WIN系统中的各种命令调用
0
赞
16 人读过
新浪微博
微信
腾讯微博
QQ空间
人人网
提交评论
立即登录
, 发表评论.
没有帐号?
立即注册
1
条评论
More...
文档导航
没有帐号? 立即注册