Unofficial MyStrom API Client
Project description
python-mystrom aka. pystrom
This is an unofficial Python integration for finding and controlling local MyStrom devices.
Due to the lack of owned devices, some features may not be fully implemented or tested. The project is primarily developed and tested with the MyStrom Wi-Fi Switch CH.
[!IMPORTANT]
This project is not developed by MyStrom nor affiliated with them in any way.
Official MyStrom API Documentation: https://api.mystrom.ch/
Want to contribute? Check out the Contributing section below.
Installation
Installation requires Python and Pip (which usually comes with Python).
python -m pip install -U pystrom
Features
This library provides a simple CLI and a Python API.
Console Commands
| Command | Function |
|---|---|
python -m pystrom find |
Listen for MyStrom devices in the local network |
python -m pystrom find --live |
Continuously listen for MyStrom devices in the local network |
Python API
Get device objects
You can use the MyStromDeviceFinder class to find devices in your local network. It will return a list of
MyStromDevice objects or subclasses thereof.
from pystrom.finder import MyStromDeviceFinder
with MyStromDeviceFinder() as finder:
devices = finder.find_all() # will take 5 seconds
for device in devices:
print(device)
You can also create a MyStromDevice object by using the MyStromDeviceFactory.from_ip method, which only requires the
IP address of the device:
from pystrom.device import MyStromDeviceFactory
device = MyStromDeviceFactory.from_ip("192.168.1.220")
print(device)
Control devices
The following API methods are available for controlling devices:
General (MyStromDevice)
| Method | Function |
|---|---|
.get_general_info() |
Get general device information |
.get_wifi_list() |
Get reachable Wi-Fi networks |
.get_help() |
Get a list of available API endpoints |
.get_settings() |
Get current device settings |
.set_settings() |
Set or update device settings |
Switch (MyStromSwitch)
| Method | Function |
|---|---|
.turn_on() |
Turn on the switch |
.turn_off() |
Turn off the switch |
.toggle() |
Toggle the switch state and return the new state |
.power_cycle() |
Power cycle the switch (off, wait, then on) |
.timer() |
Set the state and reverse it after a specified time |
.get_report() |
Get a report of the switch's current state |
.get_temperature() |
Get the current temperature reading and configuration |
Bulb (MyStromBulb)
| Method | Function |
|---|---|
.turn_on() |
Turn on the bulb |
.turn_off() |
Turn off the bulb |
.toggle() |
Toggle the bulb state |
.set_options() |
Set options like color, ramp, mode, and notifyurl |
.get_device_information() |
Get the device information, including current bulb state |
Other devices and missing endpoints
Other device types are not yet implemented with specific classes, but you can still interact with them:
To control them, you can use the manual API methods of the MyStromDevice class, which allows you to send HTTP requests
to the device's API endpoints.
| Method | Function |
|---|---|
.api_get() |
Send a GET request to the device's API endpoint |
.api_post() |
Send a POST request to the device's API endpoint |
Contributing
If you want to contribute to this project, feel free to open an issue or pull request. Contributions are welcome!
- Fork the repository
- Clone your forked repository
python -m pip install -e .[dev]to install the package in editable mode with development dependencies- Make your changes
- Format & check your code:
- Format your code with
black . - Check typing with
mypy --strict .
- Format your code with
- Push your changes to your forked repository
- Open a pull request
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pystrom-2.0.0.tar.gz.
File metadata
- Download URL: pystrom-2.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c429b8d95f9b3e3712c288996c73920ce9cb8446168765542d18ab162b5a6f8f
|
|
| MD5 |
1d3fc0fc1a3d6ad34e8b7ce87a3d36e5
|
|
| BLAKE2b-256 |
91c071924c373570add5c4f73214edc4ffdf4ce01e17ccaa55f5d157a0126211
|
Provenance
The following attestation bundles were made for pystrom-2.0.0.tar.gz:
Publisher:
python-publish.yml on rafaelurben/python-mystrom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pystrom-2.0.0.tar.gz -
Subject digest:
c429b8d95f9b3e3712c288996c73920ce9cb8446168765542d18ab162b5a6f8f - Sigstore transparency entry: 272683500
- Sigstore integration time:
-
Permalink:
rafaelurben/python-mystrom@8d20a8fb5aa6c0b266331995c9b5e17c0b900002 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/rafaelurben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8d20a8fb5aa6c0b266331995c9b5e17c0b900002 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pystrom-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pystrom-2.0.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e46adc71fae7d6b588fc06c5ad237b1af1d09962a3999f557d20d8a633ebfb1c
|
|
| MD5 |
01fb50baf5b07750f91196c6b437dfac
|
|
| BLAKE2b-256 |
141a1dcb1984725b3b5a76c530e0d022d9b7f1ebfe0c34660ac3238ded968bd2
|
Provenance
The following attestation bundles were made for pystrom-2.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on rafaelurben/python-mystrom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pystrom-2.0.0-py3-none-any.whl -
Subject digest:
e46adc71fae7d6b588fc06c5ad237b1af1d09962a3999f557d20d8a633ebfb1c - Sigstore transparency entry: 272683502
- Sigstore integration time:
-
Permalink:
rafaelurben/python-mystrom@8d20a8fb5aa6c0b266331995c9b5e17c0b900002 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/rafaelurben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8d20a8fb5aa6c0b266331995c9b5e17c0b900002 -
Trigger Event:
release
-
Statement type: