総当たりで赤外線リモコンの隠しコマンドを探す
隠しコマンド
リモコンで操作できる家電の多くには隠しコマンドがあります。隠しているつもりではないのかもしれませんが、多くの機能が実装はしているけどリモコンのボタンには無い状態になっています。
今使っているシーリングライトのリモコンは電源ボタンを押すと点灯→常夜灯→オフをループする、つまり冪等性がありません。そのため、IoTで自動化するには現在の状態を保持する必要があり多少めんどくさいです。
そこで、オンするコマンド、オフにするコマンドを探そうというわけです。
隠しコマンドを探す方法は単純に総当たりです。赤外線リモコンでもっとも普及しているNECフォーマットのコマンドは8bit、つまり256通りしか無いので総当たりが十分現実的なのです。
総当たり装置
Arduinoで総当たりするプログラムを作りました。
進む、戻る、送信、送信して進む、の4つボタンを使って総当たりして変化がないか確認します。
ボードはラズピコを使いましたが、IRremoteが対応していればなんでもいいはずです。
当然ですが、オフにするコマンドはオフの状態では反応がないように見えるので、状態を変えながら繰り返し総当たりをします。
アドレスは事前に調べておいてください。
https://moris.day/blog/post/ir-remote/#受信
コード
#include <IRremote.hpp>
#define ADDRESS 0x6D82
#define IR_LED_PIN 0
#define BACK_BUTTON_PIN 2
#define NEXT_BUTTON_PIN 3
#define SEND_BUTTON_PIN 4
#define SEND_AND_NEXT 5
# Connection
# GPIO ---- Switch ---- GND
static uint8_t command = 0;
void next() {
command++;
Serial.printf("Set: %#x\n", command);
}
void back() {
command--;
Serial.printf("Set: %#x\n", command);
}
void send_command() {
IrSender.sendNEC(ADDRESS, command, 1);
Serial.printf("Send: %#x\n", command);
}
void send_and_next() {
IrSender.sendNEC(ADDRESS, command, 1);
Serial.printf("Send: %#x\n", command);
command++;
Serial.printf("Set: %#x\n", command);
}
void setup() {
IrSender.begin(IR_LED_PIN, DISABLE_LED_FEEDBACK, 25);
Serial.begin();
pinMode(SEND_BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(SEND_BUTTON_PIN), send_command, FALLING);
pinMode(BACK_BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BACK_BUTTON_PIN), next, FALLING);
pinMode(NEXT_BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(NEXT_BUTTON_PIN), back, FALLING);
pinMode(SEND_AND_NEXT, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(SEND_AND_NEXT), send_and_next, FALLING);
}
void loop() {}
結果
リモコンにボタンのあるコマンド
0xBF 電源 点灯→常夜灯→オフをループ
0xBA 明るく
0xBB 暗く
0xA7 白色
0xA8 暖色
0xAF スリープタイマー
0xA6 全灯 中間色
Onkyo 0x1971 留守番モード
リモコンにボタンのないコマンド
0xA2 点灯モード 中間の明るさ、中間色
0xAB オンオフ切り替え
0xAC 全灯 最も寒色
0xAD 全灯 中間色 全灯ボタン0xA6と同じ?
0xAE 全灯 最も暖色
0xBC 常夜灯
0xBD 点灯モード 明るさ、色は以前の状態を保持
0xBE オフ
0xE3 常夜灯
0xE5 点灯モード 0xBDと同じ?
個人的なメモ
サーキュレーター
電源
Protocol=NEC Address=0xD001 Command=0x8C Raw-Data=0x738CD001 32 bits LSB first Gap=3276750us Duration=63750us
横首振り
Protocol=NEC Address=0xD001 Command=0x8F Raw-Data=0x708FD001 32 bits LSB first Gap=3276750us Duration=63650us
タイマー
Protocol=NEC Address=0xD001 Command=0x87 Raw-Data=0x7887D001 32 bits LSB first Gap=3276750us Duration=63650us
風量
Protocol=NEC Address=0xD001 Command=0x88 Raw-Data=0x7788D001 32 bits LSB first Gap=3276750us Duration=63650us
縦首振り
Protocol=NEC Address=0xD001 Command=0x96 Raw-Data=0x6996D001 32 bits LSB first Gap=3276750us Duration=63650us
リズム
Protocol=NEC Address=0xD001 Command=0x86 Raw-Data=0x7986D001 32 bits LSB first Gap=3276750us Duration=63700us
シーリングライト
電源
Protocol=NEC Address=0x6D82 Command=0xBF Raw-Data=0x40BF6D82 32 bits LSB first Gap=1702600us Duration=67350us
明るく
Protocol=NEC Address=0x6D82 Command=0xBA Raw-Data=0x45BA6D82 32 bits LSB first Gap=3276750us Duration=67400us
暗く
Protocol=NEC Address=0x6D82 Command=0xBB Raw-Data=0x44BB6D82 32 bits LSB first Gap=3276750us Duration=67350us
白色
Protocol=NEC Address=0x6D82 Command=0xA7 Raw-Data=0x58A76D82 32 bits LSB first Gap=3276750us Duration=67400us
暖色
Protocol=NEC Address=0x6D82 Command=0xA8 Raw-Data=0x57A86D82 32 bits LSB first Gap=3276750us Duration=67350us
スリープタイマー
Protocol=NEC Address=0x6D82 Command=0xAF Raw-Data=0x50AF6D82 32 bits LSB first Gap=3276750us Duration=67350us
全灯
Protocol=NEC Address=0x6D82 Command=0xA6 Raw-Data=0x59A66D82 32 bits LSB first Gap=3276750us Duration=67350us
留守番
Protocol=Onkyo Address=0x6D82 Command=0x1971 Raw-Data=0x19716D82 32 bits LSB first Gap=3276750us Duration=66200us