PHPackages                             rudestan/broadlink-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rudestan/broadlink-api

ActiveLibrary[API Development](/categories/api)

rudestan/broadlink-api
======================

Broadlink RM devices API library

v1.1.0(7y ago)9595[1 issues](https://github.com/rudestan/broadlink-api/issues)MITPHPPHP &gt;=7.2.0

Since Mar 2Pushed 7y ago3 watchersCompare

[ Source](https://github.com/rudestan/broadlink-api)[ Packagist](https://packagist.org/packages/rudestan/broadlink-api)[ RSS](/packages/rudestan-broadlink-api/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Broadlink API PHP7 library
==========================

[](#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](http://www.ibroadlink.com/rm/). The protocol refer to: [mjg59/python-broadlink](https://github.com/mjg59/python-broadlink/blob/master/README.md)

Original code refer to: [ThePHPGuys/broadlink](https://github.com/ThePHPGuys/broadlink).

### What are the differences with original implementation from "ThePHPGuys"?

[](#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

[](#usage)

#### Discover devices

[](#discover-devices)

```
use BroadlinkApi\Device\NetDevice;

$discovered = (NetDevice::create())->discover();
```

The code will produce an array with Instances of corresponding Authenticatable (extended from `AbstractAuthenticatableDevice::class`) devices or/and with Instances of `UnknownIndetifiedDevice::class` in case no or some Unknown devices found.

#### Authorize device (get the cipher key)

[](#authorize-device-get-the-cipher-key)

To control previously discovered RM device it must be Authenticated. Let's say the first device in the `$discovered` array is an instance of `RMDevice` class (or any other that extended from `AbstractAuthenticatableDevice::class`). The code will look like the following:

```
use BroadlinkApi\Device\AuthenticatableDeviceInterface;
use BroadlinkApi\Exception\ProtocolException;

/** @var AuthenticatableDeviceInterface $device */
$device = $discovered[0];

try {
    $device->authenticate();
} catch(ProtocolException $e) {
    echo $e->getMessage();
}
```

#### Set device to learning mode

[](#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.

```
use BroadlinkApi\Device\Authenticatable\RMDevice;

if ($device instanceof RMDevice) {
    try {
        $device->enterLearning();
    } catch(ProtocolException $e) {
        echo $e->getMessage();
    }
}
```

#### Receive last learned command from the Device

[](#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:

```
$command = null;

while(true) {
    $command = $device->getLearnedCommand();
    sleep(1);

    if ($command !== null) {
        break;
    }
}

var_dump($command->toArray());
```

An instance of `Packet::class` will be returned once the command will be received.

#### Send command to the Device

[](#send-command-to-the-device)

After receiving a Packet from `RMDevice::getLearnedCommad()` it can be converted to an array by calling `Packet::toArray()` 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:

```
use BroadlinkApi\Exception\ProtocolException;

try {
    $device->sendCommand($command);
} catch (ProtocolException $e) {
    echo $e->getMessage();
}
```

#### Other usage example

[](#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 BroadlinkApi\Device\Authenticatable\RMDevice;
use BroadlinkApi\Exception\ProtocolException;
use BroadlinkApi\Packet\Packet;

// Let's assume that $commandJson is json encoded array with received command
$commandCode = json_decode($commandJson, true);
$command = Packet::fromArray($commandCode);

$rmDevice = new RMDevice('192.168.1.1', '77:0f:71:b9:5e:82');

try {
    $device->authenticate();
    $device->sendCommand($command);
} catch(ProtocolException $e) {
    echo $e->getMessage();
}
```

#### Use cases

[](#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.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

2625d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97cfa9bd6b59333d0d661e14f494f8bb1496a8fc7ca42c9802b955cb94f9b6b4?d=identicon)[rudestan](/maintainers/rudestan)

---

Top Contributors

[![rudestan](https://avatars.githubusercontent.com/u/696823?v=4)](https://github.com/rudestan "rudestan (19 commits)")

---

Tags

apibroadlinkrmpro

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rudestan-broadlink-api/health.svg)

```
[![Health](https://phpackages.com/badges/rudestan-broadlink-api/health.svg)](https://phpackages.com/packages/rudestan-broadlink-api)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
