このプロジェクトは、Nature Remoデバイスを使用して家電製品を自動制御するPythonプログラムです。 AIアシスタント(Claude)によって作成されています。
- Nature RemoのクラウドAPIおよびローカルAPIを利用したデバイス制御
- エアコンや照明などの家電製品の制御
- スケジュールベースの自動制御
- センサーデータに基づく自動制御(温度、湿度)
- 詳細なログ記録
- Python 3.7以上
- Pipenv(パッケージ管理用)
- Nature Remoデバイス
- Nature Remo APIトークン
- リポジトリのクローン
git clone [リポジトリURL]
cd natureRemo
- Python環境のセットアップ
pipenv install -r requirements.txt
pipenv shell
- 設定ファイルの作成
cp config.json.template config.json
config.json
の編集
- APIトークンの設定
- デバイスIDの設定
- スケジュールの設定
- 自動化ルールの設定
設定例:
{
"api": {
"token": "your_api_token_here",
"base_url": "https://api.nature.global/1/",
"local_url": "http://[Nature Remo IP]/messages"
},
"devices": {
"aircon": {
"id": "your_aircon_device_id",
"settings": {
"mode": "cool",
"temp": "26",
"fan": "auto"
}
}
}
}
- プログラムの実行
python natureRemo.py
- 動作確認
- ログファイル(natureRemo.log)で動作状況を確認
- 設定したスケジュールやセンサールールが正常に動作することを確認
テストの実行:
pytest tests/
カバレッジレポートの生成:
pytest --cov=natureRemo tests/
natureRemo/
├── natureRemo.py # メインプログラム
├── config.json # 設定ファイル
├── requirements.txt # 依存パッケージ
├── tests/ # テストファイル
│ └── test_natureRemo.py
└── logs/ # ログファイル
時間指定で家電を制御できます。設定例:
"schedule": [
{
"time": "07:00",
"action": "turn_on_light",
"device": "light",
"params": {}
}
]
温度や湿度に基づいて自動制御を行います。設定例:
"automation": {
"temperature": {
"high_threshold": 28,
"action_high": {
"device": "aircon",
"action": "set_aircon",
"params": {
"mode": "cool",
"temp": "26"
}
}
}
}
- ネットワークエラー時は自動的にリトライ
- APIエラー時はログに詳細を記録
- 設定ファイルの不備は起動時にチェック
- このプロジェクトはAI(Claude)によって生成されています
- 実運用前に十分なテストを行ってください
- APIトークンは安全に管理してください
MIT License