0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenWrt ホームアシスタント 23.05~

0
Last updated at Posted at 2024-02-08

:flag_jp: Japanese notation

OpenWrt_icon.png

はじめに

記事について

OpenWrt初期設定・運用ガイドです
インストールから各種設定、チューニングなどをまとめています

初心者対応構成

前提条件

  • 要件:
  • 構成状態 : 初期値前提
  • 動作確認 : 23.05.2@ BPI-R3 / 23.05.5@NCP^HG100

ホームアシスタント

インストール

wget https://raw.githubusercontent.com/openlumi/homeassistant_on_openwrt/23.05/ha_install.sh -O - | sh
# reboot
# /etc/init.d/homeassistant restart
  • インストール時間
    BPR-R3:約三分
    NCP-HG100:数十分
  • Webインターフェース
    192.168.1.1:8123

Nature Remo のホーム アシスタントの統合

Nature Remoのサポート
HomeAssistantのご紹介とコマンド調教劇
OpenWrt上のContainer版HomeAssistantへのHACSのインストール
HACS

  • HACS(Home Assistant Community Store)
opkg update
# opkg remove uclient-fetch
# opkg install wget-nossl
# opkg install wget-ssl
opkg install bash
# reboot
# /etc/init.d/homeassistant restart
#sudo -u hass bash
wget -O - https://get.hacs.xyz | bash -
# reboot
# /etc/init.d/homeassistant restart
#! /bin/sh
YOUR_ACCESS_TOKEN='token' # サインインで取得したトークン
/etc/init.d/homeassistant stop
cat <<"EOF" >> /etc/homeassistant/configuration.yaml
nature_remo:
  access_token:  YOUR_ACCESS_TOKEN
EOF
cat <<"EOF" >> /etc/homeassistant/secrets.yaml
nature_remo_token:  YOUR_ACCESS_TOKEN
EOF
sed -i -e "s/YOUR_ACCESS_TOKEN/${YOUR_ACCESS_TOKEN}/g" /etc/homeassistant/configuration.yaml
sed -i -e "s/YOUR_ACCESS_TOKEN/${YOUR_ACCESS_TOKEN}/g" /etc/homeassistant/secrets.yaml
mkdir -p /etc/homeassistant/custom_components/nature_remo
wget --no-check-certificate -O /etc/homeassistant/custom_components/nature_remo/__init__.py https://raw.githubusercontent.com/calee0219/hass-nature-remo/main/__init__.py
wget --no-check-certificate -O /etc/homeassistant/custom_components/nature_remo/climate.py https://raw.githubusercontent.com/calee0219/hass-nature-remo/main/climate.py
wget --no-check-certificate -O /etc/homeassistant/custom_components/nature_remo/manifest.json https://raw.githubusercontent.com/calee0219/hass-nature-remo/main/manifest.json
wget --no-check-certificate -O /etc/homeassistant/custom_components/nature_remo/sensor.py https://raw.githubusercontent.com/calee0219/hass-nature-remo/main/sensor.py
wget --no-check-certificate -O /etc/homeassistant/custom_components/nature_remo/switch.py https://raw.githubusercontent.com/calee0219/hass-nature-remo/main/switch.py
/etc/init.d/homeassistant start

スクリーンショット 2024-12-24 105852.jpg

既知の問題

Nature Remo 2 の接続が切断される問題

ネットワーク変更時の自動Wi-Fiリロードを明示的に禁止する

  • 対策
uci set network.globals.reload_wifi='0'
uci commit network
# reboot

リムーブ

# Deleting the home assistant in this way
/etc/init.d/homeassistant stop
pip3 uninstall homeassistant
rm -R /etc/homeassistant
rm -R /usr/lib/python*/site-packages/hass_frontend
rm -R /usr/lib/python*/site-packages/hass_nabucasa-*
rm -R /usr/lib/python*/site-packages/home_assistant_frontend-*
rm -R /etc/homeassistant
rm /etc/init.d/homeassistant
#reboot

OpenWrt ルーターをホーム アシスタントに統合

opkg update
opkg install luci-mod-rpc
#! /bin/sh
ROUTER_IP_ADDRESS='192.168.1.1'
YOUR_ADMIN_PASSWORD='password' # rootのパスワードを入力
# Example configuration.yaml entry
cat <<"EOF" >> /etc/homeassistant/configuration.yaml
device_tracker:
  - platform: luci
    host: ROUTER_IP_ADDRESS
    username:  root
    password:  YOUR_ADMIN_PASSWORD
EOF
sed -i -e "s/ROUTER_IP_ADDRESS/${ROUTER_IP_ADDRESS}/g" /etc/homeassistant/configuration.yaml
sed -i -e "s/YOUR_ADMIN_PASSWORD/${YOUR_ADMIN_PASSWORD}/g" /etc/homeassistant/configuration.yaml

ACL

  • ユーザーhass作成
    ※hassパスワードは任意
HASS_PASSWD='openwrt'
opkg update
opkg install shadow
opkg install sudo
opkg install acl
opkg install luci-i18n-acl-ja
opkg install bash
useradd -m -d /home/hass -s /bin/ash -U hass
# passwd hass
#! /bin/sh
# Device Password
ubus call luci setPassword '{ "username": "hass", "password": "${HASS_PASSWD}" }'
sed -i -e "# %sudo ALL=(ALL:ALL) ALL/%sudo ALL=(ALL) ALL/g" /etc/sudoers 
groupadd --system sudo
usermod -a -G sudo hass
uci set rpcd.@login[1].username='hass'
uci set rpcd.@login[1].timeout='300'
uci set rpcd.@login[1].read='*'
uci set rpcd.@login[1].write='*'
uci set rpcd.@login[1].password='$p$root'
uci commit rpcd
# reboot

あとがき

インストール自体は、有志のおかげもあり、簡単
しかし、その後の設定が四苦八苦

参考資料(感謝:relaxed:

Home Assistant 2023.3.6 と OpenWRT 22.03.3 - またはその他の低予算ソリューション

OpenWrt 19.07 でマルチユーザー環境を構築

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?