Add support for the single phase Shelly Pro EM as an output device#400
Open
andrebrait wants to merge 1 commit into
Open
Add support for the single phase Shelly Pro EM as an output device#400andrebrait wants to merge 1 commit into
andrebrait wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new output device type
ShellyProEMwhich 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/EM1Datacomponents) instead of the three phaseEM/EMDatacomponent. The emulation reports the summed up power and energy data of all input phases on channel0, while channel1is 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
ShellyProEM(config blockuni-meter.output-devices.shelly-proem) which extends the existingShellyPro3EMactor and overrides the device identity and the meter components:Shelly.GetDeviceInforeportsmodel: SPEM-002CEBEU50,app: ProEM50,gen: 2, hostnameShellyProEM50-<MAC>and noprofilefield, matching a real Pro EM-50Shelly.GetStatus,Shelly.GetConfigandShelly.GetComponentsexposeem1:0,em1:1,em1data:0andem1data:1instead ofem:0/emdata:0NotifyStatuson the outbound websocket connection carries anem1:0payloadEM1.GetStatus/GetConfigandEM1Data.GetStatus/GetConfigRPC methods, available via HTTP GET, JSON RPC over HTTP POST, websocket and UDP. TheEM1HTTP GET routes are only registered for the Pro EM device, the Pro 3EM behaves exactly as beforemin-sample-periodthrottling of the websocket/UDP status polling now also applies toEM1.GetStatusrequestsdevice.hostname-prefixconfiguration value (defaults toShellyPro3EM-/ShellyProEM50-per device) used to build the default hostname from the mac addressdoc/output/ShellyProEM.md), README and CHANGELOG updatedTesting
mvn testpassesgeneric-httpinput 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.GetStatusverified via HTTP GET, JSON RPC over HTTP POST and JSON RPC over UDP (udp-port), including the unused channel1and proper error responses for invalid channel idsShelly.GetDeviceInfo,/shelly,/settings,Shelly.GetStatus,Shelly.GetConfig,Shelly.GetComponentsverified to return the Pro EM component layoutshelly-pro3emoutput: unchanged behavior,EM1.*endpoints correctly return 404 thereThis 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