Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

- `s2-resource`: FRBC as a built-in control type, next to OMBC and None. Pick a preset (battery, hot water boiler, heat pump buffer or custom), enter the capacity or tank volume and the power range of each operation mode, and the node works out the fill rates. The fill level goes in as a plain number on the input; instructions come out as in `s2-frbc`, confirmed by the flow or by the new *Auto-confirm instructions* option. More complex setups can edit the JSON, or use `s2-frbc`. New example: `s2-resource-frbc-boiler`. (#125)

### Fixed

- `s2-rm` and `s2-resource` accepted a `RevokeObject` whose `object_type` named another control type than the open instruction with that ID. A queued instruction was then revoked anyway, and one already passed on to the flow got OK without a `REVOKED`. They now answer such a revoke with `PERMANENT_ERROR`. (#123)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Below, each node's internal type (`s2-resource`, `s2-rm`, ...) is used for ident

| Node | Description |
|------|-------------|
| **s2-resource** | Composite S2 Resource Manager - combines `s2-rm`, a built-in transport (`WebSocket`, `D-Bus`, or `External`), and a built-in control type (`OMBC` or `None`) behind one tabbed edit dialog. Recommended starting point: a minimal S2 flow needs just this one node instead of wiring the nodes below together. |
| **s2-resource** | Composite S2 Resource Manager - combines `s2-rm`, a built-in transport (`WebSocket`, `D-Bus`, or `External`), and a built-in control type (`OMBC`, `FRBC` or `None`) behind one tabbed edit dialog. Recommended starting point: a minimal S2 flow needs just this one node instead of wiring the nodes below together. |
| **s2-rm** | S2 Resource Manager - generic S2 protocol state machine (handshake, control-type selection, instruction ack/routing) for a connected CEM, independent of any specific control type |
| **s2-rm-config** | Configuration for RM identity: resource ID, name, roles, control types, serial number, power measurement/forecast |
| **s2-ombc** | Operation Mode Based Control - declares the OMBC system description, resolves OMBC instructions, and confirms operation mode changes back to the CEM |
Expand Down Expand Up @@ -60,7 +60,7 @@ npm install node-red-contrib-s2

## Quick start

For the simplest possible flow, drag in a single **s2-resource** node instead: pick `Transport: WebSocket`, `D-Bus`, or `External` and `Control type: OMBC` or `None` on its tabbed edit dialog, and it behaves like steps 1-5 below wired together (see the node's own help panel for its full tabbed configuration). The rest of this section covers the fully wired-together model, which `s2-resource` builds on and which you'd still use if you want OMBC/PEBC as separate nodes, or multiple resources sharing one CEM connection.
For the simplest possible flow, drag in a single **s2-resource** node instead: pick `Transport: WebSocket`, `D-Bus`, or `External` and `Control type: OMBC`, `FRBC` or `None` on its tabbed edit dialog, and it behaves like steps 1-5 below wired together (see the node's own help panel for its full tabbed configuration). The rest of this section covers the fully wired-together model, which `s2-resource` builds on and which you'd still use if you want OMBC/PEBC as separate nodes, or multiple resources sharing one CEM connection.

1. Add an **s2-rm-config** node and configure your Resource Manager identity (name, roles, control types).
2. Add an **s2-cem-config** node with the WebSocket URL and credentials of your CEM.
Expand All @@ -82,6 +82,7 @@ Import any of these from the Node-RED palette manager's "Import Examples" menu (

| Example | Demonstrates |
|---------|--------------|
| `s2-resource-frbc-boiler` | A hot water boiler as an FRBC resource in a single **s2-resource** node (`Transport: WebSocket`, `Control type: FRBC`, preset *Hot water boiler*), with a function node simulating the water temperature and confirming each instruction - no real hardware required. |
| `s2-resource-quickstart` | The recommended starting point: the same boiler-OMBC scenario below, collapsed to a single **s2-resource** node (`Transport: WebSocket`, `Control type: OMBC`) plus the **s2-cem-config** it shares its CEM connection with. |
| `boiler-ombc-demo` | The fully wired-together model: **s2-rm-config** + **s2-cem-config** + **s2-websocket** + **s2-rm** + **s2-ombc-config** + **s2-ombc**, simulating a single-phase electric boiler with two operation modes (Standby/off, Normal 2500W) - no real hardware required. |
| `s2-dbus-quickstart` | The same boiler-OMBC scenario as `boiler-ombc-demo`, but over the **s2-dbus** transport (Venus OS D-Bus) instead of WebSocket - for a CEM running on the same GX device. |
Expand Down
126 changes: 126 additions & 0 deletions examples/s2-resource-frbc-boiler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
[
{
"id": "d8a320bc185dd550",
"type": "tab",
"label": "s2-resource FRBC boiler",
"disabled": false,
"info": "A hot water boiler as an FRBC resource in a single s2-resource node (Control type: FRBC, preset Hot water boiler, 200 l, heat 0-3000 W). A function node simulates the water temperature, so no hardware is needed. Point the s2-cem-config at your CEM.",
"env": []
},
{
"id": "dcd1adafe7a95c5e",
"type": "comment",
"z": "d8a320bc185dd550",
"name": "Point \"Demo CEM\" at your CEM, then deploy",
"info": "",
"x": 230,
"y": 60,
"wires": []
},
{
"id": "2b89d879ecf750e3",
"type": "s2-cem-config",
"name": "Demo CEM",
"url": "ws://localhost:8080/s2-message-handler",
"apiPrefix": ""
},
{
"id": "d14f2d7c29405690",
"type": "s2-resource",
"version": "0.9.7",
"z": "d8a320bc185dd550",
"name": "Boiler",
"rmName": "RM: Hot water boiler",
"resourceId": "cc94a3c3-8555-4041-b761-8e2386de06d8",
"roles": "ENERGY_CONSUMER",
"controlTypes": "FILL_RATE_BASED_CONTROL",
"providesPowerMeasurement": "3_PHASE_SYMMETRIC",
"providesForecast": false,
"manufacturer": "Victron Energy",
"model": "Virtual RM",
"serialNumber": "",
"firmwareVersion": "1.0.0",
"instructionPollIntervalMs": 2000,
"skipInstructionStatus": false,
"transport": "websocket",
"cem": "2b89d879ecf750e3",
"reconnectInterval": 5,
"debug": true,
"controlType": "frbc",
"systemDescription": "{\"operationModes\":[{\"id\":\"7c1b2a3d-4e5f-4061-8a9b-0c1d2e3f4a5b\",\"diagnostic_label\":\"Standby/off\",\"power_ranges\":[{\"commodity_quantity\":\"ELECTRIC.POWER.3_PHASE_SYMMETRIC\",\"start_of_range\":0,\"end_of_range\":0}],\"abnormal_condition_only\":false},{\"id\":\"9e2c3b4d-5f60-4172-9b0c-1d2e3f4a5b6c\",\"diagnostic_label\":\"Normal operation\",\"power_ranges\":[{\"commodity_quantity\":\"ELECTRIC.POWER.3_PHASE_SYMMETRIC\",\"start_of_range\":0,\"end_of_range\":2500}],\"abnormal_condition_only\":false}],\"transitions\":[{\"id\":\"a1b2c3d4-e5f6-4283-ac1d-2e3f4a5b6c7d\",\"from\":\"7c1b2a3d-4e5f-4061-8a9b-0c1d2e3f4a5b\",\"to\":\"9e2c3b4d-5f60-4172-9b0c-1d2e3f4a5b6c\",\"start_timers\":[],\"blocking_timers\":[],\"abnormal_condition_only\":false},{\"id\":\"b2c3d4e5-f607-4394-bd2e-3f4a5b6c7d8e\",\"from\":\"9e2c3b4d-5f60-4172-9b0c-1d2e3f4a5b6c\",\"to\":\"7c1b2a3d-4e5f-4061-8a9b-0c1d2e3f4a5b\",\"start_timers\":[],\"blocking_timers\":[],\"abnormal_condition_only\":false}],\"timers\":[]}",
"outputs": 1,
"x": 420,
"y": 200,
"wires": [
[
"a3e57e828ee30d59",
"30c1b5ae105df76e"
]
],
"frbcForm": "{\"preset\":\"boiler\",\"unit\":\"°C\",\"min\":10,\"max\":80,\"size\":200,\"cop\":null,\"minOn\":0,\"minOff\":0,\"modes\":[{\"id\":\"1df32985-7d4d-4dcf-805c-ff5b9ec1abc0\",\"label\":\"Heat\",\"from\":0,\"to\":3000},{\"id\":\"83ac070f-ba25-4f5e-a708-a3605d1f6b38\",\"label\":\"Idle\",\"from\":0,\"to\":0}],\"actuatorId\":\"7fc657a3-8a73-49e0-ab4d-e90ae82f2c84\"}",
"frbcSystemDescription": "{\"actuators\":[{\"id\":\"7fc657a3-8a73-49e0-ab4d-e90ae82f2c84\",\"diagnostic_label\":\"Heating element\",\"supported_commodities\":[\"ELECTRICITY\"],\"operation_modes\":[{\"id\":\"1df32985-7d4d-4dcf-805c-ff5b9ec1abc0\",\"diagnostic_label\":\"Heat\",\"abnormal_condition_only\":false,\"elements\":[{\"fill_level_range\":{\"start_of_range\":10,\"end_of_range\":80},\"fill_rate\":{\"start_of_range\":0,\"end_of_range\":0.00358337},\"power_ranges\":[{\"commodity_quantity\":\"ELECTRIC.POWER.3_PHASE_SYMMETRIC\",\"start_of_range\":0,\"end_of_range\":3000}]}]},{\"id\":\"83ac070f-ba25-4f5e-a708-a3605d1f6b38\",\"diagnostic_label\":\"Idle\",\"abnormal_condition_only\":false,\"elements\":[{\"fill_level_range\":{\"start_of_range\":10,\"end_of_range\":80},\"fill_rate\":{\"start_of_range\":0,\"end_of_range\":0},\"power_ranges\":[{\"commodity_quantity\":\"ELECTRIC.POWER.3_PHASE_SYMMETRIC\",\"start_of_range\":0,\"end_of_range\":0}]}]}],\"transitions\":[{\"id\":\"1df32985-7d4d-4dcf-805c-a3605d1f6b38\",\"from\":\"1df32985-7d4d-4dcf-805c-ff5b9ec1abc0\",\"to\":\"83ac070f-ba25-4f5e-a708-a3605d1f6b38\",\"start_timers\":[],\"blocking_timers\":[],\"abnormal_condition_only\":false},{\"id\":\"83ac070f-ba25-4f5e-a708-ff5b9ec1abc0\",\"from\":\"83ac070f-ba25-4f5e-a708-a3605d1f6b38\",\"to\":\"1df32985-7d4d-4dcf-805c-ff5b9ec1abc0\",\"start_timers\":[],\"blocking_timers\":[],\"abnormal_condition_only\":false}],\"timers\":[]}],\"storage\":{\"diagnostic_label\":\"Hot water boiler\",\"fill_level_label\":\"°C\",\"provides_leakage_behaviour\":false,\"provides_fill_level_target_profile\":false,\"provides_usage_forecast\":false,\"fill_level_range\":{\"start_of_range\":10,\"end_of_range\":80}}}",
"frbcAutoConfirmInstructions": false
},
{
"id": "33c4d8ff74eac73a",
"type": "inject",
"z": "d8a320bc185dd550",
"name": "every 10 s",
"props": [
{
"p": "payload"
}
],
"repeat": "10",
"crontab": "",
"once": true,
"onceDelay": "1",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 140,
"wires": [
[
"a3e57e828ee30d59"
]
]
},
{
"id": "a3e57e828ee30d59",
"type": "function",
"z": "d8a320bc185dd550",
"name": "Boiler simulator",
"func": "// Simulates a 200 l hot water boiler: integrates the instructed fill rate (°C per second) minus\n// a small hot-water draw, sends the temperature every tick, and confirms each instruction straight\n// away (a real flow would confirm once the heater actually switched).\nconst DRAW_PER_S = 0.0005 // °C per second taken out by hot water use\nconst now = Date.now()\nconst last = context.get('last') ?? now\nconst rate = context.get('rate') ?? 0\nlet temp = context.get('temp') ?? 45\ntemp = Math.min(80, Math.max(10, temp + (rate - DRAW_PER_S) * (now - last) / 1000))\ncontext.set('temp', temp)\ncontext.set('last', now)\n\nif (msg.topic === 'ActuatorInstruction') {\n context.set('rate', msg.payload.fillRate)\n node.status({ fill: 'blue', shape: 'dot', text: `${msg.payload.operationModeLabel} - ${temp.toFixed(1)} °C` })\n return { topic: 'ActuatorConfirmation', payload: msg.payload, cemId: msg.cemId }\n}\nif (msg.topic === 'Selected' || msg.topic === 'Deselected' || msg.topic === 'Revoked') return null\nnode.status({ fill: 'grey', shape: 'ring', text: `${temp.toFixed(1)} °C` })\n// A plain number is the fill level, here the water temperature.\nreturn { payload: Math.round(temp * 10) / 10 }",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 140,
"wires": [
[
"d14f2d7c29405690"
]
]
},
{
"id": "30c1b5ae105df76e",
"type": "debug",
"z": "d8a320bc185dd550",
"name": "debug - instructions",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 660,
"y": 200,
"wires": []
}
]
14 changes: 8 additions & 6 deletions resources/s2-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,24 @@ window.__s2Common.versionAtLeast = function (version, minimum) {
}

// Keeps a dialog's Update or Done button $ok disabled until a delayed check of its values passes,
// and shows the check's errors in $err. check(done) calls done({ valid, errors }). Pass the button
// and error box found in oneditprepare, and let check read inputs captured there with val(). The
// timer may fire after the dialog closed, or while the "..." JSON editor has it detached: then a
// lookup by id finds nothing, typedInput() throws, and another dialog's button may have that id.
// and shows the check's errors, if any, in $err. check(done) calls done({ valid, errors }). Pass
// the button and error box found in oneditprepare, and let check read inputs captured there with
// val(). The timer may fire after the dialog closed, or while the "..." JSON editor has it
// detached: then a lookup by id finds nothing, typedInput() throws, and another dialog's button
// may have that id.
window.__s2Common.validationGate = function ($ok, $err, check) {
let timer = null
let seq = 0

function set (result) {
const valid = !!result.valid
$ok.prop('disabled', !valid).toggleClass('ui-state-disabled', !valid)
if (valid) {
const errors = result.errors || []
if (valid || errors.length === 0) {
$err.hide()
} else {
$err.empty()
;(result.errors || []).forEach(function (e) { $('<div>').text(e).appendTo($err) })
errors.forEach(function (e) { $('<div>').text(e).appendTo($err) })
$err.show()
}
}
Expand Down
Loading
Loading