Skip to content

Conversation

@rkapsi
Copy link

@rkapsi rkapsi commented Sep 1, 2024

Disclaimer: This PR is based on @Jalle19 work and he helped me to make it ultimately work. All glory goes to him!

This PR should add generic support for all Shelly Modbus EMs to dbus-modbus-client 1.58+ using just the dbus-modbus-client's own API. There is no custom code other than just defining the device. It's only a matter of enumerating them.

Screenshot from 2024-09-01 11-30-00
Screenshot from 2024-09-01 11-28-48
Screenshot from 2024-09-01 11-29-08
Screenshot from 2024-09-01 11-29-23

@Dennis-LB
Copy link

@rkapsi Guide how to connect the Shelly Pro 3EM ?

@rkapsi
Copy link
Author

rkapsi commented Sep 12, 2024

On your Cerbo GX go to Settings -> Modbus TCP/UDP devices -> Saved devices and enter your Shelly's IP. It will immediately show up under Settings -> Device list.

@Dennis-LB
Copy link

Dennis-LB commented Sep 12, 2024

@rkapsi Can't get it to work... have now tried 3.42 (latest release) and ran this --> #4 (comment)
But still nothing... might need to downgrade to 3.40 or .41 ... if possible

image

image

image

@rkapsi
Copy link
Author

rkapsi commented Sep 12, 2024

I'm sorry if this stuff is confusing but this PR only works with 3.50 and later (current beta).

@Dennis-LB
Copy link

Dennis-LB commented Sep 30, 2024

@rkapsi

I'm sorry if this stuff is confusing but this PR only works with 3.50 and later (current beta).

Well... got it working on 3.41, but not on 3.50

@Jalle19
Copy link

Jalle19 commented Sep 30, 2024

If Victron would show some interest in merging this then maybe we wouldn't have to provide user support for years on end.

@rkapsi
Copy link
Author

rkapsi commented Sep 30, 2024

@Dennis-LB very cool. It appears dbus-modbus-client 1.58 has been backported to Venus OS 3.4.

$ cat /opt/victronenergy/version 
v3.42
Victron Energy
20240910081535

$ grep VERSION /opt/victronenergy/dbus-modbus-client/dbus-modbus-client.py
VERSION = '1.58'

When it happened I don't know but I'll update the PR description to make it clear that it's a dbus-modbus-client 1.58 dependency rather than Venus OS. With that said I'm on v3.50~25 (and all the betas before that) and it's been fine and the only thing I keep track of. It's difficult for me to provide support for something I don't use.

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch 2 times, most recently from 6a6c5cd to d348c85 Compare October 14, 2024 07:06
@rkapsi rkapsi changed the title Shelly Pro 3EM support for Venus OS 3.50+ Shelly Pro 3EM support for dbus-modbus-client 1.58+ Oct 14, 2024
@onceuponatime78
Copy link

I just recognized that with the latest 3.5034 (before that I had 3.5030 running) the rootfs became read-only and therefore its unfortunatly not straight forward again to patch this - this is especially a bit sad as the available way in venus via websocket is not working reliably. Did you guys figure out on how to patch this in anyhow?

@rkapsi
Copy link
Author

rkapsi commented Oct 20, 2024

Until Victron accepts the PR or does their own thing there's no way around it. Every time there's an update you need to set the root password, ssh into it and do the dance.

I keep the shelly.py file in my /data directory and symlink it to /opt/victronenergy/... To make life easier and not having to do the import you can choose to override one of the other EMs (say ABB). This dance could be automated if there's interest but it's kind of weird.

@onceuponatime78
Copy link

doing the dance wasn't the issue for me...problem now is that on my Ekrano I am locked out now of any modifications to items in the rootfs, hence adding the import is not possible any more

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from d348c85 to a3d3f7d Compare October 31, 2024 04:25
@Jalle19
Copy link

Jalle19 commented Dec 25, 2024

@mpvader I've been waiting almost 1,5 years now for this to be merged. If Victron won't merge this due to conflicts with their own energy meter offering then please say so and close these requests.

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch 2 times, most recently from 43a3ed5 to 28eb26f Compare December 27, 2024 05:59
@rkapsi
Copy link
Author

