Download the PHP package rudestan/broadlink-api without Composer
On this page you can find all versions of the php package rudestan/broadlink-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package broadlink-api
Broadlink API PHP7 library
A PHP 7 library for controlling IR and Wireless 433Mhz controllers (e.g. RM Devices), Smart Plugs (e.g. SP2/SP3) from Broadlink. The protocol refer to: mjg59/python-broadlink
Original code refer to: ThePHPGuys/broadlink.
What are the differences with original implementation from "ThePHPGuys"?
- Added full support of RM3 Pro Plus (learning mode, receiving and sending commands), so it became fully usable withing the api
- Added support of SP2/SP3 Devices (power on/off, nightlight on/off, get state of power/nightlight)
- Code was refactored and logic a bit simplified
- Code was reformatted and cleaned to be able to easily understand the flow
Usage
Discover devices
The code will produce an array with Instances of corresponding Authenticatable (extended from ) devices or/and with Instances of in case no or some Unknown devices found.
Authorize device (get the cipher key)
To control previously discovered RM device it must be Authenticated. Let's say the first device in the array is an instance of class (or any other that extended from ). The code will look like the following:
Set device to learning mode
After RM device got Authenticated we can set it to learning mode for receiving commands from any remote control. The following code will set the device to learning mode in case the device class is instace of RMDevice.
Receive last learned command from the Device
Once the RM Device is in learning mode we can receive the last learned command. We also need to wait until the command arrives, so example code might look like this:
An instance of will be returned once the command will be received.
Send command to the Device
After receiving a Packet from it can be converted to an array by calling method. Converted array can easily be stored for example in json file or in the DB and later can be reused to reproduce this command with the Device. To send previously learned command the following code can be used:
Other usage example
If the IP and Mac address of the device is already known (for example it was previously saved) as well as the command (eg. loaded from JSON) the device can be easily used to trigger this command. Possible code might look like the following:
Use cases
The following API can be used for example to connect Google Home or Alexa together with Broadlink RM Pro for example through Raspberry PI as proxy hub. Or another way of usage can be creation of some web widget for Android instead of using limited official Broadlink Application. This API extends the limits of the Device and it becomes much more interesting.
All versions of broadlink-api with dependencies
ext-openssl Version *
ext-sockets Version *
ext-json Version *