Raspberry PiでRM mini (黒豆) を使う

# ライブラリのインストール

```shell:console
$ sudo apt install libffi-dev libssl-dev openssl
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
openssl はすでに最新バージョン (1.1.1k-1+deb11u1) です。
openssl は手動でインストールしたと設定されました。
提案パッケージ:
  libssl-doc
以下のパッケージが新たにインストールされます:
  libffi-dev libssl-dev
アップグレード: 0 個、新規インストール: 2 個、削除: 0 個、保留: 0 個。
1,637 kB のアーカイブを取得する必要があります。
この操作後に追加で 6,203 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian bullseye/main armhf libffi-dev armhf 3.3-6 [58.2 kB]
取得:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libssl-dev armhf 1.1.1k-1+deb11u1 [1,579 kB]
1,637 kB を 2秒 で取得しました (884 kB/s)
以前に未選択のパッケージ libffi-dev:armhf を選択しています。
(データベースを読み込んでいます ... 現在 106537 個のファイルとディレクトリがインストールされています。)
.../libffi-dev_3.3-6_armhf.deb を展開する準備をしています ...
libffi-dev:armhf (3.3-6) を展開しています...
以前に未選択のパッケージ libssl-dev:armhf を選択しています。
.../libssl-dev_1.1.1k-1+deb11u1_armhf.deb を展開する準備をしています ...
libssl-dev:armhf (1.1.1k-1+deb11u1) を展開しています...
libffi-dev:armhf (3.3-6) を設定しています ...
libssl-dev:armhf (1.1.1k-1+deb11u1) を設定しています ...
man-db (2.9.4-2) のトリガを処理しています ...
install-info (6.7.0.dfsg.2-6) のトリガを処理しています ...
```

# Pythonライブラリのインストール

```shell:console
$ sudo python -m pip install configparser netaddr pycrypto broadlink
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting configparser
  Downloading https://www.piwheels.org/simple/configparser/configparser-5.2.0-py3-none-any.whl (19 kB)
Collecting netaddr
  Downloading https://www.piwheels.org/simple/netaddr/netaddr-0.8.0-py3-none-any.whl (1.9 MB)
     |████████████████████████████████| 1.9 MB 4.1 MB/s
Collecting pycrypto
  Downloading https://www.piwheels.org/simple/pycrypto/pycrypto-2.6.1-cp39-cp39-linux_armv7l.whl (526 kB)
     |████████████████████████████████| 526 kB 3.6 MB/s
Collecting broadlink
  Downloading https://www.piwheels.org/simple/broadlink/broadlink-0.18.0-py3-none-any.whl (20 kB)
Requirement already satisfied: cryptography>=3.2 in /usr/lib/python3/dist-packages (from broadlink) (3.3.2)
Installing collected packages: pycrypto, netaddr, configparser, broadlink
Successfully installed broadlink-0.18.0 configparser-5.2.0 netaddr-0.8.0 pycrypto-2.6.1
```

# BroadLink CLIをインストールする

```shell:console
$ git clone https://github.com/mjg59/python-broadlink.git
Cloning into 'python-broadlink'...
remote: Enumerating objects: 1240, done.
remote: Counting objects: 100% (195/195), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 1240 (delta 124), reused 132 (delta 99), pack-reused 1045
Receiving objects: 100% (1240/1240), 367.75 KiB | 1.73 MiB/s, done.
Resolving deltas: 100% (695/695), done.
```

```shell:console
$ cd python-broadlink/
$ sudo python setup.py install
running install
running bdist_egg
running egg_info
creating broadlink.egg-info
writing broadlink.egg-info/PKG-INFO
writing dependency_links to broadlink.egg-info/dependency_links.txt
writing requirements to broadlink.egg-info/requires.txt
writing top-level names to broadlink.egg-info/top_level.txt
writing manifest file 'broadlink.egg-info/SOURCES.txt'
reading manifest file 'broadlink.egg-info/SOURCES.txt'
writing manifest file 'broadlink.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/broadlink
copying broadlink/exceptions.py -> build/lib/broadlink
copying broadlink/climate.py -> build/lib/broadlink
copying broadlink/light.py -> build/lib/broadlink
copying broadlink/device.py -> build/lib/broadlink
copying broadlink/alarm.py -> build/lib/broadlink
copying broadlink/cover.py -> build/lib/broadlink
copying broadlink/remote.py -> build/lib/broadlink
copying broadlink/const.py -> build/lib/broadlink
copying broadlink/switch.py -> build/lib/broadlink
copying broadlink/helpers.py -> build/lib/broadlink
copying broadlink/sensor.py -> build/lib/broadlink
copying broadlink/protocol.py -> build/lib/broadlink
copying broadlink/__init__.py -> build/lib/broadlink
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/exceptions.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/climate.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/light.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/device.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/alarm.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/cover.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/remote.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/const.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/switch.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/helpers.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/sensor.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/protocol.py -> build/bdist.linux-armv7l/egg/broadlink
copying build/lib/broadlink/__init__.py -> build/bdist.linux-armv7l/egg/broadlink
byte-compiling build/bdist.linux-armv7l/egg/broadlink/exceptions.py to exceptions.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/climate.py to climate.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/light.py to light.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/device.py to device.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/alarm.py to alarm.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/cover.py to cover.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/remote.py to remote.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/const.py to const.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/switch.py to switch.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/helpers.py to helpers.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/sensor.py to sensor.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/protocol.py to protocol.cpython-39.pyc
byte-compiling build/bdist.linux-armv7l/egg/broadlink/__init__.py to __init__.cpython-39.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/not-zip-safe -> build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/requires.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying broadlink.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
creating dist
creating 'dist/broadlink-0.18.0-py3.9.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing broadlink-0.18.0-py3.9.egg
creating /usr/local/lib/python3.9/dist-packages/broadlink-0.18.0-py3.9.egg
Extracting broadlink-0.18.0-py3.9.egg to /usr/local/lib/python3.9/dist-packages
Adding broadlink 0.18.0 to easy-install.pth file

Installed /usr/local/lib/python3.9/dist-packages/broadlink-0.18.0-py3.9.egg
Processing dependencies for broadlink==0.18.0
Searching for cryptography==3.3.2
Best match: cryptography 3.3.2
Adding cryptography 3.3.2 to easy-install.pth file

Using /usr/lib/python3/dist-packages
Finished processing dependencies for broadlink==0.18.0
```

# 動作確認(探してみる)

```shell:console
$ cd cli/
$ ./broadlink_discovery
Discovering...
###########################################
RMMINI
# broadlink_cli --type 0x0000 --host 000.000.000.000 --mac 000000000000
Device file data (to be used with --device @filename in broadlink_cli) :
0x0000 000.000.000.000 000000000000
```