ShellyControl
ShellyControl is a Python library for controlling and managing Shelly smart devices via HTTP and MQTT protocols. It provides an easy-to-use interface to interact with Shelly devices, retrieve their status, configure settings, and perform actions such as OTA updates and reboots.
Features
- Supports communication with Shelly devices via HTTP and MQTT
- Retrieve device status, settings, and actions
- Perform OTA updates and reboots
- Factory reset Shelly devices
- MQTT authentication support
- Easily extensible for different Shelly models
Installation
To install ShellyControl, you need Python 3.7 or later. Install the required dependencies using pip:
pip install requests paho-mqtt
Alternatively, if you have a requirements.txt file, install the dependencies with:
pip install -r requirements.txt
Usage
Importing the Library
from shellycontrol import ShellyDevice
Creating a Shelly Device Instance
You can initialize a Shelly device using either HTTP or MQTT:
Using HTTP:
device = ShellyDevice(deviceID="shelly1", ip="192.168.1.100")
Using MQTT:
device = ShellyDevice(deviceID="shelly1", mqttBroker="mqtt.example.com", mqttPort=1883, username="user", password="pass")
Retrieve Device Status
status = device.getStatus()
print(status)
Retrieve Device Settings
settings = device.getSettings()
print(settings)
Retrieve Device Actions
actions = device.getActions()
print(actions)
Perform OTA Update
device.OTAUpdate()
Reboot Device
device.reboot()
Factory Reset
device.factoryReset()
Available Classes and Methods
ShellyDevice Class
Constructor
ShellyDevice(deviceID, ip=None, mqttBroker=None, mqttPort=1883, username=None, password=None)
deviceID(str): Unique identifier of the Shelly device.ip(str, optional): IP address of the device (if using HTTP).mqttBroker(str, optional): MQTT broker address (if using MQTT).mqttPort(int, optional): MQTT broker port (default is 1883).username(str, optional): Username for authentication.password(str, optional): Password for authentication.
Methods
def sendHTTPRequest(endpoint, params=None)
- Sends an HTTP request to the Shelly device.
endpoint(str): API endpoint (e.g., "status").params(dict, optional): Request parameters.- Returns: JSON response if successful, else None.
def sendMQTTCommand(topic, payload)
- Sends an MQTT message.
topic(str): MQTT topic.payload(str): Message payload.
def getStatus()
- Retrieves device status.
- Returns: JSON response with device status.
def getSettings()
- Retrieves device settings.
- Returns: JSON response with device settings.
def getActions()
- Retrieves available device actions.
- Returns: JSON response with device actions.
def OTAUpdate()
- Performs an over-the-air (OTA) update.
def reboot()
- Reboots the device.
def factoryReset()
- Resets the device to factory settings.
Supported Shelly Devices
ShellyControl is designed to work with multiple Shelly devices, including:
- Shelly 3EM
- Shelly Dimmer 2
- Shelly Duo E27/GU10
- Shelly Plug
- Shelly Plus 1/1PM/2PM
- Shelly Pro 1/1PM/2/2PM/3/4PM
- Shelly RGBW2
- Shelly TRV
- Shelly Uni
- Shelly Vintage
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
License
This project is licensed under the MIT License.
Metadata
Release files for PyShellyControl 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyshellycontrol-0.1.0.tar.gz | 12.6 kB | Without provenance | Details for pyshellycontrol-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyShellyControl-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for PyShellyControl-0.1.0-py3-none-any.whl |
Total release size: 35.4 kB
Release files / pyshellycontrol-0.1.0.tar.gz
| Download URL | pyshellycontrol-0.1.0.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc676363011b171cb9e4b723be06ee6578914ba8d48507d457a6c7ee12f60cdd
|
|
BLAKE2b-256 checksum How to use checksums |
7e6261c61a6d8af595c906029c19614343f6e32ff19266dcc14888a264ff4169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.0 CPython/3.8.10
|
Release files / PyShellyControl-0.1.0-py3-none-any.whl
| Download URL | PyShellyControl-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8248db1952eed64b5307d2182e8bb1caea1d13905dcf39824b2b830535aa91a
|
|
BLAKE2b-256 checksum How to use checksums |
77fee9aa50ac82329e5146797482934dac00a36fcd2d4df04ca3272e260c8fab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.0 CPython/3.8.10
|
Security for PyShellyControl 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.