Skip to main content

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.json response.
  • Returns a list of AltruistDeviceModel instances.
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 IP
  • fw_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.json and provide a valid sensor_id are returned.
  • Internally uses aiohttp.

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)

Uploaded Source

Built Distribution

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

altruistclient-0.1.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

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

Hashes for altruistclient-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4f786bcebaf42c411ef1ddb1a226f935b38147c4ff9275ed3622e37ca2a49a1
MD5 9507057b6eb51afb01db3c8332e3df30
BLAKE2b-256 a5531cf3fb9b54b58ce0cd8108d1baa86f413447a62b689d6672c11e94e24445

See more details on using hashes here.

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

Hashes for altruistclient-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b20af47c3a350ac55187d46ed3ddd3df5bf39cb16a595bab9697a07d80723686
MD5 d1b5687de481acf891554494310d1a23
BLAKE2b-256 43e0202e6b791620505f15449ddde9d5490ed05d163ee96f1e01334ac0b5fab0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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