Giter VIP home page Giter VIP logo

sharpbroadlink's Introduction

SharpBroadlink - for Broadlink RM IR Controller

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

Links

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

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

sharpbroadlink's People

Contributors

adamot avatar saoszjant avatar ume05rw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sharpbroadlink's Issues

Discover Device empty

The RM PRO connects to WiFi correctly because the blue led stops blinking, but the devices list is empty, I tried to increase the time but i'm getting a null anyways.

await Broadlink.Setup("xxx", "xxx", Broadlink.WifiSecurityMode.WPA2);
var devices = await Broadlink.Discover(30);
var device = (SharpBroadlink.Devices.Rm2Pro)devices.First(d => d.DeviceType == DeviceType.Rm2Pro);

Question

If my device is present in the network, How can I connect via IP address?

Thank you!

IR learning not working?

Hello,
I used the command line project for testing and the method "RmTest()" for learning IR codes does not work for me.
await rm.EnterLearning();
var data1 = await rm.CheckData();
var data2 = await rm.CheckData();

data1 and data2 are always NULL. What am I missing?
How do you do IR learning?

Regards
Bernd

Problem with learning

When i put the device in learning mode (rf), i get the for example opening lights command. But when i try to learn another command (close lights), it returns the same byte[] from the last command (open lights).
So if i want to use another command i have to reset the device.
There is anyway of making the device learn other command without reseting the device?

RF learning always returns the same code

So I have written a WPF GUI that uses SharpBroadlink to learn IR- and RF-codes.
IR-codes work like a charm, but learning RF-codes always returns the same byte[].

So, if I have learned an IR-code and then want to learn an RF-code, I will get the IR-code I have learned before.
If I have not learned an IR-code before, I always get the same 92bytes for learning RF-codes, no matter which RF-code I want to learn.

This can easy be reproduced using the command line tool or
you can reproduce that using my GUI application:
BroadlinkControl

Regards
Bernd

UI using this library?

Hello,
is there a UI available that uses this library?

I downloaded and compiled the source code and RF-learning works with my RM Pro (tested with the command line project) :)

But it would be nice to be able to get the codes via a UI, so that I can get them for my OpenHab installation.

Regards
Bernd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.