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

Uploaded Python 3

File details

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

File metadata

  • Download URL: energy_counters-1.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 16bcbe329b1c4b1c83f7b456b4a974282baaa16936e77d808c51fc4002d4697d
MD5 9c4945245b8ca34bdd73ee15a1244ea6
BLAKE2b-256 a3baf262ab7524e4e68fc17a2b52c2ea2a3a85b3f284ac5f0318538b856f0c7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for energy_counters-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d39c3d88c9ff93b5d993b02e242b851e60513aa5697c31d9a5e7edafe0f57c3d
MD5 2ac6d264753f65e73807cf2806ca5476
BLAKE2b-256 937dea82eb5a25f49f5aa4c91565e3d98d2d4433c36b30208a147cc755e9ad9f

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