mlfunston / node-red-contrib-broadlink-control

Set of node-red nodes to manage the Broadlink home automation device suite
MIT License
44 stars 24 forks source link
broadlink broadlink-rm home-automation node-red

Broadlink Control - Broadlink Device nodes for Node-RED

GitHub version GitHub issues GitHub license Twitter

A set of Node-RED nodes to manage the Broadlink RM series of IR Controllers and for home automation. A cost effective way to control Air Conditioners, TV's, Audio equipment and many more like a universal remote control unit.

This is a fork of the work by VladimirSFilippov https://github.com/VladimirSFilippov/node-red-contrib-broadlink with some enhancements and additions I was looking for, including documentation. I don't have that much time to maintain this, so feel free to fork and submit a PR if you do any updates. It will help a lot.

If you would like to donate to purchasing some testing hardware or want to buy me a coffee or beer, click here: https://www.paypal.me/mlfunston

Supported Devices

Note: There are other nodes included per below list, however, I have not tested them as I don't have those devices. So let me know if you've had success using them.

The TC2 device is not directly supported as it communicates via RF to the RM-Pro. However, if you have an RM Pro unit, you can pull the RF codes from the phone app after you have configured it and use those to control the switch. Note that you may need to send them multiple times to ensure it meets the requirements of being divisible by 16. Refer to this thread for similar process.

Installing and Setting up

Add the Broadlink node to Node-RED through the manage palette tab or command line.

Discover your Broadlink device by using the Discover node. This will reveal MAC Address, IP Address and Type Code needed to setup the config node.

You can either learn commands directly from the RM unit using the node, or from the Broadlink e-control app and export them. In the latter case, you will need the SharedData folder exported from the app as a starting point.

Catalog folder (SharedData) is not needed if you plan to learn every command you will use, but using the sample broadlinkDB folder as the catalog might help since the RM Node expects IR data to be formatted a certain way.

Community How-Tos, Videos & Articles

If you find good content related to this set of nodes please share it below:

Broadlink e-control App Method

First, configure the Broadlink device through the Broadlink e-control app on your smartphone. You will need to copy some files from your device after setup.

For Apple devices use this app: https://itunes.apple.com/us/app/broadlink-e-control/id793152994?mt=8

Note: The newer Broadlink IHC / Intelligent Home Center app is not compatible with this method at present. Only the e-control app files work with this node at present. If someone wants to have a go at developing this, please fork and submit a pull request. I will not have time to look at this for a bit.

Secondly, newer firmware / devices may not work with the older e-control app, so you may need to use the database files I have included in the brodlinkDB directory and learn the IR codes directly with the example code.

New Broadlink App and Cloud mode - Troubleshooting

The latest Broadlink app may confiure the device in cloud mode which means that it will no longer function locally with this library. This is common for RM4 and RM3 Mini newer devices (e.g. device type 5f36 or 2737). If you can discover the device but cannot learn or send, then you likely have this issue.

To reverse this, you will need to reset the device.

Suggested process is as follows:

  1. Remove any existing configured devices or control in the Broadlink app.
  2. Reset device by long press (~6 seconds) the reset button with a pin or paperclip until the LED rapidly flashes.
  3. Use the BroadLink app to connect to WiFi (keep your phone close to RM). AND STOP!!
  4. Do nothing more, dont't add anything more in the app, quit the app and now use the broadlink nodes in Node Red.

If you have a locked device, you can also unlock it from the Broadlink app now. Try the instructions here https://github.com/mlfunston/node-red-contrib-broadlink-control/issues/91

Configuring the Broadlink App

The app itself is not that intuitive, but after you add the RM device you will need to add a user defined device (eg an air conditioner or tv) and buttons. If you use one of the built in devices the remote commands aren't recorded in the files, so make sure to use user defined.

  1. Swipe left on the home screen to reveal your devices.
  2. Select the device
  3. Select the :gear: icon and add remote
  4. Click the + sign and add the buttons or functions you want to be able to use in Node-RED
  5. The app will ask you to point the remote at it and press the appropriate button
  6. Complete the process to add the buttons you need
  7. Click the :gear: icon and create shortcut if you want the device to be visible on the app home screen
  8. Return to the home screen and swipe right and click share and Share to other phones in WLAN

