Skip to main content

Asynchronous Python client for IOmeter

Project description

IOmeter Python Client

A Python client for interacting with IOmeter devices over HTTP. This client provides an async interface for reading energy consumption/production data and monitoring device status.

Features

  • 🔌 Asynchronous communication with IOmeter bridge over HTTP
  • 📊 Read energy consumption and energy production data
  • 🔋 Monitor device status including battery level and signal strength
  • 🔄 Two transport modes: polling (IOmeterClient) and Server-Sent Events (IOmeterSSEClient)

Quick Start

Installation

pip install iometer

Polling

Use IOmeterClient to fetch readings on demand:

from iometer import IOmeterClient

async def check_meter_reading():
    async with IOmeterClient("192.168.1.100") as client:
        reading = await client.get_current_reading()
        print(f"Consumption: {reading.get_total_consumption()} Wh")
        print(f"Production: {reading.get_total_production()} Wh")
        print(f"Current Power: {reading.get_current_power()} W")

Server-Sent Events (SSE)

Use IOmeterSSEClient to receive readings as they arrive (push-based):

from iometer import IOmeterSSEClient
from aiohttp import ClientSession

async def stream_readings():
    async with ClientSession() as session:
        client = IOmeterSSEClient("192.168.1.100", session=session)
        async for reading in client.watch_readings():
            print(f"Consumption: {reading.get_total_consumption()} Wh")
            print(f"Current Power: {reading.get_current_power()} W")

Device Status Information

from iometer import IOmeterClient

async def check_device_status():
    async with IOmeterClient("192.168.1.100") as client:
        # Get current status
        status = await client.get_current_status()
        
        # Bridge information
        print(f"Bridge Version: {status.device.bridge.version}")
        print(f"Bridge Signal: {status.device.bridge.rssi} dBm")
        
        # Core information
        core = status.device.core
        print(f"Connection: {core.connection_status}")
        print(f"Power Mode: {core.power_status}")
        
        if core.power_status.value == "battery":
            print(f"Battery Level: {core.battery_level}%")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Setting up a dev environment

We use Poetry for dependency management and testing. Install everything with:

poetry install

To run the Python tests use:

poetry run pytest tests/test.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

iometer-1.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

iometer-1.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file iometer-1.0.1.tar.gz.

File metadata

  • Download URL: iometer-1.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1013-azure

File hashes

Hashes for iometer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 401807a1413cd63579ae117ebe2860d957ff5db6b34790e4b7ccba2ce2d1e6d4
MD5 8d546eb799154aca0dac7183d7ee8610
BLAKE2b-256 3f8b23464bbb15a9025ca492df3a9359e5eef8e8bc97cab66497776cccce9aa4

See more details on using hashes here.

File details

Details for the file iometer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: iometer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1013-azure

File hashes

Hashes for iometer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77aa0f63c51ca3c9700e4d0d58b8710d3cd67bef2efeb27b6abc0dcf1a043025
MD5 94b468436b3333507a6fa24380211e4c
BLAKE2b-256 39bdbdf30be9f53b213711e36c0930d109fac3d865f2db0b3c53ab1efb420152

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