Overview
This node, named ioBroker Output, allows users to write data to an ioBroker instance. It supports writing to different types of ioBroker entities: states, objects, files, and logs. The node connects to an ioBroker server via WebSocket using provided credentials and performs the requested write operation based on user input.
Common scenarios where this node is beneficial:
- Updating a state value in ioBroker, e.g., changing a sensor reading or toggling a device.
- Creating or modifying an object definition within ioBroker.
- Writing or updating files managed by ioBroker, such as configuration or visualization files.
- Sending log messages to ioBroker's logging system for monitoring or debugging purposes.
Practical examples:
- Writing a temperature value to a state ID like
javascript.0.temperatureSensor. - Creating a new device object with specific properties.
- Uploading a JSON configuration file to
main/vis-views.JSON. - Logging an error message to ioBroker logs with level "error".
Properties
| Name | Meaning |
|---|---|
| Type | The type of entity to write to. Options: - State: Write to a state. - Object: Write to an object. - File: Write to a file. - Logs: Write a log message. |
| Object ID | The ioBroker object ID to write to (e.g., javascript.0.myObject). Required when Type is State, Object, or File. |
| File Name | The name/path of the file to write (e.g., main/vis-views.JSON). Required when Type is File. |
| Value | The value to write. For states and objects, can be a JSON string or object. For logs, must be a string. |
| Log Level | The severity level of the log message. Options: Info, Debug, Warning, Error. Shown only when Type is Logs. |
Output
The node outputs the original input data array, potentially augmented with error information if any item failed during execution and "Continue On Fail" is enabled.
- The output JSON corresponds to the input items.
- If an error occurs on an item and "Continue On Fail" is active, the output item will include an
errorfield describing the failure. - No binary data output is produced by this node.
Dependencies
- Requires an API key credential for connecting to the ioBroker server, including host and port.
- Uses a WebSocket connection to communicate with ioBroker's AdminConnection interface.
- The node depends on the
IobrokerConnectionclass which manages connection, authentication, and commands over WebSocket. - The node expects the ioBroker server to support the relevant socket.io API endpoints for states, objects, files, and logs.
Troubleshooting
Common issues:
- Invalid JSON for Object or State values: When writing objects or complex state values, the input must be valid JSON. Invalid JSON strings will cause errors.
- Non-existent Object IDs: Attempting to write to a state or object ID that does not exist will throw an error.
- Type mismatches: Writing a value that does not match the expected type of the target state (number, boolean, string) will result in an error.
- Connection failures: Incorrect host or port, or network issues, will prevent connection to ioBroker.
- Permission errors: Insufficient permissions on the ioBroker server may block write operations.
Common error messages and resolutions:
"Value for OID ... must be a valid JSON object."
Ensure the value is a properly formatted JSON string or a JavaScript object."Object with OID ... does not exist."
Verify the object ID exists in ioBroker before writing."OID ... is not a state object."
Confirm the target object is of type "state" when writing state values."Value for OID ... must be a number/boolean/string."
Match the value type to the expected type defined in the object's common.type property.Connection errors such as
"Connection error: ..."
Check network connectivity, host, port, and credentials.
Links and References
- ioBroker WebSocket Client GitHub - Reference implementation of the WebSocket client used.
- ioBroker Documentation - Official documentation for ioBroker concepts and APIs.
- n8n Documentation - General n8n usage and node development guides.
Summary of execute() method logic
- Connects to ioBroker server using credentials (host and port).
- Iterates over each input item.
- Reads parameters:
type,oid,val, and optionallyfileNameorlevel. - Depending on
type:- object: Parses
valas JSON if string, then callssetObject(oid, val). - state: Retrieves the object by
oid. Validates it exists and is a state. Checks the state's expected type (number,boolean,string) and converts/parsesvalaccordingly. CallssetState(oid, val)with proper structure. - file: (Not fully shown in code snippet but implied by properties; likely writes file content.)
- log: Sends a log message with given
valand log level.
- object: Parses
- Catches errors per item; if "Continue On Fail" is enabled, appends error info to output; otherwise throws.
- Returns the processed items as output.
This node provides flexible writing capabilities to ioBroker entities, enabling automation workflows to update states, objects, files, or logs dynamically.