Skip to content

Resource Manager MQTT bridge reference implementation (Ruby)#5

Merged
jorritn merged 10 commits into
mainfrom
resource-manager-mqtt-bridge-ruby
Jun 24, 2026
Merged

Resource Manager MQTT bridge reference implementation (Ruby)#5
jorritn merged 10 commits into
mainfrom
resource-manager-mqtt-bridge-ruby

Conversation

@epologee

@epologee epologee commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Adds resource-manager-mqtt-bridge-ruby/, a Ruby reference implementation of an S2 Resource Manager. It bridges a charging session's events from an MQTT broker to S2 (FRBC control type) and turns an inbound FRBC.Instruction back into an MQTT message. It is derived from (and nearly identical to) the bridge Stekker runs in production for its smart-charging platform.

rm/ is the reference and runs on its own with docker compose up. Three small demo stand-ins next to it (cem/, mqtt/, demo/) make the closed loop visible: ./demo.sh brings everything up on one screen at http://localhost:8080, press the buttons in their chronological order to see messages travel from left to right and vice versa:

CleanShot 2026-06-11 at 12 31 06

The README contains further info on how to demo the reference implementation.

Greetings from the Stekker S2 team,
@bforma, @ErikDeBruijn, @martijnversluis and @epologee

epologee and others added 5 commits June 11, 2026 16:19
The reference implementation: a Rails app that consumes charger
telemetry and lifecycle events from an MQTT broker, translates each
message to its S2 counterpart over a WebSocket session (FRBC control
type), and turns inbound FRBC.Instruction messages back into MQTT
power setpoints. Derived from the S2 bridge Stekker.app runs against
its smart-charging platform; the S2 wire types come from the public
s2-ruby gem, pinned to an exact revision. Runs stand-alone with
docker compose and ships its spec suite.

Co-authored-by: Bob Forma <bob@stekker.com>
Co-authored-by: Erik de Bruijn <edb@stekker.com>
Co-authored-by: Martijn Versluis <martijn@stekker.com>
The bridge needs resource-side traffic to translate, and the real
charging platform behind the MQTT contract is not open source. This
stand-in bundles the broker and a small panel that publishes the
example payloads and shows the power setpoints coming back, so the
forward and reverse paths are drivable without any external system.

Co-authored-by: Bob Forma <bob@stekker.com>
Co-authored-by: Erik de Bruijn <edb@stekker.com>
Co-authored-by: Martijn Versluis <martijn@stekker.com>
Stand-alone, the RM has no peer to complete the S2 handshake with.
This minimal WebSocket server replies with its own Handshake, selects
FILL_RATE_BASED_CONTROL, and sends an FRBC.Instruction built from the
FRBC.SystemDescription it received from the RM, so the closed loop
runs on real protocol traffic rather than scripted state.

Co-authored-by: Bob Forma <bob@stekker.com>
Co-authored-by: Erik de Bruijn <edb@stekker.com>
Co-authored-by: Martijn Versluis <martijn@stekker.com>
./demo.sh starts the broker, the CEM, the RM and the platform panel,
and frames the three applications side by side on a single URL. A
viewer presses one button on the MQTT side and watches the message
travel through the RM to the CEM and a power setpoint come back, so
the closed loop is legible from end to end.

Co-authored-by: Bob Forma <bob@stekker.com>
Co-authored-by: Erik de Bruijn <edb@stekker.com>
Co-authored-by: Martijn Versluis <martijn@stekker.com>
States the terms under which this reference implementation is offered
and records copyright. The Apache 2.0 text is verbatim from the
canonical source; the NOTICE file carries the Stekker.app B.V.
copyright and attribution.
@epologee epologee marked this pull request as ready for review June 11, 2026 14:40
@epologee epologee requested a review from jorritn June 12, 2026 13:26
@jorritn

jorritn commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hi @epologee. Thanks a lot! It looks really good. I have commit two changes of which I hope you agree with.

@jorritn jorritn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have request for change. In AdoptS2 we have used a slightly modified version of S2, a measurement timestamp was added to the FRBC.StorageStatus message and instructions have an end time. Those changes also made it into your s2-ruby library and therefore also in the example messages in this reference implementation. However, we cannot have a reference implementation that is not following exactly the official S2 message definition so therefore I would like to ask you if you can revert (of make it optional to use) the changes that I just mentioned.

@martijnversluis

Copy link
Copy Markdown
Collaborator

@jorritn We're working on it, this PR reverts the changes on the message specifications: stekker/s2-ruby#18

@epologee

Copy link
Copy Markdown
Collaborator Author

I would like to ask you if you can revert (of make it optional to use) the changes that I just mentioned.

@jorritn, please have a look at 10594b0. Does address your request? Cheers!

@epologee epologee requested a review from jorritn June 18, 2026 15:59
@jorritn

jorritn commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@jorritn, please have a look at 10594b0. Does address your request? Cheers!

Yes, I think so, thanks! But it could be that there some more leftovers in the library. See my comment there: stekker/s2-ruby#18 (comment)

@jorritn jorritn merged commit f111db2 into main Jun 24, 2026
@jorritn jorritn deleted the resource-manager-mqtt-bridge-ruby branch June 30, 2026 09:11
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.

3 participants