SharpBroadlink 1.0.3

.NET Standard 2.0
dotnet add package SharpBroadlink --version 1.0.3
NuGet\Install-Package SharpBroadlink -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharpBroadlink" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpBroadlink --version 1.0.3
#r "nuget: SharpBroadlink, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SharpBroadlink as a Cake Addin
#addin nuget:?package=SharpBroadlink&version=1.0.3

// Install SharpBroadlink as a Cake Tool
#tool nuget:?package=SharpBroadlink&version=1.0.3

A simple C# API for controlling RM from Broadlink.
This is a port of python-broadlink to C# .Net Standard.

Description

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

Requirement

Xb.Core
Xb.Net

Usage

  1. Add NuGet-Package to your project, or download this source and add ref SharpBroadlink.csproj
  2. Setup devices or discover devices as follows:
Setup:

== Preparation - It is the same as the original. ==

  1. Plug the USB-cable into your Broadlink device, turn it on.
  2. Long press the reset button until the blue LED is blinking quickly.
  3. Long press again until blue LED is blinking slowly.
  4. 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);
Discover devices:
using SharpBroadlink;
 
var devices = await Broadlink.Discover(5);
Get signal data with RM:
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);
Send Philips-Pronto format IR signal data with RM:
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);
Learning and sending RF codes using RM2Pro
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);
Get sensor data with A1:
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();
Get/Set plug state with SP3:
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);

Licence

MIT Licence

Original python-broadlink:
https://github.com/mjg59/python-broadlink

Protocol document:
https://github.com/mjg59/python-broadlink/blob/master/protocol.md

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 1,007 8/9/2019
1.0.2 841 12/30/2018
1.0.1 618 9/29/2018
1.0.0 600 9/29/2018

Fix RF-Signal Learning Function.THANK A LOT to saoszjant, AdamoT!!!