Now you are ready to copy the config files from the device to use in the node!

Copying the files from an iPhone

  1. Use an app like iExplorer and connect your iPhone to your computer and do a backup using the tool
  2. Explore the backup and open the Apps section of the backup
  3. Find the cn.com.broadlink.e-Control folder and export it to your computer
  4. Put the folder into a location where Node-RED can see it. You will need the path to the cn.com.broadlink.e-Control.new/Documents/SharedData/ folder later

Copying files from and Android phone

I don't have one, but it should be simpler to find the folder on it and extract it. I did find the below instructions somewhere that you could try. Perhaps someone can contribute here?

Connect your Android device to your computer and browse the SD card/External Storage folder /broadlink/newremote/SharedData/.

Configuring Node-RED nodes

Assuming you have added the Broadlink nodes and configured as above, you will need the MAC address of the device, IP address and the path to the SharedData folder above. For device type, if you have an older device you can set the default value to 272a. Newer RM3 devices or RM4 requires the correct device type to be entered. You can find your device type via the discover node. Check the example nodes below.

  1. Add the RM node and double click it
  2. Select device and add new rmdevice
  3. Fill in the MAC address of the device, IP address, device type and the full path to the SharedData folder in the Catalog field and click Add
  4. You will then need to save the node and click Deploy so that you can see the buttons you created in the Broadlink app in the node.
  5. Double click on the node again and you should be now able to select Action -> Send and then pick the remote and button you wish to send.
  6. Save node, add an inject node on the front and link them together and deploy.

Now you should be able to click on the inject node and fire a signal to your device!

Start adding extra nodes to fire out the functions you need or inject messages to the node to drive it.

Sending data via msg.payload

Data needs to be formatted as a buffer object, or as a Base64 data string (eg as used by Home Assistant or others).

An example of a function node containing the sample data is shown below.

//Insert learned data object here
var data = [38,0,140,0,77,21,18,22,38,21,17,22,17,22,38,21,18,21,18,22,37,22,17,22,18,21,18,22,17,0,3,99,77,21,18,22,38,21,17,22,18,21,38,21,18,22,17,22,38,21,18,21,18,22,17,22,17,0,3,99,77,21,18,22,37,22,17,22,18,21,38,21,18,22,17,22,37,22,18,21,18,22,17,22,18,0,3,100,76,22,18,21,38,21,18,22,17,22,37,22,18,21,18,22,37,22,17,22,18,21,18,22,17,0,3,101,76,22,18,21,39,20,18,22,17,22,37,22,18,21,18,22,37,22,17,22,18,21,18,22,17,0,13,5,0,0,0,0,0,0,0,0,0,0,0,0];
// or Base64 encoded format from other source
//var data = "JgBMAnM3ECkQKRANEAwRDQ8pEAwQDRApDyoQDQ8pEA0QDRAoECkQDRAoEigQDBEMECkRDBAMECkQDRAMEA0QDRAMEA0QDRANDw4PDQ8NEA0PDRANEA0RDA8NEAwRDBAMESgQDRAMEA0QDRAMESgQKRANEAwRDBApDyoQDBApEA4PDBILEQwQDRAoESgRDBApECkQDBANECkQDBANECgRDBANECkQDBEoEQwQKQ8NEA0QKQ8qEAwQDRAMEA0QDQ8NEA0QDBEMEAwRDQ8ODwwRDBAMEA0QDRAMEA0QDBANEQwQDRAMEA4PDRANEAwQDBANEA0QDBEMEAwQDRAMEA4PDBEMEA0PDRANEAwRDQ4OEAwRDBEMEAwQDRANECgQKRApECkQDBEMEAACMnc4ECgQKRANEQwQDQ8pEQwQDQ8qECgQDRApEA0QDBEoECkQDBEoECkQDRAMECkQDRAMECkQDRANEAwQDRANDw0QDQ8NEQwQDBEMEA0PDRENDw0QDBANDw0QDRANECgRDBAMEA0QDRAMECkRKBANEAwRDBApECkQDBEoEQwQDRAMEA0QDBApECkQDRApECgQDRANECgRDBANECgRDBANECgRDBApEAwQKRANEAwRKBApEQwQDBEMEA0QDBEMEA0QDQ8NDw0RDBAMEQwQDRAMEA0QDBEMEA0QDBANEAwQDRANEAwQDRANEAwQDRAMEA0QDRAMEA0QDBANEA0RCxILEQwQDBEMEA0QDBEMEA0QDQ8NEQwQDBANECkPKhApECkQDBANEAANBQAAAAAAAAAAAAAAAA=="

