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.
The current version uses Poetry. Install the project and dependencies with:
poetry install
Example:
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"
Run the project with:
poetry run meter <path-to-config-yaml>
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 <path-to-config-yaml>
.
Brand | Model | Tested | Notes |
---|---|---|---|
Solax | X3 MIC G2 | ✅ | Current import/export is working, still need to validate the other values. |
Used the following repo's for inspiration:
And huge thanks to raenji-sk/Solax-X3-MIC-G2-Virtual-Smart-Meter for basically sorting out all the used addresses, so I don't have to.