Add support for the Shelly 4PM (images attached)
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
some images of a disassebled one
)
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
How about the LAN port?
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.
Yes of course, ESPHome is either LAN or WiFi...
Question was if LAN is supported at all... what's the LAN PHY inside?
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.
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
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.
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)
After the support for the sensor gets added I will submit an entry to esphome devices.
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
For your information, I'm currently adding support for Shelly Pro 2 PM: https://github.com/esphome/feature-requests/issues/3033
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 ;))
@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:
- seeing that your PR for ade7953 support is merged, what would be missing in your eyes to get the devices added?
- have you tried using
esp-idfframework instead ofarduino? 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?
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
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.