sugimisu が 2021年05月16日23時58分33秒 に編集
初版
タイトルの変更
玄関のポーチ灯をswitchbotとobnizのボタンをIFTTTで簡単連携してつけてみる
タグの変更
obnizBoard1Y
obnizIoTコンテスト
スマートホーム
メイン画像の変更
記事種類の変更
セットアップや使用方法
本文の変更
# 概要 玄関のライトをSwitchBotボットとobniz Board 1Yを繋げてオンオフできるようにする # 用意するもの obniz Board 1Y [IFTTT](https://ifttt.com/home)アカウント [SwitchBotボット](https://www.switchbot.jp/bot) # IFTTTの設定  SwitchBotの設定を済ませておきます。今回はスイッチモードでONとOFF二種類のwebhookを用意します。  webhooksを探して選択する thenの方はswitchbotを選択してアカウント連携して利用するswitchbotの名前を選択   WEBHOOKSのテスト画面から、実行するとうまく行きました。簡単〜。 # ソース ```ボタンを右に押すとON 左に押すとOFF const KEY = 'your-apikey'; const EVENT1 = 'turn_on'; const EVENT2 = 'turn_off'; obniz.switch.onchange = function(state) { if(state == "right"){ try { fetch(`https://maker.ifttt.com/trigger/${EVENT1}/with/key/${KEY}`); } catch(e) { console.error(e); } }else if(state == "left"){ try { fetch(`https://maker.ifttt.com/trigger/${EVENT1}/with/key/${KEY}`); } catch(e) { console.error(e); } } ``` # 動画 本当はスイッチに貼り付けたかったけど不器用すぎてちゃんと貼り付けれなかったw スイッチがオンにはなるけどオフにならないw