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
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 iometer-0.4.0.tar.gz.
File metadata
- Download URL: iometer-0.4.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ea2a2e09bc9293df8566c6e72961135028a1cf31622a48b1b799335e9594737
|
|
| MD5 |
6401ac192d2e5f2be84ece64b0cf1720
|
|
| BLAKE2b-256 |
bf6bca113a67d3acc172030fb06097a470fefba9ff5e543aa2ab933e1d91324a
|
File details
Details for the file iometer-0.4.0-py3-none-any.whl.
File metadata
- Download URL: iometer-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
252eac5b2d975ec5cc408fddd09ade86064c52cfd7ee0c8c91eea22eb3ce681b
|
|
| MD5 |
17de89b5169549b35c3f66d791f1609e
|
|
| BLAKE2b-256 |
9a1d5630c8bb19d9cb8168fae5abaa5956498084b65ae66638eb21fbb6910e23
|