Skip to main content

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.2.1.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flespi_sdk-0.2.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file flespi_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: flespi_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for flespi_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 973a56525d578af84940362ec1747d470f50ce7b5ac0cb7ccccba9ae3e4f664e
MD5 5c7678abc1a1cd383e23574ef71f2bff
BLAKE2b-256 59f521cc81507b758cd2dd80c63b4fe7c515d35929df32c6fa05cf61bed2adc7

See more details on using hashes here.

File details

Details for the file flespi_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: flespi_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for flespi_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d98c4c689f7f16280879488c6358abaac7094ca865e858b8ff398f3718b43f85
MD5 e4399b358e1447f731c2130e69a95136
BLAKE2b-256 6f052d225095a7064f616bc643e73775ca1515066800a183431bb4595afde7e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page