Async library for discovering and fetching data from Altruist sensors
Project description
AltruistClient
Python async library for discovering and communicating with Altruist ESP32-based sensors over the local network using mDNS (zeroconf) and HTTP.
Features
- Discover sensors on your LAN using Zeroconf (
_altruist._tcp.local.) - Fetch sensor metadata and measurement data from
/data.json - Filter supported sensor names
- Async/AIOHTTP-based for fast, non-blocking usage
Installation
pip install atruistclient
Quick Start
import asyncio
from aiohttp import ClientSession
from zeroconf.asyncio import AsyncZeroconf
from altruistclient import AltruistDiscoverer, AltruistClient
async def main():
async with AsyncZeroconf() as zc, ClientSession() as session:
discoverer = AltruistDiscoverer(zc, session)
devices = await discoverer.get_devices()
for device in devices:
client = AltruistClient(session, device)
data = await client.fetch_data()
print(f"Device {client.device_id} (fw: {client.fw_version})")
print("Sensor names:", client.sensor_names)
print("Data:", data)
asyncio.run(main())
Class Overview
AltruistDiscoverer
- Scans for
_altruist._tcp.local.devices using zeroconf. - Filters and validates devices via their
/data.jsonresponse. - Returns a list of
AltruistDeviceModelinstances.
discoverer = AltruistDiscoverer(zc, session)
devices = await discoverer.get_devices()
AltruistClient
- Handles data fetching and parsing from a specific device.
- Extracts firmware version, sensor types, and measurements.
client = AltruistClient(session, device)
data = await client.fetch_data()
print(client.fw_version, client.sensor_names)
You can also construct it directly from an IP:
client = await AltruistClient.from_ip_address(session, "192.168.1.45")
AltruistDeviceModel
Simple dataclass containing:
id: sensor ID (from/data.json)ip_address: resolved IPfw_version: firmware version (optional)
@dataclass
class AltruistDeviceModel:
id: str
ip_address: str
name: str = "Altruist Sensor"
fw_version: str | None = None
Notes
get_devices()waits 5 seconds for mDNS discovery.- Only devices that respond to
/data.jsonand provide a validsensor_idare returned. - Internally uses
aiohttp.
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
altruistclient-0.1.1.tar.gz
(7.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 altruistclient-0.1.1.tar.gz.
File metadata
- Download URL: altruistclient-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.9.22 Linux/6.11.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4f786bcebaf42c411ef1ddb1a226f935b38147c4ff9275ed3622e37ca2a49a1
|
|
| MD5 |
9507057b6eb51afb01db3c8332e3df30
|
|
| BLAKE2b-256 |
a5531cf3fb9b54b58ce0cd8108d1baa86f413447a62b689d6672c11e94e24445
|
File details
Details for the file altruistclient-0.1.1-py3-none-any.whl.
File metadata
- Download URL: altruistclient-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.9.22 Linux/6.11.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b20af47c3a350ac55187d46ed3ddd3df5bf39cb16a595bab9697a07d80723686
|
|
| MD5 |
d1b5687de481acf891554494310d1a23
|
|
| BLAKE2b-256 |
43e0202e6b791620505f15449ddde9d5490ed05d163ee96f1e01334ac0b5fab0
|