Skip to content

Commit 1896622

Browse files
authored
plugins: in/out transform (#1021)
1 parent e45b0e1 commit 1896622

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

docs/devices/plugins.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,15 @@ charger:
484484
// maxcurrent Variable ist automatisch verfügbar
485485
```
486486

487-
#### Input-Transformationen verwenden
487+
#### Input- und Output-Transformationen {#transformations}
488+
489+
Die `go` und `js` Plugins unterstützen `in` und `out` Parameter, um Daten aus anderen Quellen als Variablen im Script zu verwenden bzw. das Ergebnis an andere Plugins weiterzuleiten.
490+
491+
##### Input-Transformationen (`in`)
488492

489493
Mit dem `in` Parameter können Werte aus anderen Quellen als Variablen im Script verwendet werden.
494+
Jeder Eintrag benötigt `name` (Variablenname im Script), `type` (`bool`, `int`, `float`, `string`) und `config` (Plugin-Konfiguration).
495+
490496
Dieses Beispiel zeigt eine bedingte Logik, die mit den einfachen Calc-Operationen nicht möglich ist:
491497

492498
```yaml
@@ -514,6 +520,29 @@ power:
514520
value: false
515521
```
516522

523+
##### Output-Transformationen (`out`)
524+
525+
Mit dem `out` Parameter kann das Ergebnis eines Scripts an andere Plugins weitergeleitet werden.
526+
Dies ist besonders nützlich im Schreibkontext, wenn das Script-Ergebnis z. B. per MQTT oder HTTP weiterverarbeitet werden soll.
527+
Jeder Eintrag benötigt `name`, `type` und `config` — analog zu `in`.
528+
529+
```yaml
530+
chargers:
531+
- name: smart-heater
532+
type: custom
533+
maxcurrent:
534+
source: go
535+
script: |
536+
watts := maxcurrent * 230
537+
watts
538+
out:
539+
- name: watts
540+
type: float
541+
config:
542+
source: mqtt
543+
topic: heater/target_power
544+
```
545+
517546
### HTTP <Tag label="lesen" category="read" /> <Tag label="schreiben" category="write" /> {#http}
518547

519548
Das `http`-Plugin führt HTTP Aufrufe durch, um Daten zu lesen oder zu aktualisieren.
@@ -641,6 +670,8 @@ charger:
641670
console.log(maxcurrent);
642671
```
643672

673+
Das `js` Plugin unterstützt dieselben [Input- und Output-Transformationen](#transformations) (`in`/`out`) wie das `go` Plugin.
674+
644675
### Modbus <Tag label="lesen" category="read" /> <Tag label="schreiben" category="write" /> {#modbus}
645676

646677
Das `modbus`-Plugin kann Daten von jedem Modbus-fähigen Gerät oder SunSpec-kompatiblen Wechselrichter lesen.

i18n/en/docusaurus-plugin-content-docs/current/devices/plugins.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,15 @@ charger:
484484
// maxcurrent variable is automatically available
485485
```
486486

487-
#### Using Input Transformations
487+
#### Input and Output Transformations {#transformations}
488+
489+
The `go` and `js` plugins support `in` and `out` parameters to use values from other sources as variables in the script or to forward the script result to other plugins.
490+
491+
##### Input Transformations (`in`)
488492

489493
The `in` parameter allows you to use values from other sources as variables in your script.
494+
Each entry requires `name` (variable name in the script), `type` (`bool`, `int`, `float`, `string`) and `config` (plugin configuration).
495+
490496
This example shows conditional logic that cannot be achieved with simple Calc operations:
491497

492498
```yaml
@@ -514,6 +520,29 @@ power:
514520
value: false
515521
```
516522

523+
##### Output Transformations (`out`)
524+
525+
The `out` parameter forwards the script result to other plugins.
526+
This is particularly useful in a writing context, e.g. when the script result should be further processed via MQTT or HTTP.
527+
Each entry requires `name`, `type` and `config` — analogous to `in`.
528+
529+
```yaml
530+
chargers:
531+
- name: smart-heater
532+
type: custom
533+
maxcurrent:
534+
source: go
535+
script: |
536+
watts := maxcurrent * 230
537+
watts
538+
out:
539+
- name: watts
540+
type: float
541+
config:
542+
source: mqtt
543+
topic: heater/target_power
544+
```
545+
517546
### HTTP <Tag label="read" category="read" /> <Tag label="write" category="write" /> {#http}
518547

519548
The `http` plugin performs HTTP calls to read or update data.
@@ -641,6 +670,8 @@ charger:
641670
console.log(maxcurrent);
642671
```
643672

673+
The `js` plugin supports the same [input and output transformations](#transformations) (`in`/`out`) as the `go` plugin.
674+
644675
### Modbus <Tag label="read" category="read" /> <Tag label="write" category="write" /> {#modbus}
645676

646677
The `modbus` plugin can read data from any Modbus-capable device or SunSpec-compatible inverter.

0 commit comments

Comments
 (0)