This project replicates a Smart Meter device for a B2500 energy storage system while allowing integration with various smart meters.
Python Installation: Make sure you have Python 3.7 or higher installed. You can download it from the official Python website.
Configuration: Create a config.ini
file in the root directory of the project and add the appropriate configuration as described in the Configuration section.
Open Command Prompt
Win + R
, type cmd
, and hit Enter.Navigate to the Project Directory
cd path\to\b2500-meter
Install Dependencies
pipenv install
Run the Script
pipenv run python main.py
Open Terminal
Cmd + Space
, type Terminal
, and hit Enter.Navigate to the Project Directory
cd path/to/b2500-meter
Install Dependencies
pipenv install
Run the Script
pipenv run python main.py
Install Dependencies
pipenv install
Run the Script
pipenv run python main.py
When the script is running, switch your B2500 to "Self-Adaptation" mode to enable the powermeter functionality.
The configuration is managed using an ini
file called config.ini
. Below, you'll find the configuration settings required for each supported powermeter type.
Optionally add a general section with the option to enable or disable summation of phase values.
[GENERAL]
# By default, the script will sum the power values of all phases and report them as a single value on phase 1. To disable this behavior, add the following configuration to the `config.ini` file
DISABLE_SUM_PHASES = False
# Setting this to true, disables the powermeter test at the beginning of the script.
SKIP_POWERMETER_TEST = False
# By default, the script sends an absolute value of the measured power. This seems to be necessary for the storage system, since it can't handle negative values (results in an integer overflow). Set this to true to clamp the values to 0 instead of sending the absolute value.
DISABLE_ABSOLUTE_VALUES = False
# Sets the interval at which the script sends new power values to the B2500 in seconds. The original Smart Meter sends new values every second.
POLL_INTERVAL = 1
[SHELLY]
TYPE = 1PM
IP = 192.168.1.100
USER = username
PASS = password
METER_INDEX = meter1
[SHELLY]
TYPE = PLUS1PM
IP = 192.168.1.100
USER = username
PASS = password
METER_INDEX = meter1
[SHELLY]
TYPE = EM
IP = 192.168.1.100
USER = username
PASS = password
METER_INDEX = meter1
[SHELLY]
TYPE = 3EM
IP = 192.168.1.100
USER = username
PASS = password
METER_INDEX = meter1
[SHELLY]
TYPE = 3EMPro
IP = 192.168.1.100
USER = username
PASS = password
METER_INDEX = meter1
[TASMOTA]
IP = 192.168.1.101
USER = tasmota_user
PASS = tasmota_pass
JSON_STATUS = StatusSNS
JSON_PAYLOAD_MQTT_PREFIX = SML
JSON_POWER_MQTT_LABEL = Power
JSON_POWER_INPUT_MQTT_LABEL = Power1
JSON_POWER_OUTPUT_MQTT_LABEL = Power2
JSON_POWER_CALCULATE = True
[SHRDZM]
IP = 192.168.1.102
USER = shrdzm_user
PASS = shrdzm_pass
[EMLOG]
IP = 192.168.1.103
METER_INDEX = 0
JSON_POWER_CALCULATE = True
[IOBROKER]
IP = 192.168.1.104
PORT = 8087
CURRENT_POWER_ALIAS = Alias.0.power
POWER_CALCULATE = True
POWER_INPUT_ALIAS = Alias.0.power_in
POWER_OUTPUT_ALIAS = Alias.0.power_out
[HOMEASSISTANT]
IP = 192.168.1.105
PORT = 8123
HTTPS = True
ACCESSTOKEN = YOUR_ACCESS_TOKEN
CURRENT_POWER_ENTITY = sensor.current_power
POWER_CALCULATE = True
POWER_INPUT_ALIAS = sensor.power_input
POWER_OUTPUT_ALIAS = sensor.power_output
[VZLOGGER]
IP = 192.168.1.106
PORT = 8080
UUID = your-uuid
[ESPHOME]
IP = 192.168.1.107
PORT = 6052
DOMAIN = your_domain
ID = your_id
[AMIS_READER]
IP = 192.168.1.108
[MODBUS]
HOST = 192.168.1.100
PORT = 502
UNIT_ID = 1
ADDRESS = 0
COUNT = 1
[MQTT]
BROKER = broker.example.com
PORT = 1883
TOPIC = home/powermeter
JSON_PATH = $.path.to.value (Optional for JSON payloads)
USERNAME = mqtt_user (Optional)
PASSWORD = mqtt_pass (Optional)
The JSON_PATH
option is used to extract the power value from a JSON payload. The path must be a valid JSONPath expression.
If the payload is a simple integer value, you can omit this option.
[MODBUS]
IP =
PORT =
UNIT_ID =
REGISTER =
You can also use a custom script to get the power values. The script should output at most 3 integer values, separated by a line break.
[SCRIPT]
COMMAND = /path/to/your/script.sh
Before installing the B2500 Meter add-on, you need to access the directory where Home Assistant looks for local add-ons. You can do this using either the Samba or SSH add-ons:
This "addons" folder is where you should store your custom add-ons.
Tip for macOS users: If the folder doesn't show up automatically, go to Finder, press CMD+K, and enter smb://homeassistant.local
/addons
directory.Once you have access to the add-ons directory, follow these steps to install the B2500 Meter add-on:
Copy the add-on files
ha_addon
folder from this repository into the addons
directory you accessed via Samba or SSH./addons/ha_addon/
b2500_meter
Install and run the add-on
Configure the add-on
Power Input Alias
and optionally the Power Output Alias
to the entity IDs of your power sensors in Home Assistant.Start the add-on
The B2500 Meter add-on will now run as a Home Assistant service, integrating with your existing smart meter setup.
This project also provides a Node-RED implementation, allowing integration with various smart meters. The Node-RED flow is available in the nodered.json
file.
Import the Node-RED Flow
nodered.json
and paste it into the import dialog, then click "Import".Hooking Powermeter Readings
[100, 200, 300]
.Running the Flow
This project is licensed under the General Public License v3.0 - see the LICENSE file for details.