A Go package to control BroadLink RM mini 3 "Black Bean" IR remote controller.
I built this package just to control my own home appliances, and the RM mini 3 is the only device I have. For other devices, you can fork and implement yourselves. :p
devs, err := broadlink.DiscoverDevices(100*time.Millisecond, 0)
fmt.Println(devs)
// d := devs[0]
myname := "my test server" // Your local machine's name.
myid := make([]byte, 15) // Must be 15 bytes long.
// Fill myid[] with some unique ID for your local machine.
err = d.Auth(myid, myname) // d.ID and d.AESKey will be updated on success.
var rtype RemoteType
var ircode []byte
// Enter capturing mode.
err = d.StartCaptureRemoteControlCode()
// Point a remote controller toward the device and press a button to have some signal.
// Poll captured data. (Certainly you can do much better than this ;p)
ok := false
for i:=0; i<30; i++ {
remotetype, ircode, err = d.ReadCapturedRemoteControlCode()
if err == nil {
ok = true
break
}
if err != ErrNotCaptured {
return err // real error
}
time.Sleep(time.Second)
continue
}
if ok {
// ircode now have captured data
}
err = d.SendIRRemoteCode(ircode, 1) // 1 means once, 2 is twice, ...
// Note that sending IR signals may take a few hundred milliseconds. Set network timout accordingly.
err = broadlink.SetupDeviceWifi("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD", broadlink.WIFI_SECURITY_WPA_TKIP, nil)
// try to detect devices below
// devs, err := broadlink.DiscoverDevices(100*time.Millisecond, 0)
Note that references may have incorrect and inconsistent information.
- mjg59's Python-broadlink tool: https://github.com/mjg59/python-broadlink
- Broadlink smart home devices complete protocol hack: https://blog.ipsumdomus.com/broadlink-smart-home-devices-complete-protocol-hack-bc0b4b397af1