rkapsi commented Dec 27, 2024

To whom it may concern I also added support for Shelly's Monophase profile.

@patrick-dmxc
Copy link

patrick-dmxc commented Jan 6, 2025

@rkapsi @Jalle19
Hi im whatching this since you opend the PR because i also did an Implementation of some Meters esp. of Janitza., which would allow it to Build ESS with mouch larger scale as all other supported Meters
And it seems like there is no interested in contribute of the Community for Implementing and/or keep 3rd-Party Meters in there Code.

@Jalle19
Copy link

Jalle19 commented Jan 6, 2025

Would be a good conpromise if there would be a plugin system where users can easily add third-party functionality, like support for other meters. AFAICT there's no such thing at the moment though.

@rkapsi
Copy link
Author

rkapsi commented Jan 7, 2025

For me it's fine if they don't want to include OSS contributions but they should say so. Then I'd move on and write my own install script.

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 28eb26f to 1ce4d6e Compare January 31, 2025 20:36
@BasvanH
Copy link

BasvanH commented Mar 11, 2025

Screenshot_20250311-223015
I've implemented this and in regards to the grid values it seems to be working fine. I however dont understand how it calculated the AC loads. As you can see in the screenshot the AC loads on L1 is much higher then it should be. The loads should reflect the same numbers as on the grid, or do I mis understand this?

@Jalle19
Copy link

Jalle19 commented Mar 12, 2025

Looks fairly normal, except for L3. Take a look at https://www.victronenergy.com/media/pg/Energy_Storage_System/en/multiphase-regulation---further-information.html#UUID-72f5b2fc-0d74-563a-b2d6-848f1e8fd046, I doubt it's the Shelly that's measuring or reporting wrong values.

@BasvanH
Copy link

BasvanH commented Mar 13, 2025

I only have one multiplus and thus a single phase ESS in a 3 phase system but my Multiplus is connected to L2 and not L1 as Victron apparently assumes. There's seems to be no option to change this. I need to change my wiring to get this done. Thanks for point me into this direction, Im fairly new in this and you gave me the info I was looking for. Txs!

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 1ce4d6e to c8db597 Compare March 22, 2025 07:27
@rkapsi
Copy link
Author

rkapsi commented Mar 22, 2025

Added support for the EM-50 and the 3CT63

Screenshot from 2025-03-22 09-28-43

@Jalle19
Copy link

Jalle19 commented Apr 22, 2025

Edit: removed outdated instructions

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from c8db597 to e720cbf Compare April 24, 2025 04:46
@Sider92
Copy link

Sider92 commented May 7, 2025

Up-to-date copy-paste instructions:

mount -o remount,rw /
cd /opt/victronenergy/dbus-modbus-client
cp device.py device.py.bak
cp dbus-modbus-client.py dbus-modbus-client.py.bak
cd /tmp
wget https://github.com/rkapsi/dbus-modbus-client/archive/refs/heads/rkapsi/shelly-pro-3em.zip -O shelly-pro3em.zip
unzip shelly-pro3em.zip
cd dbus-modbus-client-rkapsi-shelly-pro-3em
cp shelly.py device.py dbus-modbus-client.py /opt/victronenergy/dbus-modbus-client

Finally, reboot manually

i used this after i updated to 3.55 and i cant get the shelly to show up in devices. it was working before i update to 3.55

@Jalle19
Copy link

Jalle19 commented May 7, 2025

Maybe one of the commands failed, check the output

@Jalle19
Copy link

Jalle19 commented May 7, 2025

If Victron would just merge this it would be much easier for everyone

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from e720cbf to f176251 Compare May 7, 2025 11:56
@rkapsi
Copy link
Author

rkapsi commented May 7, 2025

I believe I know what's going on and I don't recommend installing it this way. My pull-request targets HEAD of master in this project. Unless Victron cuts a new release of Venus OS with the latest and greatest of every component it's always aimed at the most recent beta version of theirs.

