Control Tasmota devices via their web api
Project description
Tasmota Device Controller
This packag provides async wrappers for Tasmota's web request API.
Only very few requests are implemented so far! If you need other requests, please have a look at the section Contributing, or create an issue.
get
methods return the value of the fetched item, set
methods return the new set value (so what the get
method would return after the set). However there are some exceptions like BLINK
for setPower()
which always returns True
, but that should be mentioned in the methods description.
Since this package was created for a Home Assistant integration, you can check out that integration for other sample usage.
Example usage:
import asyncio
from tasmotadevicecontroller import TasmotaDevice
from tasmotadevicecontroller import tasmota_types as t
async def main():
device = await TasmotaDevice.connect('192.168.10.21')
# Get friendly name (of first output, which is the default output)
nameResult = await device.getFriendlyName()
print(nameResult) # Returns 'My Tasmota Plug'
# Get power of first output
getResult = await device.getPower()
print(getResult) # Returns True (on)
# Set power of first output to on
setResult = await device.setPower(t.PowerType.TOGGLE)
print(setResult) # Returns True or False (depending if the device was switched on or off)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Contributing
If you want to add new requests, can implement these commands and create a merge request on GitHub.
Almost every command is implemented as one getter method and one setter method. Add your command if possible in the same way inside the TasmotaDevice
class. Remember to add descriptions to each method. This description can usually be taken from the Tasmota wiki.
Also, remember to always use async
await
!
If the command takes values from a specific set of values, create an Enum
inside tasmota_types.py
for it.
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
File details
Details for the file tasmotadevicecontroller-0.0.6.tar.gz
.
File metadata
- Download URL: tasmotadevicecontroller-0.0.6.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d43e9e7679eff1d98ce0b93ff621fc76007dfc0dc5c4fde834defd5f6a7639e |
|
MD5 | 3d537fe34558efae9807b03f2644e4e1 |
|
BLAKE2b-256 | ee4e0fd1d97dc9e224bf39eadaa22dbf94d7b5777e720bbec0648ab4926f11ac |
File details
Details for the file tasmotadevicecontroller-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: tasmotadevicecontroller-0.0.6-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b0493bec44390ca3607b9dc5627088ed49e5f22b8090ce44da00a6d9eafca53 |
|
MD5 | d90b5a479d456cf9b1cc42f4faea2d50 |
|
BLAKE2b-256 | c1323c061c0f97b5063999b7b763b6eecda462dd9dd48f3327a914deea9475b7 |