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 Yes Yes Module structure ready
Schneider IEM3155 Planned Yes Yes 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.3.0.tar.gz (23.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.3.0-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: energy_counters-1.3.0.tar.gz
  • Upload date:
  • Size: 23.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.3.0.tar.gz
Algorithm Hash digest
SHA256 ad2db2d19fe0c296d4fc47f56a4eaff1ec843e8341670c95cb0aebe768653120
MD5 088273f01415f838d871bf9a87a82559
BLAKE2b-256 c33a1444302558a9e1cdd5c6bd911b1fb9368602af9b0118e8bed1c2bdb3e6c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for energy_counters-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c50cbfebb083d955ea29587a80e57641af359078ec01b99d05a159788505dbfa
MD5 e911572e04ac18e425f98447d534e2a2
BLAKE2b-256 3a190ef9affd03ed34a4504f4b71f91237c5b25d57d5e4bd326492ce3abe3f7a

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