目覚まし時計が鳴るのと同時にSwitchBotでカーテンを開ける方法を紹介します。
![<strong>タイマニ</strong>](https://taimanix.com/wp-content/uploads/2021/12/cropped-サイトアイコン-150x150.jpg)
目覚まし時計と太陽光でバッチリ目が覚めます!
1.用意するもの
1.MacroDroid
「○○したら、□□する。」という一連の流れを自動で実行してくれるアプリです。
今回は「目覚まし時計が鳴る→カーテンを開ける。」という動作をこのアプリで行います。
![](https://taimanix.com/wp-content/uploads/2023/01/image-2.png)
2.AMdroidスマートアラーム時計
MacroDroidと連携可能な目覚まし時計アプリです。
![](https://taimanix.com/wp-content/uploads/2023/01/image-1.png)
3.IFTTT
MacroDroidと同じように、「○○したら、□□する。」という一連の流れを自動で実行してくれるアプリです。
SwitchBot カーテンと連携することが可能です。
![](https://taimanix.com/wp-content/uploads/2023/01/image-4.png)
4.SwitchBot カーテン
カーテンレールに取り付けることで、カーテンを開け閉めしてくれます。
![](https://taimanix.com/wp-content/uploads/2023/01/image-6.png)
5.SwitchBot ハブミニ
SwitchBot カーテンをオンラインで操作できるようになります。
※Wi-Fi環境が必須です。
※ハブミニの初期設定は本記事では紹介していませんので各自で初期設定を済ませておいてください!
![](https://taimanix.com/wp-content/uploads/2023/03/switchbothabumini-switchbot-1ge-591990.webp)
![<strong>タイマニ</strong>](https://taimanix.com/wp-content/uploads/2021/12/cropped-サイトアイコン-150x150.jpg)
自動でカーテンが開く仕組みはこんな感じです。
![](https://taimanix.com/wp-content/uploads/2023/03/スライド2.jpg)
2.設定方法
(1)SwitchBot カーテンの設定
SwitchBotのアプリからシーンを作成します。
※我が家では操作するカーテンが2つあるので、2つ同時にカーテンを開ける設定をします。
![](https://taimanix.com/wp-content/uploads/2023/01/001.png)
![](https://taimanix.com/wp-content/uploads/2023/01/002.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/003.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/004.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/005.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/006.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/007-1.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/008.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/009.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/010.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/011.jpg)
(2)AMdroidスマートアラーム時計の設定
次にAMdroidでアラームを作成します。
![](https://taimanix.com/wp-content/uploads/2023/01/012.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/013.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/014.jpg)
(3)IFTTTの設定
次にIFTTTを使い「Webhooks」と「SwitchBotカーテン」を連動させます。
![<strong>タイマニ</strong>](https://taimanix.com/wp-content/uploads/2021/12/cropped-サイトアイコン-150x150.jpg)
「Webhooks?」と思われた方もいると思いますが、気にせず先に進んでください。
![](https://taimanix.com/wp-content/uploads/2023/01/015.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/016.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/017.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/018.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/019.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/020.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/021.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/022.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/023.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/024.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/025.jpg)
ここで設定した内容をしっかり動作させるために、次の確認を行います。
![](https://taimanix.com/wp-content/uploads/2023/01/026.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/027.jpg)
![](https://taimanix.com/wp-content/uploads/2023/01/028.jpg)
Documentationをタップすると次のような画面が表示されます。
![](https://taimanix.com/wp-content/uploads/2023/01/029.jpg)
この画面を下にスクロールしていきます。
黒塗りの箇所は各ユーザーに割り当てられている文字列です。
![](https://taimanix.com/wp-content/uploads/2023/01/030.jpg)
スクロールしていくと「To trigger an Event with 3 JSON values」の画面が表示されるので、赤枠のURLをコピーします。
https://maker.ifttt.com/trigger/{event}/with/key/{黒塗り部分}
上のURLの{event}部分に先ほどIFTTTで設定したEVENT NAMEを入力します。
このURLは後で使用するのでコピーしておいてください。
今回の例では次のようなURLになります。
https://maker.ifttt.com/trigger/curtain-open/with/key/{黒塗り部分}
(2)MacroDroidの設定
「目覚ましが鳴ったら」→「カーテンを開ける」を実行するための設定をしていきます。
①トリガーの設定
MacroDroidを使ってマクロを作っていきます。
まずは「アラームが鳴ったら、、、」というトリガーを作っていきます。
![](https://taimanix.com/wp-content/uploads/2023/03/031.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/032.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/033.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/034.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/035.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/036-1.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/037-1.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/038.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/039.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/040.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/041.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/042.jpg)
![<strong>タイマニ</strong>](https://taimanix.com/wp-content/uploads/2021/12/cropped-サイトアイコン-150x150.jpg)
トリガーを作動させる時間帯を朝4時~昼12時までに限定しました。
夕方や夜の時間帯にアラームをかけて少しだけ眠ることも多々ありますので、そのような場合でもカーテンが開いてしまうと面倒ですので、作動する時間帯は限定したほうが良いですね。
②アクションの設定
トリガーの次は、「カーテンを開ける」というアクションを作っていきます。
![](https://taimanix.com/wp-content/uploads/2023/03/043.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/044.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/045.jpg)
③条件の設定
![<strong>タイマニ</strong>](https://taimanix.com/wp-content/uploads/2021/12/cropped-サイトアイコン-150x150.jpg)
「アラームが鳴ったら」→「カーテンを開ける」が完成しました。
しかし、まだ完成ではありません。
現状ですと、在宅時も外出時も関係なく、アラームが鳴ったらカーテンが開いてしまいます。
なので、「在宅時のみ、カーテンを開ける。」という条件を追加します。
※外出時もカーテンが開いても問題ないという方は、この工程は無視してかましません。
在宅しているかどうかを判別するためには、別のマクロを追加で作成する必要があります。
マクロの作成方法は、下の記事で紹介しているので参考にしてください。
![](https://taimanix.com/wp-content/uploads/2023/06/macrodroid-variable-home-ic.png)
条件の設定方法は次のとおりです。
![](https://taimanix.com/wp-content/uploads/2023/03/046-2.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/047.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/048-2.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/049.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/050-1.jpg)
以上で、目覚まし時計とSwitchBot カーテンが連動するようになり、アラームが鳴ればカーテンが開くようになります。
おまけ
私の場合、アラームが鳴る10分前にカーテンが開くように設定しています。
AMdroidスマートアラーム時計の設定を変えるだけで、特に難しくないので紹介します。
AMdroidスマートアラーム時計の設定画面に移動し、使用しているプロフィール設定に移動します。
![](https://taimanix.com/wp-content/uploads/2023/03/052.jpg)
![](https://taimanix.com/wp-content/uploads/2023/03/053.jpg)
通常の設定だと「事前アラームなし」で設定されていますので、「事前アラームあり」に設定します。
何分前(下の画像では10分前)に事前アラームを鳴らすかを設定し、事前アラームのボリュームをゼロにすれば、設定完了です。
![](https://taimanix.com/wp-content/uploads/2023/03/054.jpg)
この設定により、アラームが鳴る10分前にカーテンが開くようになります。