https://github.com/bossan/modbus-meter-emulator
Emulates an energy meter with modbus communication
https://github.com/bossan/modbus-meter-emulator
energy-management home-assistant modbus modbus-rtu solax solaxpower
Last synced: 3 months ago
JSON representation
Emulates an energy meter with modbus communication
- Host: GitHub
- URL: https://github.com/bossan/modbus-meter-emulator
- Owner: bossan
- License: mit
- Created: 2025-01-08T21:12:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-10T11:57:31.000Z (over 1 year ago)
- Last Synced: 2025-02-10T12:37:43.784Z (over 1 year ago)
- Topics: energy-management, home-assistant, modbus, modbus-rtu, solax, solaxpower
- Language: Python
- Homepage:
- Size: 81.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Modbus Meter Emulator
Emulates an energy meter with modbus communication to enable export control on your inverter.
The project is intended to be used with Home Assistant, but can be used with any other system that supports MQTT and Modbus.
> [!CAUTION]
> This project is in the early phases of development. Please use with caution.
> I am not responsible for any damage caused by using this project.
## Installation
The current version uses [Poetry](https://python-poetry.org).
Install the project and dependencies with:
```bash
poetry install
```
## Configuration
Example:
```yaml
mqtt:
broker:
host: homeassistant.local
port: 1883
username: ha-user
password: password
keepalive: 60
modbus:
port: "/dev/ttyUSB0"
baudrate: 9600
bytesize: 8
parity: N
stopbits: 1
meter:
type: solax
config:
current_power_state_topic: "homeassistant/sensor/p1_meter_power/state"
energy_import_state_topic: "homeassistant/sensor/p1_meter_energy_import/state"
energy_export_state_topic: "homeassistant/sensor/p1_meter_energy_export/state"
```
## Usage
Run the project with:
```bash
poetry run meter
```
Possitional arguments:
- `config`: Path to the configuration file.
Options:
- `-v` or `--verbose`: Enable verbose logging.
- `-h` or `--help`: Show help message.
> [!NOTE]
> If you get a weird error like `'format'` when running the command above, this is most likely because of the version of Poetry you are using.
> This project was developed with Poetry 1.8 and does not yet work with Poetry 2.0.
> Try running the tool with `poetry run python -m modbus_meter_emulator `.
### Docker
This project is also available as a docker image.
#### Pull
```bash
docker pull ghcr.io/bossan/modbus-meter-emulator
```
#### Run
```commandline
docker run -v ./config.yaml:/etc/modbus-meter/config.yaml ghcr.io/bossan/modbus-meter-emulator
```
Where `./config.yaml` should be replaced with the location of your config file.
## Supported Inverters
| Brand | Model | Tested | Notes |
|-------|-----------|--------------------|----------------------------------------------------------------------------|
| Solax | X3 MIC G2 | :white_check_mark: | Current import/export is working, still need to validate the other values. |
## Credits
Used the following repo's for inspiration:
- [syssi/esphome-solax-x1-mini](https://github.com/syssi/esphome-solax-x1-mini/).
- [wills106/homeassistant-solax-modbus](https://github.com/wills106/homeassistant-solax-modbus)
- [straga/Smart-Meter-Gateway](https://github.com/straga/Smart-Meter-Gateway)
And huge thanks
to [raenji-sk/Solax-X3-MIC-G2-Virtual-Smart-Meter](https://github.com/raenji-sk/Solax-X3-MIC-G2-Virtual-Smart-Meter) for
basically sorting out all the used addresses, so I don't have to.