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

Quick Start

Installation

pip install iometer

Basic Usage

from iometer import IOmeterClient

async def check_meter_reading():
    async with IOmeterClient("192.168.1.100") as client:
        # Get current reading
        reading = await client.get_current_reading()
        
        # Access basic metrics
        consumption = reading.get_total_consumption()
        production = reading.get_total_production()
        power = reading.get_current_power()
        
        print(f"Meter: {reading.meter.number}")
        print(f"Time: {reading.meter.reading.time}")
        print(f"Consumption: {consumption} Wh")
        print(f"Production: {production} Wh")
        print(f"Current Power: {power} W")

Continuous Monitoring

import asyncio
from iometer import IOmeterClient

async def monitor_readings(interval: int = 300):
    """Monitor readings every 5 minutes."""
    async with IOmeterClient("192.168.1.100") as client:
        while True:
            try:
                reading = await client.get_current_reading()
                print(f"Time: {reading.meter.reading.time}")
                print(f"Consumption: {reading.get_total_consumption()} Wh")
                await asyncio.sleep(interval)
            except Exception as e:
                print(f"Error: {e}")
                await asyncio.sleep(60)  # Wait before retry

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-0.1.0.tar.gz (5.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-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iometer-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.3 Linux/6.8.0-1017-azure

File hashes

Hashes for iometer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd08ad3250e9384bb34c661533fcc2ee4ae36904a4f75f4e6510e571bca3aba8
MD5 d2e1fb4e05b0e080dcf5f41f8a6c4698
BLAKE2b-256 24eb0d256836a8fbc90d6cbd0a2312167be7936f4d51be3f281e4d5d3e6039e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: iometer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.3 Linux/6.8.0-1017-azure

File hashes

Hashes for iometer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f87add0d32380849fdca09a7bdd28582434e2be3cb09fe192001f6f0490fa6f
MD5 8332209b73b8b26b7695c5ad7dfca6d8
BLAKE2b-256 ab5d39d2aed939f8e76c41d71c0ea8a587c5586ed8b42a537e64311aab8a2baa

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