1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

switchbotをRaspberry Piで動作させる。

Last updated at Posted at 2021-04-26

1. この記事は

SwitchbotをRaspberry piで動作させる方法をメモします。

Switchbotは下記サイトに説明があります。リモートで物理的にボタンを押すことができます。
https://www.amazon.co.jp/dp/B07B7NXV4R?ref=ppx_pop_mob_ap_share

image.png

2. 方法

(注)下記に説明する方法は、Raspberry Pi4では動作しないようです。Raspberry Pi3であればOKでした。

2-1 (準備)Raspberry Pi3に関連モジュールをインストールします。

製造メーカーが作成したサイト

下記のコマンドを実行してください。

example
sudo apt-get update
sudo apt-get install python-pexpect
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev 
sudo apt-get install libudev-dev libical-dev libreadline-dev
sudo pip install bluepy
git clone https://github.com/OpenWonderLabs/python-host.git
cd python-host

2-2 Switchbot本体のMACアドレスを調べる

スマホに下記のアプリをインストールする。
https://play.google.com/store/apps/details?id=com.theswitchbot.switchbot&hl=ja

下記図のとおり操作するとSwitchbot本体のMACアドレスが分かる。
image.png

2-3 Raspberry Pi本体とSwitchbotをbluetooth接続する。

346.jpg

2-4 Raspberry Pi3からSwitchbotに信号を送る

Raspberry Piからコマンドを送り以下のとおり「Complete」となればOK

example
pi@raspberrypi:~ $ cd python-host
pi@raspberrypi:~/python-host $ sudo python switchbot.py
Usage: "sudo python switchbot.py [mac dev_type cmd]" or "sudo python switchbot.py"
Scanning...
Scan timeout.
(' 0', [u'd1:xx:xx:xx:xx:xx', 'Bot', 'Press'])
Input the device number to control:0
[u'd1:xx:xx:xx:xx:xx', 'Bot', 'Press']
Preparing to connect.
Connection successful.
Complete

'd1:xx:xx:xx:xx:xx'はSwitchbot本体のMACアドレスを示します。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?