Pages

Output Script

What is Output Script?

Output Script is a flexible output element that lets you modify or calculate data before it’s shown in the UI.
You write your own JavaScript logic to transform live values from a connected source or create entirely new output based on conditions, rules, or expressions.

This allows for custom formatting, unit conversion, conditional display, and much more — all in real time.

Key Features

  • Uses your own JavaScript logic
  • Works with one or more connected input values
  • Output is calculated or formatted before display
  • Ideal for complex display needs (e.g. “if temperature > 50 → show ‘HOT’”)

When should you use it?

Use Output Script when:

  • You need to format, filter, or calculate values before showing them
  • You want to display logic-based messages (e.g. system status based on rules)
  • You work with non-standard units, conversions, or combined values
  • You want maximum control over the output content

Practical Examples

  1. Simple Value Formatting
    Use Case: Round a numerical input to one decimal and add unit °C.
return value.toFixed(1) + " °C";

What it does:
If the input is 23.678, the output will be 23.7 °C.

  1. Conditional Output
    Use Case: Show a warning message if value exceeds threshold.
if (value > 80) {
  return "⚠️ High Load!";
} else {
  return "Normal";
}

What it does:
Displays ⚠️ High Load! if the value is above 80, otherwise shows Normal.

  1. Convert Units (e.g., Celsius to Fahrenheit)
 let fahrenheit = value * 1.8 + 32;
return fahrenheit.toFixed(1) + " °F";

What it does:
Transforms a temperature value from Celsius to Fahrenheit and adds unit.

  1. Custom Logic with Multiple Inputs
    Scenario: You have two connected inputs: voltage and current. You want to calculate and display power.
return (voltage * current).toFixed(2) + " W";

Note: You must configure the input mapping properly so that voltage and current are accessible by name.

  1. Time Formatting from Seconds
    Use Case: Convert seconds into MM:SS format.
let minutes = Math.floor(value / 60);
let seconds = value % 60;
return minutes + ":" + (seconds < 10 ? "0" : "") + seconds;

What it does:
If input is 135, output will be 2:15.

Advantages

  • Extremely powerful and flexible
  • Works in real-time
  • Can output text, numbers, or formatted messages

Limitations

  • Requires basic understanding of JavaScript
  • Purely for display – not interactive
let minutes = Math.floor(value / 60); let seconds = value % 60; return minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
return (voltage * current).toFixed(2) + " W";
let fahrenheit = value * 1.8 + 32; return fahrenheit.toFixed(1) + " °F";
if (value > 80) { return "⚠️ High Load!"; } else { return "Normal"; }
return value.toFixed(1) + " °C";