Skip to content

Commit ed63bb0

Browse files
committed
Add support for new B2500 port 2220 for Shelly Pro 3EM
- Added support for Shelly Pro 3EM on port 2220 (B2500 firmware v226+) - Added backward compatibility through shellypro3em_old (port 1010) and shellypro3em_new (port 2220) - Updated README with detailed device type information and port explanations - Updated CHANGELOG.md with new 1.0.4 version info
1 parent 973b7aa commit ed63bb0

5 files changed

Lines changed: 37 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.0.4
4+
5+
### Added
6+
- Added support for Shelly Pro 3EM on port 2220 (B2500 firmware version >=226)
7+
- Added backward compatibility for Shelly Pro 3EM devices through shellypro3em_old (port 1010) and shellypro3em_new (port 2220) device types
8+
39
## 1.0.3
410

511
### Added

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
This project emulates Smart Meter devices for Marstek storage systems such as the B2500, Marstek Jupiter, and Marstek Venus energy storage systems while allowing integration with almost any smart meter. It does this by emulating one or more of the following devices:
44
- CT001
55
- Shelly Pro 3EM
6+
- Uses port 1010 (B2500 firmware up to version 224) and port 2220 (B2500 firmware version 226+)
7+
- Can be specifically targeted with shellypro3em_old (port 1010) or shellypro3em_new (port 2220)
68
- Shelly EM gen3
79
- Shelly Pro EM50
810

11+
**Note:** If your B2500 or Marstek storage system supports it, always prefer a Shelly device type over CT001 for better compatibility and reliability.
12+
913
## Getting Started
1014

1115
The B2500 Meter project can be installed and run in several ways depending on your needs and environment:
@@ -47,7 +51,15 @@ The B2500 Meter project can be installed and run in several ways depending on yo
4751
- Set the `Power Input Alias` to a comma-separated list of three entity IDs (one for each phase)
4852
- If using calculated power, also set the `Power Output Alias` to a comma-separated list of three entity IDs
4953
- Example: `sensor.phase1,sensor.phase2,sensor.phase3`
50-
- Set `Device Types` (comma-separated list) to the device types you want to emulate (ct001, shellypro3em, shellyemg3, shellyproem50)
54+
- Set `Device Types` (comma-separated list) to the device types you want to emulate:
55+
- `ct001`: CT001 emulator
56+
- `shellypro3em`: Shelly Pro 3EM emulator (uses both ports 1010 and 2220 for compatibility with all B2500 firmware versions)
57+
- `shellypro3em_old`: Shelly Pro 3EM emulator using port 1010 (for B2500 firmware up to v224)
58+
- `shellypro3em_new`: Shelly Pro 3EM emulator using port 2220 (for B2500 firmware v226+)
59+
- `shellyemg3`: Shelly EM gen3 emulator
60+
- `shellyproem50`: Shelly Pro EM50 emulator
61+
62+
**Important:** Always prefer a Shelly device type over CT001 if supported by your energy storage system.
5163
- Click "Save" to apply the configuration
5264

5365
B) Using a Custom Configuration File for Advanced Configuration:
@@ -118,7 +130,7 @@ Configuration is managed via `config.ini`. Each powermeter type has specific set
118130

119131
```ini
120132
[GENERAL]
121-
# Comma-separated list of device types to emulate (ct001, shellypro3em, shellyemg3, shellyproem50)
133+
# Comma-separated list of device types to emulate (ct001, shellypro3em, shellyemg3, shellyproem50, shellypro3em_old, shellypro3em_new)
122134
DEVICE_TYPE = ct001
123135
# Skip initial powermeter test on startup
124136
SKIP_POWERMETER_TEST = False

ha_addon/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ports:
2020
12345/tcp: 12345
2121
12345/udp: 12345
2222
1010/udp: 1010
23+
2220/udp: 2220
2324
2222/udp: 2222
2425
2223/udp: 2223
2526
map:
@@ -30,7 +31,7 @@ options:
3031
power_output_alias: ""
3132
poll_interval: 1
3233
disable_absolute_values: false
33-
device_types: "ct001"
34+
device_types: "shellypro3em"
3435
schema:
3536
power_input_alias: str
3637
power_output_alias: str?

ha_addon/translations/en.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ configuration:
1313
description: "If enabled, the ct001 emulator will allow negative values. This is only compatible with newer versions of the B2500 firmware. Ignore this if you are emulating a different device."
1414
device_types:
1515
name: Emulated Devices
16-
description: "Comma-separated list of devices to emulate (ct001, shellypro3em, shellyemg3, shellyproem50)."
16+
description: "Comma-separated list of devices to emulate (ct001, shellypro3em, shellyemg3, shellyproem50, shellypro3em_old, shellypro3em_new). The device type shellypro3em_old uses port 1010 (used up until B2500 firmware version 224). The device type shellypro3em_new uses the new port 2220 (used for B2500 firmare >=226). If you use shellypro3em, it will use shellypro3em_old and shellypro3em_new simultaneously for backwards compatibility. If possible, always prefer a Shelly device type over ct001."
1717
custom_config:
1818
name: Custom Config
1919
description: "Optional. Name of a custom config.ini file to use instead of the UI configuration. The file must be placed in the add-on's configuration directory."

main.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,16 @@ def update_readings(addr):
8484

8585
device.before_send = update_readings
8686

87-
elif device_type == "shellypro3em":
87+
elif device_type == "shellypro3em_old":
8888
print(f"Shelly Pro 3EM Settings:")
8989
print(f"Device ID: {device_id}")
9090
device = Shelly(powermeters=powermeters, device_id=device_id, udp_port=1010)
9191

92+
elif device_type == "shellypro3em_new":
93+
print(f"Shelly Pro 3EM Settings:")
94+
print(f"Device ID: {device_id}")
95+
device = Shelly(powermeters=powermeters, device_id=device_id, udp_port=2220)
96+
9297
elif device_type == "shellyemg3":
9398
print(f"Shelly EM Gen3 Settings:")
9499
print(f"Device ID: {device_id}")
@@ -119,7 +124,7 @@ def main():
119124
"-d",
120125
"--device-types",
121126
nargs="+",
122-
choices=["ct001", "shellypro3em", "shellyemg3", "shellyproem50"],
127+
choices=["ct001", "shellypro3em", "shellyemg3", "shellyproem50", "shellypro3em_old", "shellypro3em_new"],
123128
help="List of device types to emulate",
124129
)
125130
parser.add_argument("--device-ids", nargs="+", help="List of device IDs")
@@ -157,6 +162,13 @@ def main():
157162
else:
158163
device_ids.append(f"device-{len(device_ids) + 1}")
159164

165+
# For backward compatibility, replace shellypro3em with shellypro3em_old and shellypro3em_new
166+
if "shellypro3em" in device_types:
167+
shellypro3em_index = device_types.index("shellypro3em")
168+
device_types[shellypro3em_index] = "shellypro3em_old"
169+
device_types.append("shellypro3em_new")
170+
device_ids.append(device_ids[shellypro3em_index])
171+
160172
print(f"Device Types: {device_types}")
161173
print(f"Device IDs: {device_ids}")
162174
print(f"Skip Test: {skip_test}")

0 commit comments

Comments
 (0)