A simple C# API for controlling RM from Broadlink.
This is a port of python-broadlink to C# .Net Standard.
Supported device:
- RM Pro
- RM mini 3 (Black Bean)
- A1 Temperature/Humidity/Noise/Light/VOC Sensor
- SP mini 3 Smart Plug
Supports .NET Standard2.0
- Add NuGet-Package to your project, or download this source and add ref SharpBroadlink.csproj
- Setup devices or discover devices as follows:
== Preparation - It is the same as the original. ==
- Plug the USB-cable into your Broadlink device, turn it on.
- Long press the reset button until the blue LED is blinking quickly.
- Long press again until blue LED is blinking slowly.
- Manually connect your PC to the WiFi SSID named BroadlinkProv.
== Preparation is over ==
using SharpBroadlink;
// Security mode options are [None, Wep, WPA1, WPA2, WPA12]
Broadlink.Setup('myssid', 'mynetworkpass', Broadlink.WifiSecurityMode.WPA12);
using SharpBroadlink;
var devices = await Broadlink.Discover(5);
using SharpBroadlink;
var devices = await Broadlink.Discover(5);
var device = (SharpBroadlink.Devices.Rm)devices.First(d => d.DeviceType == DeviceType.Rm);
await device.Auth();
// Enter Learning mode
await device.EnterLearning();
Here, Point the remote control to be learned to RM Pro, and press the button.
And...
// Get signal data.
var signal = await device.CheckData();
// Test signal
await device.SendData(signal);
using SharpBroadlink;
var devices = await Broadlink.Discover(5);
var device = (SharpBroadlink.Devices.Rm)devices.First(d => d.DeviceType == DeviceType.Rm);
await device.Auth();
// Toshiba-TV Power-On IR code
// http://www.remotecentral.com/cgi-bin/codes/toshiba/ct-9726/
var pronto = "0000 006b 0022 0002 0156 00ac 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0015 0016 0040 0016 0015 0016 0040 0016 0040 0016 0040 0016 0040 0016 0040 0016 0040 0016 0015 0016 0040 0016 0015 0016 0040 0016 0015 0016 0015 0016 0040 0016 0015 0016 0015 0016 0015 0016 0040 0016 0015 0016 0040 0016 0040 0016 0015 0016 0040 0016 0040 0016 0040 0016 05fb 0156 0056 0016 0e59";
var bytes = Signals.String2ProntoBytes(pronto);
await device.SendPronto(bytes);
var rm2pro = (await Broadlink.Discover(1))
.First(x => x.DeviceType == DeviceType.Rm2Pro) as Rm2Pro;
await rm2pro.Auth();
using(var code = await rm2pro.LearnRfCommand(CancellationToken.None))
await rm2pro.SendRfData(code);
using SharpBroadlink;
var devices = await Broadlink.Discover(5);
var device = (SharpBroadlink.Devices.A1)devices.First(d => d.DeviceType == DeviceType.A1);
// before Auth, cannot get values.
await device.Auth();
var values = await device.CheckSensors();
using SharpBroadlink;
var devices = await Broadlink.Discover(5);
var device = (SharpBroadlink.Devices.Sp2)devices.First(d => d.DeviceType == DeviceType.Sp2);
// before Auth, cannot get values.
await device.Auth();
var powerState = await device.CheckPower();
var nightLightState = await device.CheckNightLight();
await device.SetPower(!powerState);
await device.SetNightLight(!nightLightState);
Original python-broadlink:
https://github.com/mjg59/python-broadlink
Protocol document:
https://github.com/mjg59/python-broadlink/blob/master/protocol.md