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.2.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.2-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: energy_counters-1.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 fbfa1049041e8e2a56ecbdf667f6a4fcefaa0833dd3bfcb25c3e6197a4769bd4
MD5 793372f0a7984f71a90d00a07319bd86
BLAKE2b-256 353f49404db94550ea97d8a253b1f5e5b414a7558500784d60a236f9f618c874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for energy_counters-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3a636333fcfa09d9ed330b589f2a764196161c661af70f557d3ef6ba50f197
MD5 cfcf0b890809b4a68aac5a942667fca4
BLAKE2b-256 751443cc99967ee989384a3ab2cd8c3c5f02c9a4d5c220dc1cad38f77833b1cc

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