Fostrom Device SDK
Project description
Fostrom Device SDK for Python
Fostrom is an IoT Cloud Platform built for developers. Monitor and control your fleet of devices, from microcontrollers to industrial IoT. Designed to be simple, secure, and fast. Experience first-class tooling with Device SDKs, type-safe schemas, programmable actions, and more.
The Fostrom Device SDK for Python works with Python 3.10+ and helps you quickly integrate, start monitoring, and controlling your IoT devices in just a few lines of code.
Installation
pip install fostrom
Quick Start
from fostrom import Fostrom, Mail
# Create SDK instance
fostrom = Fostrom({
"fleet_id": "<your-fleet-id>",
"device_id": "<your-device-id>",
"device_secret": "<your-device-secret>",
"env": "<dev|test|prod>",
})
# Setup mail handler for incoming messages
def handle_mail(mail: Mail):
print(f"Received: {mail.name} ({mail.id})")
mail.ack() # Acknowledge the message
fostrom.on_mail = handle_mail
# Start the Device Agent and event stream
fostrom.start()
# Send sensor data
fostrom.send_datapoint("sensors", {
"temperature": 23.5,
"humidity": 65,
})
# Send status messages
fostrom.send_msg("status", {"online": True})
API Reference
Fostrom Class
__init__(config)
Create a new Fostrom instance.
Parameters:
config(dict): Configuration dictionary with:fleet_id(str): Your fleet IDdevice_id(str): Your device IDdevice_secret(str): Your device secretlog(bool, default: True): Enable logging (default: True)env(str, default: PYTHON_ENV || "dev"): Runtime Environmentstop_agent_on_exit(bool, default: False): If True,shutdown()will stop the Device Agent too.
start() -> None
Start the Device Agent in the background and connect to it.
shutdown(stop_agent: bool = False) -> None
Stop the background event processing. If stop_agent=True, also stops the Device Agent.
send_datapoint(name: str, payload: dict) -> None
Send a datapoint to Fostrom.
send_msg(name: str, payload: dict | None) -> None
Send a message to Fostrom. Pass None if the schema has no payload.
mailbox_status() -> dict
Get current mailbox status.
next_mail() -> Mail | None
Get the next mail from the mailbox.
Mail Class
Properties
id(str): Mail IDname(str): Mail name/typepayload(dict): Mail payload datamailbox_size(int): Current mailbox size
Methods
ack(): Acknowledge the mailreject(): Reject the mailrequeue(): Requeue the mail
Device Agent
The Fostrom Device SDK downloads and runs the Fostrom Device Agent in the background. The Device Agent is downloaded automatically when the package is installed. The Device Agent starts when fostrom.start() is called and handles all communication with the Fostrom platform. The Device Agent runs continuously in the background, even after your Python program has terminated, to ensure that when your process manager restarts your Python program, it connects to the Device Agent right away. In case you want to stop the Device Agent when your program terminates, you can pass stop_agent_on_exit: True to the config.
Logging
The SDK logs via Python's logging module using the fostrom logger. By default, WARNING/ERROR/CRITICAL are visible; INFO is not.
To see INFO messages (e.g., "Connected"), enable logging:
import logging
logging.basicConfig(level=logging.INFO)
Links
- Fostrom Platform: https://fostrom.io
- Documentation: https://docs.fostrom.io/sdk/py
- Python SDK: https://pypi.org/project/fostrom/
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
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 fostrom-0.0.15.tar.gz.
File metadata
- Download URL: fostrom-0.0.15.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3b08b680e563464eb73df68b5bae768daf77b9ee15b1148c4c06b6c9f4ee02
|
|
| MD5 |
6fd76ef513a762ecfa7ce3a9ea185f2a
|
|
| BLAKE2b-256 |
7d1d25b2087dbd0d2ff2da285e4e8cc34ba56be6e94b63a328e1ab78e7c7f6e6
|
File details
Details for the file fostrom-0.0.15-py3-none-any.whl.
File metadata
- Download URL: fostrom-0.0.15-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef1bc49b9814028bcd7e9b01a6ebf2a73d2318b98fb1b4a4d5df07393783861d
|
|
| MD5 |
7f502d5f359e93bd7044b9a23dca6dbf
|
|
| BLAKE2b-256 |
cc1bf935c75b0ac7e0a7c04be0929d6aeaef3de38298e02097e7c5db917dedfa
|