msg.payload={
    //"mac":"MAC address of your broadlink rm",  // Optional if configured in the RM node
    //"host":"IP address of your broadlink rm",  // Optional if configured in the RM node
    "action":"send",
    "data":data,
    "repeat":2
};

return msg;

This should then be connected to the RM node to send the data.

Examples

There are example flows to provide some additional functions / templates to use. You can get the example flows from the Node-RED hamburger menu (top right corner), choose Import -> Examples -> broadlink-control and pick your example.

Example 1: Add new button to the RM node database

This example allows modification of the RM node database files (jsonSubIr, jsonButton and jsonIrCode) so you can add new buttons and IR codes without having to re-import from the Broadlink App. New Devices and Buttons can also be added here.

Set your data file location and new device, button name and IR codes in the Config node in the example.

Image of AddNewButton Example Nodes

Image of AddNewButtonSubflow Example Nodes

Note: If your Broadlink files contain any non standard characters eg the degree symbol then it will not load the file correctly. Also I noted that the e-control app put the incorrect quotation marks around some of the parameters, so this may need to be fixed in your file first before using this script. I have supplied some example database files in the broadlinkDB directory.

Example: Image of CorruptCharacters

The " marks are incorrect at the end of name, start and end of OFF and start of index in the example above. Check to make sure yours are correct. This is also what causes "undefined" to be displayed in the button list.

Example 2: Return IR Codes based on Device and Button Names

This example allows you to pull the IR code out from the data files based on the device and button name. You can then directly send them with the RM node. This allows programmatic selection of the device and button.

Set your data file location and device and button name and the IR codes will be returned in the msg.payload.

Image of GetIRCode Example Nodes

Image of GetIRCodeSubflow Example Nodes

Example 3: Learn and Send Data

This example allows you to Learn an IR code with the RM device and then Send those out directly.

Set your RM device details in the RM nodes in the example and the data string in the function node in the send example. You can use this as an example to programmatically learn and send data from and to the RM device.

Image of LearnAndSendData Example Nodes

To Do

Authors & Contributors

Feel free to fork this and provide updates and new features! Don't forget to submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

This Node-RED module is based on the great work of VladimirSFilippov - VladimirSFilippov, using his node-red-contrib-broadlink libraries. Also thanks to the python-broadlink repository from Matthew Garrett.

Changelog

v2.1.6 (latest)

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.5

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.4

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.3

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.2

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.1

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.1.0

Note - Version 2.0.0 introduced a new field in the device configuration which required a manual change to each RM device configuration in Node-RED.

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.0.1

Note - Version 2.0.0 introduced a new field in the device configuration which required a manual change to each RM device configuration in Node-RED.

Note - RF learn and send may not be working yet on the RM Pro 4 series but should be working in the earlier RM Pro units, although I don't have either to test with.

v2.0.0

Note - This version introduces a new field in the device configuration which will require a manual change to each device configuration.

v1.0.8

v1.0.7

v1.0.6

v1.0.5

v1.0.4

v1.0.3

v1.0.2

v1.0.1

v0.2.8

v0.2.7

v0.2.5