Files
app/docs/concepts/values.md
T
stroblme b2aa932b6d
Docs / docs (push) Successful in 26s
Playwright Tests / test-playwright (1, 2) (push) Failing after 4m7s
Playwright Tests / test-playwright (2, 2) (push) Failing after 2m30s
pre-commit / pre-commit (push) Failing after 2m42s
Test Backend / test-backend (push) Failing after 3m3s
Compose Smoke Test / test-compose (push) Successful in 32s
Playwright Tests / merge-reports (push) Successful in 1m51s
docs
2026-10-13 10:02:20 +02:00

61 lines
2.1 KiB
Markdown

# Where a node's values come from
Function nodes receive values as named arguments. Each comes from a message
port, a node setting or a Python default.
## Ports: what the graph carries
A port binds to a message name and reads its current value. Declare inputs
`reading` and `setpoint`, and output `heat`:
```python
def process(reading, setpoint):
return {"heat": reading < setpoint}
```
Matching message names connect nodes. A port can have a different name from
its message: bind port `reading` to `house.temperature`, for example.
## Settings: constants of this node
Use settings for values that stay fixed while the flow runs: units, retries,
thresholds. Add them in the Function node's **Settings** section; they are
stored with the flow and passed beside the ports:
```python
def process(reading, unit="C"):
return {"shown": reading if unit == "C" else reading * 1.8 + 32}
```
With a `unit` setting, its configured value is passed to the function. Without
one, the Python default applies. A setting cannot share a name with a port.
Changing a setting edits the flow draft, so publish it to apply the change.
For a value that should change at runtime, use a message. To share a constant
between nodes, publish it from one node and let the others consume it.
## Flow inputs: what arrives from outside
Dashboard controls, the API and batch runs can supply messages without a
producer node. Declare them as **Inputs** in the flow settings:
```json
{"inputs": [{"spec": {"name": "setpoint", "dtype": "float"}, "initial": 21.0}]}
```
The initial value seeds an unset live message. Later publications take over;
changing the starting value does not overwrite a value already in state.
Use **Publish this value now** in the input row to send it immediately.
The canvas draws flow inputs as labelled endpoints. Without a producer or
declared input, a consuming node reports `unconnected_input`.
A batch flow's inputs are run parameters. Its **Result** section selects the
messages returned when the run finishes. See [Runs](runs.md).
## See also
- [Flows, nodes and messages](flows.md)
- [Keeping state in a flow](state.md)
- [Writing node code](../code/nodes.md)