View code on Github

v0.27: multi-asset scheduling & 2FA

Snippet from the 2FA form
Snippet from the 2FA form

Version v0.27 of FlexMeasures brings a long-overdue feature: ability to schedule multiple flexible assets in one go 👯. Also, a major step towards modern cyber-security 🔐 standards: two-factor authentication.

And there is even more: upload data per file, edit users, ...

See the changelog for a complete list of improvements (>40 PRs!).

Let's dive int the two main features!

Multi-asset scheduling

Until now, you can tell FlexMeasures to find an optimal schedule for a device (e.g. a battery). We already have used FlexMeasures to schedule sites with more than one flexible device (e.g. also EVs), but with one caveat: we scheduled one flexible device after the other (sequentially - we'll add a short explanation below).

Anyway, we were lacking an endpoint to run one simultaneuous optimization for a combined schedule, and after several preparation steps and testing in the last few months, we added this one:

POST /api/v3_0/assets/(id)/schedules/trigger

"Trigger FlexMeasures to create a schedule for a collection of flexible and inflexible devices."

Of course, we stay true to the ambition that each device can be steered so that the schedule fits its unique constraints, and thus telling FlexMeasures about the flex-models can look like this:

{
    "start": "2015-06-02T10:00:00+00:00",
    "flex-model": [
        {
            "sensor": 931,
            "soc-at-start": 12.1,
            "soc-unit": "kWh",
            "power-capacity": "25kW",
            "consumption-capacity" : {"sensor": 42},
            "production-capacity" : "30 kW"
        },
        {
            "sensor": 932,
            "consumption-capacity": "0 kW",
            "production-capacity": {"sensor": 760},
        }
    ],
    "flex-context": {
        "consumption-price-sensor": 9,
        "production-price-sensor": 10,
        "inflexible-device-sensors": [13, 14, 15],
        "site-power-capacity": "100kW",
        "site-production-capacity": "80kW",
        "site-consumption-capacity": {"sensor": 32}
    }
}

This is for two devices (see the endpoint docs for more explanation of this example). For more flexible devices, the body becomes longer.  Luckily, we are also working on letting you specify all flex-model fields on the asset data models (for flex-context, that already is the case). 

We are really happy that this finally is in place. This work was done in Pull Request 1065 , but actually you'll find preparation steps going back more than 6 months. 

Now, how does "sequential" scheduling work? After each device we scheduled, we were adding the already scheduled ones to the list of inflexible devices, so the next schedule would take them into account. This approach might scale better with a large number of devices, but we found that the new simultaneous approach also works well with ~100 devices. However, it is still an interesting approach, so the new endpoint offers it, as well (just passsequential=true).

Two-factor authentication

Cyber-security is more and more crucial when running a serious service - and that is what we aim FlexMeasures to be.

That means we had to increase the level of security. A lot of that happens in anybody's cloud environment, but FlexMeasures itself needs to also be hardened. 

So version 0.27 adds Two-factor Authentication, the mechanism where only one factor (your password) is not enough to log into the service. In this first implementation, users need a separate token, as well, which is sent to their email address. We can expand this to support QR codes (for security apps) or SMS.

Second login step if 2FA is enabled - form for the 2nd factor code
Second login step if 2FA is enabled - form for the 2nd factor code

 

TFA is off by default, so anyone hosting FlexMeasures should consider turning it on.

This work was done in Pull Requests 1555, 1562 and 1564.

A final note on security in FlexMeasures: we take this seriously on a few fronts: We are upgrading our dependencies with every minor version, we use GitHub's Dependabot and are now starting to scan its code regularly for any potential issues.

Upload data

To get any data into FlexMeasures, you needed to use the API or CLI. Now there is another way: Sometimes, all you need is to get data from a file into the platform (e.g. to add history for forecasting, or tomorrow's prices). And this is possible now:

Upload form on the sensor page
User editing

User editing was possible via the API, but the UI was missing. We finally got around to do this. Now you can even add/remove roles:

Editing a user in the UI