More information about Stekker’s S2-Ruby gem

Stekker has created an S2-Ruby gem, a collection of code that you can add to your Ruby project so that it can speak in S2.

Imagine a location has electric vehicle chargers, heat pumps, battery storage and a solar array. Often governed by a central energy management system (EMS), these devices might all use or provide electricity – and they’re flexible about when they can charge or deliver.

There was no universal language for these devices to tell energy management systems: “I need 40 kWh by 7 AM, but I’m flexible about when you could send it over.”

This is why the Dutch research organization TNO developed the S2 standard: a European specification (EN 50491-12-2) that defines exactly how European devices should communicate their energy flexibility.

What Stekker Built

We built a ruby gem and open-sourced it on Github.

We here at Stekker are a smart charging service provider – which means we provide smart charging services for businesses and developers. Through a partnership with TNO and others, Stekker was able to develop a new integration that made Stekker also ‘S2-compatible’ and created an S2 ruby library in the process.

We recognized that while the S2 standard existed on paper, Ruby developers lacked a practical tool to implement it. So we decided to open-source our library, as we had promised the Dutch government and TNO at the start of our partnership.

The s2-ruby gem is Stekker’s open-source implementation of the S2 protocol. It handles WebSocket connections, message validation, protocol state management. This way, developers can focus on (vibe-)coding their applications while assuring the EN 50491-12-2 is being followed.

This gem is released under the Apache 2.0 license, meaning you can do as you please with this code, as long as you you give a shout out to Stekker. We’re happy to contribute to the S2-infrastructure in Europe and where-ever developers are implementing the latest standards for grid-aware and sustainable charging.

S2 Github Library: https://github.com/stekker/s2-ruby

Core Architecture

The library is built around three main components:

  • S2::Connection manages the WebSocket lifecycle—opening connections, handling disconnects, and automatic reconnection
  • S2::Session tracks the protocol state as messages flow back and forth
  • S2::MessageHandler is your extension point—inherit from this class to define how your application responds to incoming messages FRBC Support

The gem specifically implements Fill Rate Based Control as a control type. This control type is ideal for devices that “fill up” over time—like (EV-)batteries charging or hot water tanks heating. This makes it particularly relevant for EV charging infrastructure.

Other control types might be implemented in the future.

Interested in scaling further?

If you are a developer working for a company that is looking communicate with charge points according to over 20 grid-aware parameters and are interested in partnering up, get in touch.

  • CPMS/CPO software
  • EV charging platforms
  • Home energy management systems
  • Virtual power plant software
  • Battery EMS
  • etc

EV batteries to stabilise the grid

At Stekker, we think the batteries of EVs can be used at scale to solve urgent grid problems. By partnering with Stekker, we can intelligently millions of EVs to help get as much of our energy needs from solar and wind power, just by charging batteries at the right time.