To put it very bluntly, you're on 3.55 (latest release) and have just attempted to run dbus-modbus-client.py from 3.60 (beta). That will not work. Either switch to the beta as well or do this:

Get the shelly.py file or the contents thereof

cd /opt/victronenergy/dbus-modbus-client
mv abb.py abb.py.bak

Save the shelly.py file as abb.py and reboot

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from f176251 to 28403a1 Compare May 22, 2025 04:21
@Dizzy1985
Copy link

Dizzy1985 commented May 27, 2025

Hallo.
Ich muss meinen Multiplus GX 2 auf Venus 3.50 anheben...
Habe seit letztem Jahr mit der Version 3.41 und dem Shelly Pro mit 1.6.xx und diesem Script hier:

"mount -o remount,rw /
cd /opt/victronenergy/dbus-modbus-client
cp device.py device.py.bak
cp dbus-modbus-client.py dbus-modbus-client.py.bak
cd /tmp
wget https://codeload.github.com/Jalle19/dbus-modbus-client/zip/refs/heads/shelly-pro3em -O shelly-pro3em.zip
unzip shelly-pro3em.zip
cd dbus-modbus-client-shelly-pro3em
cp shelly.py device.py dbus-modbus-client.py /opt/victronenergy/dbus-modbus-client"

den Shelly Pro 3EM sehr gut zum laufen in Venus gebracht.....

Wie wäre denn jetzt die Vorgehensweise bei dem Update auf Venus 3.50???

@rkapsi
Copy link
Author

rkapsi commented May 30, 2025

Download the shelly.py file from this PR and save it on your GX under /data/shelly.py. Then do something like this:

mv /opt/victronenergy/dbus-modbus-client/abb.py /opt/victronenergy/dbus-modbus-client/abb.py.bak

ln -s /data/shelly.py /opt/victronenergy/dbus-modbus-client/abb.py

reboot

@Dizzy1985
Copy link

Laden Sie die shelly.pyDatei von diesem PR herunter und speichern Sie sie auf Ihrem GX unter /data/shelly.py. Gehen Sie dann folgendermaßen vor:

mv /opt/victronenergy/dbus-modbus-client/abb.py /opt/victronenergy/dbus-modbus-client/abb.py.bak

ln -s /data/shelly.py /opt/victronenergy/dbus-modbus-client/abb.py

reboot

Sorry etwas überfordert damit.... Irgendwie ein "Copy & Paste Befehl" für das ganze verfügbar ;-)

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 28403a1 to 58ee0f5 Compare June 11, 2025 05:36
@fcarlier
Copy link

It's not perfect but with my Shelly Pro 3EM (Monophase profile), i add this code :

            Reg_shelly(32023, '/Ac/L2/Voltage', 1, '%.1f V'),                                                                                                                   
            Reg_shelly(32025, '/Ac/L2/Current', 1, '%.1f A'),                                                                                                                   
            Reg_shelly(32027, '/Ac/L2/Power', 1, '%.1f W'),                                                                                                                     
                                                                                                                                                                                
            Reg_shelly(32043, '/Ac/L3/Voltage', 1, '%.1f V'),                                                                                                                   
            Reg_shelly(32045, '/Ac/L3/Current', 1, '%.1f A'),                                                                                                                   
            Reg_shelly(32047, '/Ac/L3/Power', 1, '%.1f W'),                                                                                                                                                                     

It's a shame that you can't assign a configuration for each phase. (In my case, L1 : Charge CA, L2 : PV, L3 : Grid)

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 58ee0f5 to d1728a7 Compare June 27, 2025 04:43
@Jalle19
Copy link

Jalle19 commented Jun 27, 2025

For anyone coming here, this is the way I've currently used to apply this change after a VenusOS update:

  1. Remount the root filesystem so you can write to it: mount -o remount,rw /
  2. Put shelly.py in /opt/victronenergy/dbus-modbus-client
  3. Modify /opt/victronenergy/dbus-modbus-client/dbus-modbus-client.py and add import shelly somewhere near the top of the file (e.g. after import victron_em).
  4. Reboot

@fcarlier
Copy link

