Add your description here
Project description
Install
pip install flespi-sdk
Usage
from flespi_sdk.account import Account
# log into account
account = Account()
await account.set_token("<flespi-token>")
# or
# await account.realm_login("<realm-public-id>", "<realm-username>", "<realm-password>")
# use account
print("Metadata", await account.metadata.get())
print("Direct subaccount IDs", [subaccount.id for subaccount in await account.subaccounts.list()])
print("Flespi API counters", await account.mqtt.list("flespi/state/platform/customer/counters/api/#"))
Examples
Read emails from MQTT for all subaccounts (master token required)
from flespi_sdk.cli import get_account
async def main():
account = None
try:
account = await get_account()
subaccounts = await account.subaccounts.list()
for subaccount in subaccounts:
name = await subaccount.metadata.get_value("sys_user_config.title")
mqtt_msg = await subaccount.mqtt.get("flespi/state/platform/customer/email")
email = mqtt_msg["payload"]
print(f"Subaccount ID: {subaccount.id}, Name: {name}, Email: {email}")
except Exception as e:
print("Error:", e)
finally:
if account:
await account.stop()
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Manipulate realms and users
acc = Account()
await acc.set_token(acc_token)
realms = await acc.realms.list(selector="all")
for realm in realms:
print(realm.id, await realm.get_name(), await realm.metadata.get())
users = await realm.users.list()
for user in users:
print(user.id, await user.get_name(), await user.metadata.get())
realm = await acc.realms.get(22644)
user = await realm.users.get(90287)
await user.metadata.set_value("test-metadata-key", "123")
print(await user.metadata.get())
await user.metadata.delete_value("test-metadata-key")
print(await user.metadata.get())
await user.update_password("newpassword123456789")
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
flespi_sdk-0.1.3.tar.gz
(42.6 kB
view details)
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 flespi_sdk-0.1.3.tar.gz.
File metadata
- Download URL: flespi_sdk-0.1.3.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
234bc86805d511a4f454d9da3c533cfb28dfd319996f1382e6dc821f1f55515f
|
|
| MD5 |
41464b2ba1b7328adcea6aaa95916543
|
|
| BLAKE2b-256 |
81e06715e2115eea40a5bd2e9ab8096f49ed1e8154013c7b8b413407f224244f
|
File details
Details for the file flespi_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: flespi_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1802e8eb4d54e8a610ab583d6f016c1fe04d2960ae4545c8f608e236a012c8b2
|
|
| MD5 |
9af543bb0154c83e5b90bd8e48152660
|
|
| BLAKE2b-256 |
27646ee1cf2b35fd21c795c3acedc0a3ca81d72d53fecc3ad6acfa25054de649
|