# Energy Counters Library
[](https://pypi.org/project/energy-counters/)
[](https://pypi.org/project/energy-counters/)
[](https://pypi.org/project/energy-counters/)
[](https://pypi.org/project/energy-counters/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/nobrega8/energy-counters)
[](https://pepy.tech/project/energy-counters)






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](https://pypi.org/project/energy-counters/):
```bash
pip install energy-counters
```
Or for development:
```bash
pip install -e .
```
## Quick Start
### Import the library
```python
import energy_counters
from energy_counters.carlo_gavazzi import EM530DataCollector
from energy_counters.lovato import DMG210DataCollector
# ... other counters
```
### Basic Usage Example
```python
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:
- [Carlo Gavazzi Counters](src/energy_counters/carlo_gavazzi/README.md)
- [Lovato Counters](src/energy_counters/lovato/README.md)
- [Diris Counters](src/energy_counters/diris/README.md)
- [RedZ Counters](src/energy_counters/redz/README.md)
- [Contrel Counters](src/energy_counters/contrel/README.md)
- [Schneider Counters](src/energy_counters/schneider/README.md)
## 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
Contributions are welcome! Please feel free to submit a Pull Request.
Raw data
{
"_id": null,
"home_page": "https://github.com/nobrega8/energy-counters",
"name": "energy-counters",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "energy, modbus, counters, carlo gavazzi, electrical, lovato, schneider, python",
"author": "nobrega8",
"author_email": "nobrega8 <afonsognobrega@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8d/90/f73bace34af17ce7f53c7e2dd15c48a91f67188214c1fe6012a8269c8014/energy_counters-1.2.1.tar.gz",
"platform": null,
"description": "# Energy Counters Library\n\n[](https://pypi.org/project/energy-counters/)\n[](https://pypi.org/project/energy-counters/)\n[](https://pypi.org/project/energy-counters/)\n[](https://pypi.org/project/energy-counters/)\n[](https://opensource.org/licenses/MIT)\n[](https://github.com/nobrega8/energy-counters)\n\n[](https://pepy.tech/project/energy-counters)\n\n\n\n\n\n\n\n\nA Python library for reading data from various electrical energy counters including Carlo Gavazzi, Contrel, Diris, Lovato, RedZ, and Schneider devices.\n\n## Features\n\n- **Multiple Communication Protocols**: Support for both Modbus RTU (serial) and Modbus TCP connections\n- **Automatic Fallback**: Intelligent switching between TCP and RTU when both are configured\n- **Comprehensive Data Collection**: Read voltage, current, power, energy, and frequency measurements\n- **Easy Configuration**: Simple dataclass-based configuration for counters and connections\n- **Detailed Logging**: Built-in logging for debugging and monitoring\n- **Modern Python**: Written for Python 3.8+ with type hints and dataclasses\n- **Extensible Design**: Easy to add support for new counter models\n\n## Installation\n\nInstall from [PyPI](https://pypi.org/project/energy-counters/):\n\n```bash\npip install energy-counters\n```\n\nOr for development:\n```bash\npip install -e .\n```\n\n## Quick Start\n\n### Import the library\n\n```python\nimport energy_counters\nfrom energy_counters.carlo_gavazzi import EM530DataCollector\nfrom energy_counters.lovato import DMG210DataCollector\n# ... other counters\n```\n\n### Basic Usage Example\n\n```python\nfrom energy_counters.carlo_gavazzi import (\n CounterConfiguration,\n ModbusTCPConfiguration,\n EM530DataCollector\n)\n\n# Configure the counter\ncounter_config = CounterConfiguration(\n counter_id=167,\n unit_id=100,\n counter_name=\"TestCounter\",\n company_id=\"MyCompany\"\n)\n\n# Configure Modbus TCP connection\ntcp_config = ModbusTCPConfiguration(\n host=\"192.162.10.10\",\n port=502\n)\n\n# Create collector and read data\ncollector = EM530DataCollector(counter_config, modbus_tcp_config=tcp_config)\nif collector.connect():\n data = collector.collect_data()\n if data:\n print(f\"Voltage L1: {data['voltageL1']}V\")\n print(f\"Current L1: {data['currentL1']}A\")\n print(f\"Active Power: {data['activePower']}kW\")\n collector.disconnect()\n```\n\nFor detailed usage examples and complete documentation for each counter, see the README files in their respective folders:\n- [Carlo Gavazzi Counters](src/energy_counters/carlo_gavazzi/README.md)\n- [Lovato Counters](src/energy_counters/lovato/README.md)\n- [Diris Counters](src/energy_counters/diris/README.md)\n- [RedZ Counters](src/energy_counters/redz/README.md)\n- [Contrel Counters](src/energy_counters/contrel/README.md)\n- [Schneider Counters](src/energy_counters/schneider/README.md)\n\n## Supported Counters\n\n| Brand | Model | Status | Modbus RTU | Modbus TCP | Features |\n|-------|-------|--------|------------|------------|----------|\n| **Carlo Gavazzi** | EM530 | **Implemented** | Yes | Yes | Full energy monitoring, fallback support |\n| **Lovato** | DMG210 | **Implemented** | Yes | Yes | Complete energy data collection, dual communication |\n| **Lovato** | DMG800 | **Planned** | - | - | Module structure ready |\n| **Lovato** | DMG6 | **Implemented** | Yes | Yes | Complete energy data collection, dual communication |\n| **Contrel** | uD3h | **Implemented** | Yes | Yes | Complete energy monitoring, dual communication |\n| **Diris** | A10 | **Implemented** | Yes | Yes | Complete energy monitoring, THD analysis, dual communication |\n| **RedZ** | LKM144 | **Implemented** | Yes | Yes | Complete energy monitoring, dual communication |\n| **Schneider** | IEM3250 | **Planned** | - | - | Module structure ready |\n| **Schneider** | IEM3155 | **Planned** | - | - | Module structure ready |\n\n### Implementation Status Legend\n- **Implemented**: Full functionality with comprehensive data collection\n- **Planned**: Module structure exists, implementation pending\n- **Modbus RTU/TCP**: Protocol supported\n- **Fallback Support**: Automatic failover between TCP and RTU connections\n\n## Requirements\n\n- Python 3.8+\n- pymodbus 3.0.0+\n- pyserial 3.5+\n\n## License\n\nMIT License\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for reading data from various electrical energy counters including Carlo Gavazzi, Contrel, Diris, Lovato, RedZ, and Schneider devices",
"version": "1.2.1",
"project_urls": {
"Bug Tracker": "https://github.com/nobrega8/energy-counters/issues",
"Homepage": "https://github.com/nobrega8/energy-counters"
},
"split_keywords": [
"energy",
" modbus",
" counters",
" carlo gavazzi",
" electrical",
" lovato",
" schneider",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "be41f6873b4d5d884ccc953d7f5db5f56cc91722c4e67c445fb2682e9f84a55e",
"md5": "348f5bf99c88c7122864eb5a7d751130",
"sha256": "bc3976e2d82bcacd7cd6c43c61abba23fef63e59b2e7fbc0aaa50d80209a5fc9"
},
"downloads": -1,
"filename": "energy_counters-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "348f5bf99c88c7122864eb5a7d751130",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 31278,
"upload_time": "2025-08-14T13:50:04",
"upload_time_iso_8601": "2025-08-14T13:50:04.683417Z",
"url": "https://files.pythonhosted.org/packages/be/41/f6873b4d5d884ccc953d7f5db5f56cc91722c4e67c445fb2682e9f84a55e/energy_counters-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8d90f73bace34af17ce7f53c7e2dd15c48a91f67188214c1fe6012a8269c8014",
"md5": "7386df1f07888358d586f65e3444f990",
"sha256": "d17cd240a92758c2997f0734d928c3ebe7de6341b9e8a014085b2e405057d92c"
},
"downloads": -1,
"filename": "energy_counters-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "7386df1f07888358d586f65e3444f990",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 15525,
"upload_time": "2025-08-14T13:50:05",
"upload_time_iso_8601": "2025-08-14T13:50:05.833526Z",
"url": "https://files.pythonhosted.org/packages/8d/90/f73bace34af17ce7f53c7e2dd15c48a91f67188214c1fe6012a8269c8014/energy_counters-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-14 13:50:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nobrega8",
"github_project": "energy-counters",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pymodbus",
"specs": [
[
">=",
"3.0.0"
]
]
},
{
"name": "pyserial",
"specs": [
[
">=",
"3.5"
]
]
}
],
"lcname": "energy-counters"
}