Skip to main content

A Python library for reading data from various electrical energy counters including Carlo Gavazzi, Contrel, Diris, Lovato, RedZ, and Schneider devices

Project description

Energy Counters Library

PyPI Python Wheel Status License: MIT Maintained

Downloads

Carlo Gavazzi Lovato Diris RedZ Contrel Schneider

A Python library for reading data from various electrical energy counters including Carlo Gavazzi, Contrel, Diris, Lovato, RedZ, and Schneider devices.

Features

  • Multiple Communication Protocols: Support for both Modbus RTU (serial) and Modbus TCP connections
  • Automatic Fallback: Intelligent switching between TCP and RTU when both are configured
  • Comprehensive Data Collection: Read voltage, current, power, energy, and frequency measurements
  • Easy Configuration: Simple dataclass-based configuration for counters and connections
  • Detailed Logging: Built-in logging for debugging and monitoring
  • Modern Python: Written for Python 3.8+ with type hints and dataclasses
  • Extensible Design: Easy to add support for new counter models

Installation

Install from PyPI:

pip install energy-counters

Or for development:

pip install -e .

Quick Start

Import the library

import energy_counters
from energy_counters.carlo_gavazzi import EM530DataCollector
from energy_counters.lovato import DMG210DataCollector
# ... other counters

Basic Usage Example

from energy_counters.carlo_gavazzi import (
    CounterConfiguration,
    ModbusTCPConfiguration,
    EM530DataCollector
)

# Configure the counter
counter_config = CounterConfiguration(
    counter_id=167,
    unit_id=100,
    counter_name="TestCounter",
    company_id="MyCompany"
)

# Configure Modbus TCP connection
tcp_config = ModbusTCPConfiguration(
    host="192.162.10.10",
    port=502
)

# Create collector and read data
collector = EM530DataCollector(counter_config, modbus_tcp_config=tcp_config)
if collector.connect():
    data = collector.collect_data()
    if data:
        print(f"Voltage L1: {data['voltageL1']}V")
        print(f"Current L1: {data['currentL1']}A")
        print(f"Active Power: {data['activePower']}kW")
    collector.disconnect()

For detailed usage examples and complete documentation for each counter, see the README files in their respective folders:

Supported Counters

Brand Model Status Modbus RTU Modbus TCP Features
Carlo Gavazzi EM530 Implemented Yes Yes Full energy monitoring, fallback support
Lovato DMG210 Implemented Yes Yes Complete energy data collection, dual communication
Lovato DMG800 Planned - - Module structure ready
Lovato DMG6 Implemented Yes Yes Complete energy data collection, dual communication
Contrel uD3h Implemented Yes Yes Complete energy monitoring, dual communication
Diris A10 Implemented Yes Yes Complete energy monitoring, THD analysis, dual communication
RedZ LKM144 Implemented Yes Yes Complete energy monitoring, dual communication
Schneider IEM3250 Planned - - Module structure ready
Schneider IEM3155 Planned - - Module structure ready

Implementation Status Legend

  • Implemented: Full functionality with comprehensive data collection
  • Planned: Module structure exists, implementation pending
  • Modbus RTU/TCP: Protocol supported
  • Fallback Support: Automatic failover between TCP and RTU connections

Requirements

  • Python 3.8+
  • pymodbus 3.0.0+
  • pyserial 3.5+

License

MIT License

Contributing

We welcome contributions to the Energy Counters Library! Whether you're fixing bugs, adding new counter support, improving documentation, or suggesting features, your help is appreciated.

Quick Start for Contributors

  1. Fork the repository and clone your fork
  2. Set up the development environment (see CONTRIBUTING.md)
  3. Create a feature branch for your changes
  4. Make your changes following our coding standards
  5. Test thoroughly with actual hardware when possible
  6. Submit a pull request with a clear description

What We Need Help With

  • New Counter Support: Implementing support for additional energy meter models
  • Documentation: Improving guides, examples, and API documentation
  • Testing: Adding test coverage and validation with different hardware
  • Bug Fixes: Fixing issues reported by the community
  • Performance: Optimizing data collection and communication efficiency

Detailed Guidelines

For comprehensive contribution guidelines, development setup, coding standards, and implementation patterns, please see our Contributing Guide.

Adding New Counter Support

We especially welcome contributions that add support for new energy counter models. Our library follows a consistent pattern that makes it straightforward to add new devices. Check the Counter Implementation Guidelines 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

energy_counters-1.2.5.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

energy_counters-1.2.5-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file energy_counters-1.2.5.tar.gz.

File metadata

  • Download URL: energy_counters-1.2.5.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for energy_counters-1.2.5.tar.gz
Algorithm Hash digest
SHA256 c0a1f4906bf7ce8f48836e77ec0bbe910770a2b5200e271ee8ae2c709cdab8ea
MD5 bb2736c662ab3f1ccb6b259fda44f4f3
BLAKE2b-256 78955d12e50517f82a56f089425a6b5e6f3c1c84e27e8639e04540c967f699d9

See more details on using hashes here.

File details

Details for the file energy_counters-1.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for energy_counters-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1dcfc9b4505bb3eee5afa957073b89dd6de73eaaa02434533e4ff6d40bd525f8
MD5 bd5d320446ba49428d812614c21209ec
BLAKE2b-256 6c77e8bf6605e41454bffb51730b8a1af41a59c4506b3b47d5033198f761f892

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