Python API for controlling myStrom switches
Project description
Python API for controlling myStrom switches.
Requirements
You need to have Python installed.
Details
At the moment the following endpoints are covered:
/report: for getting the current state and the power consumption
/relay: for setting the relay state
You will still be able to use your device with the smartphone application, curl, or other tools. The samples below shows how to use the switch with httpie and curl along with python-mystrom.
$ http http://10.100.0.137/report
HTTP/1.1 200 OK
Content-Length: 39
Content-Type: application/json
Date: Mon, 15 Feb 2016 17:52:21 GMT
{
"power": 51.630947,
"relay": true
}
$ curl -X GET http://IP_ADDRESS_PLUG/relay?state=1
Example
The sample below shows how to use this Python module.
import time
import pymystrom
plug = pymystrom.MyStromPlug('IP_ADDRESS_PLUG')
# Switch relay on
plug.set_relay_on()
# Get the state of the switch
print('Relay state: ', plug.get_relay_state())
print('Power consumption:', plug.get_consumption())
# Switch relay off
time.sleep(10)
plug.set_relay_off()
License
python-mystrom licensed under MIT, for more details check LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file python-mystrom-0.2.1.tar.gz
.
File metadata
- Download URL: python-mystrom-0.2.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6cebc8c5a031b633371a08cc61488754185e9f82ffd5eeea99a715b18f9d6fc |
|
MD5 | dcdbe66efd4839b77947425af14e8507 |
|
BLAKE2b-256 | d864e4003bbc1968daa0cb7a361e8238d8e86d0c6977b301537962d047bda797 |