In my case :
2a. Put shelly.py in /data
2b. ln -s /data/shelly.py /opt/victronenergy/dbus-modbus-client/shelly.py
resists updating, just 3. 4. ;)

@markok12345
Copy link

I tried this with two Shelly 3EM Pro devices – one for the grid and one for the PV inverter. I got both Shellys integrated into Victron, and everything looks good in the Device List. However, VRM is not working very well. I can see both meters in VRM, but they both show the same values. What could be wrong, and is there any way to fix it?

@Jalle19
Copy link

Jalle19 commented Jul 2, 2025

@markok12345 what does the device list look like in VRM? Do they have different VRM instance IDs?

I only have a single meter and it looks like this, can you make a similar screenshot with both meters expanded?

image

@Jalle19
Copy link

Jalle19 commented Jul 2, 2025

If the VRM instance IDs are identical, try changing one of them from the UI:

image

@jipski123
Copy link

There is false productmodel for 3EM63.

in code SPEM-003CEBEU63. i read productmode from my 3EM63W and get S3EM-003CXCEU63

working great after i chage that code

i dont know if there is difference between 3EM63T and 3EM63W

@rkapsi
Copy link
Author

rkapsi commented Jul 22, 2025

There is false productmodel for 3EM63.

in code SPEM-003CEBEU63. i read productmode from my 3EM63W and get S3EM-003CXCEU63

working great after i chage that code

i dont know if there is difference between 3EM63T and 3EM63W

Not false, it's a different product. If you tell me that 3EM63T and 3EM63W works then I can add it but I have no way of testing it for the foreseeable future.

@jipski123
Copy link

There is false productmodel for 3EM63.
in code SPEM-003CEBEU63. i read productmode from my 3EM63W and get S3EM-003CXCEU63
working great after i chage that code
i dont know if there is difference between 3EM63T and 3EM63W

Not false, it's a different product. If you tell me that 3EM63T and 3EM63W works then I can add it but I have no way of testing it for the foreseeable future.

3EM63W start working after i change SPEM-003CEBEU63 to S3EM-003CXCEU63

maybe it would be a good idea to add that meter to the code too

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from d1728a7 to 937dcab Compare July 23, 2025 04:59
@rkapsi
Copy link
Author

rkapsi commented Jul 23, 2025

@jipski123 done. But please note and as already mentioned that I don't have that EM in my collection to verify anything. While adding it I also noticed that Shelly's website doesn't mention anything about Modbus support for this device. Flying blind here.

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 937dcab to 71387f0 Compare July 27, 2025 05:24
@rkapsi
Copy link
Author

rkapsi commented Jul 27, 2025

I've refined the implementation a little bit. It now enumerates the Shelly's EM components instead of essentially hard-coding them and handles the Monophase profile a lot better (cc @fcarlier). Added also the Power Factor.

@novegit
Copy link

novegit commented Aug 5, 2025

I updated from v3.54 to v3.64 some days ago and rebooted the cerbo at least 3-4 times since the update. My Shelly Pro3EM is detected and fully operational without any manual modifications from this PR, that I had to do after each upgrade before.

@nickhidding
Copy link

I'm using this to read PV generation with a Shelly PRO EM-50 because this Shelly device was installed already to monitor solar in Home Assistant.
It was easy to setup, but with two small modifications:

  • The second current transformer input is ignored, because it monitors a completely different circuit in the house in Home Assistant.
  • AC Totals was needed in init_monophase, because this is visible in the Remote Console > Devices and also works better in VRM. Otherwise it would only show Solar forecast, and didn't track actual solar generation.

@rkapsi rkapsi force-pushed the rkapsi/shelly-pro-3em branch from 71387f0 to 973b689 Compare September 11, 2025 04:00
@rkapsi
Copy link
Author

rkapsi commented Sep 13, 2025

FWIW as of one of the recent 3.70 betas a new section has appeared under Settings -> Integrations -> Shelly Devices. It hasn't been mentioned in the release notes and it seems to be not fully functional yet. For example you can add the Pro 3EM and it shows up under Devices but you have a very limited set of options to pick its Role. I assume it's just a matter of time.

Screenshot from 2025-09-13 11-44-52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.