Skip to content

Add support for the single phase Shelly Pro EM as an output device#400

Open
andrebrait wants to merge 1 commit into
sdeigm:mainfrom
andrebrait:claude/issue-382-7s8c95
Open

Add support for the single phase Shelly Pro EM as an output device#400
andrebrait wants to merge 1 commit into
sdeigm:mainfrom
andrebrait:claude/issue-382-7s8c95

Conversation

@andrebrait

Copy link
Copy Markdown

Summary

Adds a new output device type ShellyProEM which emulates the single phase Shelly Pro EM-50 (SPEM-002CEBEU50).

In contrast to the three phase Shelly Pro 3EM, the Pro EM provides two single phase meter channels (EM1/EM1Data components) instead of the three phase EM/EMData component. The emulation reports the summed up power and energy data of all input phases on channel 0, while channel 1 is reported as unused. This helps consumers which only support single phase Shelly devices or which misinterpret the three phase data of the Pro 3EM as described in #382 (Indevolt PowerFlex 2000 Eco treating solar production data of the three phases as consumption).

Closes #382

Implementation

  • New output device ShellyProEM (config block uni-meter.output-devices.shelly-proem) which extends the existing ShellyPro3EM actor and overrides the device identity and the meter components:
    • Shelly.GetDeviceInfo reports model: SPEM-002CEBEU50, app: ProEM50, gen: 2, hostname ShellyProEM50-<MAC> and no profile field, matching a real Pro EM-50
    • Shelly.GetStatus, Shelly.GetConfig and Shelly.GetComponents expose em1:0, em1:1, em1data:0 and em1data:1 instead of em:0/emdata:0
    • NotifyStatus on the outbound websocket connection carries an em1:0 payload
  • New EM1.GetStatus/GetConfig and EM1Data.GetStatus/GetConfig RPC methods, available via HTTP GET, JSON RPC over HTTP POST, websocket and UDP. The EM1 HTTP GET routes are only registered for the Pro EM device, the Pro 3EM behaves exactly as before
  • The min-sample-period throttling of the websocket/UDP status polling now also applies to EM1.GetStatus requests
  • New device.hostname-prefix configuration value (defaults to ShellyPro3EM-/ShellyProEM50- per device) used to build the default hostname from the mac address
  • Documentation (doc/output/ShellyProEM.md), README and CHANGELOG updated

Testing

  • mvn test passes
  • Manual smoke test with a generic-http input feeding 423.5 W / mono phase:
    • GET /rpc/EM1.GetStatus?id=0{"id":0,"current":1.83,"voltage":230.00,"act_power":423.51,"aprt_power":423.51,"pf":1.00,"freq":50.00,"calibration":"factory"}
    • EM1.GetStatus/EM1Data.GetStatus verified via HTTP GET, JSON RPC over HTTP POST and JSON RPC over UDP (udp-port), including the unused channel 1 and proper error responses for invalid channel ids
    • Shelly.GetDeviceInfo, /shelly, /settings, Shelly.GetStatus, Shelly.GetConfig, Shelly.GetComponents verified to return the Pro EM component layout
  • Regression test with the shelly-pro3em output: unchanged behavior, EM1.* endpoints correctly return 404 there

This change was developed together with Claude (Anthropic's AI coding assistant): implementation, smoke testing and regression testing were done in a Claude Code session. Session: https://claude.ai/code/session_01N3pBKn7wJwAwW8uTWSLJWM

Adds a new output device type 'ShellyProEM' which emulates the single
phase Shelly Pro EM-50 (SPEM-002CEBEU50). The device exposes the EM1 and
EM1Data components via HTTP GET, JSON RPC over HTTP/websocket and JSON
RPC over UDP. Channel 0 reports the summed up power and energy data of
all input phases, channel 1 is reported as unused.

https://claude.ai/code/session_01N3pBKn7wJwAwW8uTWSLJWM
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.

Shelly Pro EM output

2 participants