Skip to content

mski-iksm/home_controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Home Controller

Nature Remo を使って家電を制御するコマンドラインツールです。

ビルド / インストール

ローカルにビルドする

カレントディレクトリに home_controller という実行ファイルを生成します。

go build -o home_controller .

コマンドとしてインストールする(Mac 全体で使えるようにする)

~/go/binhome_controller をインストールします。

go install .

~/go/bin に PATH が通っていない場合は、~/.zshrc に追記して反映します。

echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

以降は home_controller としてどこからでも実行できます。コードを変更したら go install . を再実行して更新します。

モード

  • temp_control: 室温が規定の範囲内になるようにエアコンの設定温度を自動変更する
  • notify_temp: 室温がしきい値を大きく外れたときに ntfy へ通知する

使い方

事前準備

  1. Nature Remo を設置し、各家電のリモコンを設定します。
  2. Nature Remo の API キーを取得します。
  3. API キーを環境変数に設定します。
export NATURE_API_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

temp_control モード

室温と現在のエアコン設定を見て、設定温度を自動調整します。設定を変更したときは Slack に結果を通知し、しきい値を大きく外れた場合は補助的に ntfy に緊急通知します。

インストール済みのコマンドで実行する場合:

home_controller \
  -nature_api_secret="${NATURE_API_SECRET}" \
  -action_mode="temp_control" \
  -device_name="Remo" \
  -tooHotThreshold=27.5 \
  -tooColdThreshold=24.5 \
  -preparationThreshold=0.5 \
  -minimumTemperatureSetting=22.0 \
  -maximumTemperatureSetting=30.0 \
  -slackToken="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -slackChannel="#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -ntfyUrl="https://ntfy.sh/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

インストールせずにその場で実行する場合は、home_controllergo run main.go に置き換えます。

notify_temp モード

エアコンが ON のときだけ、temp_control と同じ基準で、しきい値を大きく外れた室温を ntfy に通知します。

home_controller \
  -nature_api_secret="${NATURE_API_SECRET}" \
  -action_mode="notify_temp" \
  -device_name="Remo" \
  -tooHotThreshold=27.5 \
  -tooColdThreshold=24.5 \
  -ntfyUrl="https://ntfy.sh/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors