0
1

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~ ホームアシスタント

Last updated at Posted at 2024-02-08

:warning:Japanese notation
OpenWrt_icon.png

検証中

はじめに

初心者対応構成

デバイスアクセス

PowerShellの開始

  • キー入力:Win+x > a > はい

UCI(SSH)アクセス

powershell:初期設定用
ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-rsa root@192.168.1.1
  • root@192.168.1.1's password:初期値:パスワード無し
OpenSSHのインストールが無い場合:exclamation:
  • 機能の確認
    ※Windows 10 Fall Creators Update(1709)以降標準搭載
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
  • 機能のインストール
powershell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

前提条件

  • 要件:
  • 構成状態 : 初期値前提
  • 動作確認 : 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

リムーブ

# 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
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?