feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Add support for the Shelly 4PM (images attached)

Open baldarn opened this issue 3 years ago • 14 comments

Describe the problem you have/What new integration you would like

Add support for the Shelly 4PM

Please describe your use case for this integration and alternatives you've tried:

Shelly 4PM not currently supported. I have several of the devices and they’re relatively cheap considering they have 4 output so hopefully this can be achieved.

Additional context

Shelly 4PM

some images of a disassebled one

IMG_20220629_094826 IMG_20220629_094852 IMG_20220629_095055 IMG_20220629_095108 IMG_20220629_095214 )

baldarn avatar Jun 29 '22 07:06 baldarn

I am working on it - so far I have the st7735 display, the NTC temp sensor and the mcp23s17 IO multiplex (inputs and relays) working. The ade7953 energy meter is TBD as the Pro 4PM is connected via SPI and esphome component only supports I2C.

https://github.com/angelnu/esphome/blob/master/devices/shelly/pro4pm/base_v1.yaml WIP

Pending:

  • extend ade7953 library for SPI
  • implement a nice layout for the screen to display the energy data and allow to turn on/off manually the relays like in the original firmware.
  • logic to turn off the relay if overcurrent

angelnu avatar Sep 13 '23 21:09 angelnu

How about the LAN port?

nagyrobi avatar Sep 14 '23 04:09 nagyrobi

It should work (I know the pins) and esphome supports it BUT it cannot be used in parallel to the wifi.

Ideally, it would be possible to detect at boot if the cable is plugged and use the wifi as backup but I do not think is possible to compile both modules together.

angelnu avatar Sep 14 '23 14:09 angelnu

Yes of course, ESPHome is either LAN or WiFi...

Question was if LAN is supported at all... what's the LAN PHY inside?

nagyrobi avatar Sep 14 '23 16:09 nagyrobi

Also, it looks like there are two hardware revisions already. The one in the photos above looks like V1.

Wonder if, apart from the high voltage connection differences, are there different internals.

nagyrobi avatar Sep 14 '23 17:09 nagyrobi

Yes of course, ESPHome is either LAN or WiFi...

Question was if LAN is supported at all... what's the LAN PHY inside?

It is an LAN8720A:

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT

In fact on the same pins as for other Shelly Pros - https://devices.esphome.io/devices/Shelly-Pro-1

angelnu avatar Sep 27 '23 19:09 angelnu

Also, it looks like there are two hardware revisions already. The one in the photos above looks like V1.

Wonder if, apart from the high voltage connection differences, are there different internals.

I do not think so... but since I only got v2 I cannot tell for sure. In Tasmota they have the same templates.

angelnu avatar Sep 27 '23 19:09 angelnu

Update

I got the screen working with a basic menu. I also added support for the energy sensor (see https://github.com/esphome/esphome/pull/5439)

image

After the support for the sensor gets added I will submit an entry to esphome devices.

angelnu avatar Sep 27 '23 19:09 angelnu

In order to accelerate getting https://github.com/esphome/esphome/pull/5439 merged it would help if others could validate that it works for them.

So if you use the ADE7953 sensor used in the Shelly Pro series, please give it a try by adding

external_components:
  # use rtttl and dfplayer from ESPHome's dev branch in GitHub
  - source:
      type: git
      url: https://github.com/angelnu/esphome-1
      ref: ade7953_split

to you yaml. Please also provide feedback if you test with I2C where I also added support for additional metrics reported by the sensor (apparent power, reactive power and power factor).

If you want to test with the Shelly Pro 4PM you might want to use my yaml as base: https://github.com/angelnu/esphome/blob/master/devices/shelly/pro4pm/base_v1.yaml

angelnu avatar Sep 29 '23 21:09 angelnu

For your information, I'm currently adding support for Shelly Pro 2 PM: https://github.com/esphome/feature-requests/issues/3033

mwetterw avatar Jan 23 '25 18:01 mwetterw

After the support for the sensor gets added I will submit an entry to esphome devices.

@angelnu Would love to try esphome on my 4pm, but I couldn't find the device in the Esphome devices list. Did this not materialize?

In the mean time I'm gonna check out your yaml (which I didn't see before ;))

hapklaar avatar Apr 27 '25 19:04 hapklaar

@angelnu thanks for your work so far! Just got a Pro 4 PM, I'm using your base code and it works really okay I'd say.

Two questions:

  1. seeing that your PR for ade7953 support is merged, what would be missing in your eyes to get the devices added?
  2. have you tried using esp-idf framework instead of arduino? I'd love to use it in order to use certificate validation with it (with Arduino I can use the client authentication but cannot do CA validation)

When using esp-idf, most of the readings are off by several orders of magnitude and the display doesn't work either. Before I start digging a bit more, did you play around with it already?

waza-ari avatar Jun 17 '25 18:06 waza-ari

I think there's some issue which was documented by @pihiandreas in this issue: https://github.com/esphome/issues/issues/6176 - that seems to cause both the display and outputs not working are related to this issue

waza-ari avatar Jun 17 '25 19:06 waza-ari

I gave today esp-idf another try but the problem from https://github.com/esphome/issues/issues/6176 is still there. So remaining on framework arduino until either someone else fixes the SPI issue or I have time for it. Low in the prio list since it just work with Arduino so until the arduino framework is deprecated there is no urgency to change.

angelnu avatar Oct 26 '25 14:10 angelnu