skydiablo / shelly
There is no license information available for the latest version (dev-main) of this package.
PHP library for Shelly Gen2+ devices (JSON-RPC over HTTP and AMQP/MQTT RPC)
dev-main
2026-06-05 09:28 UTC
Requires
- php: >=8.4
- ext-ctype: *
- php-extended/php-ip-object: ^6.0
- php-extended/php-mac-object: ^6.0
- react/http: ^3@dev
Requires (Dev)
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-06-05 09:28:44 UTC
README
A PHP library for controlling and managing Shelly Gen2+ devices (Plus, Pro, Gen3, Gen4) via the official JSON-RPC API.
Supported devices
This library targets Shelly devices that expose the Gen2+ JSON-RPC API (HTTP POST /rpc, optional MQTT/AMQP RPC on {topic_prefix}/{device_id}/rpc).
| Supported | Not supported |
|---|---|
| Shelly Plus series | Shelly Gen1 (original ESP8266 devices) |
| Shelly Pro series | REST-only firmware without /rpc |
| Shelly Gen3 / Gen4 |
Gen1 devices use a different protocol: path-based HTTP REST (/relay/0?turn=on), HTTP Basic authentication, and classic MQTT topics under shellies/. They are out of scope for this library.
API reference: Shelly Gen2+ documentation
Requirements
- PHP >= 8.4
- react/http ^3
Installation
composer require skydiablo/shelly
Features
- HTTP and AMQP client support for Shelly Gen2+ RPC
- Component wrappers for the Gen2+ API:
- System configuration and management
- WiFi configuration
- MQTT configuration
- Switch control
- Cloud settings
- KVS (Key-Value Store)
- Executer
- Device models for Gen2 devices (Generic, Pro1PM)
- Digest authentication (Shelly Gen2+ HTTP)
- Asynchronous operations using ReactPHP promises
Usage
use PhpExtended\Ip\Ipv4AddressParser; use PhpExtended\Mac\MacAddress48Parser; use SkyDiablo\Shelly\Model\Factory; use SkyDiablo\Shelly\Model\Shelly; // Create factory with MAC address parser $factory = new Factory(new MacAddress48Parser()); $ip = (new Ipv4AddressParser())->parse('192.168.0.10'); // Create a Shelly device instance from IP address (requires a Gen2+ device at that IP) $factory->shelly($ip)->then(function (Shelly $shelly) { // Use the Shelly device instance // The factory calls Shelly.GetDeviceInfo via RPC to obtain MAC address and device id })->otherwise(function ($error) { // Handle error (e.g. Gen1 device or unreachable host) });
License
MIT License — see LICENSE file for details.