# Litmus Edge Analytics Processors (LE 4.0.x)

> You are at https://api.litmus.io/reference/analytics-processors.md
> Parent: https://api.litmus.io/agents.md
> This is a reference, not a router. For routing start at /agents.md.

Catalog of analytics processors available on a Litmus Edge 4.0.x device, with their config parameters and required wire definitions. **56 processors** in this build, sourced live from `GetProcessorsMetadata` (`POST {edgeUrl}/analytics/v3`). The catalog is device-specific; query metadata on your own device if a processor referenced elsewhere is missing here.

A pipeline is always **SOURCE -> TRANSFORM(s) -> SINK**, wired together (or just SOURCE -> SINK if no math is needed). Processor roles below come from the API's `ConnectDirection`: `outputOnly`=SOURCE, `inputOnly`=SINK, `inputOutput`=TRANSFORM.

**Required wire definitions** name input slots the operator must wire by name on the consumer's `InputsDefinitions` (e.g. `{ "manufactureEnd": "<producer-id>" }`). Only three processors declare any; everything else is single-input or zero-input. See `/workflows/build-analytics-pipeline.md` for wiring mechanics.

## SOURCE (4)

### `Database Batch Input` (Connect)
Polls a time-series DB measurement on a timer or `Invoke` trigger and emits rows downstream. Supports SQL-style `filter` (e.g. `"tag" = 'tag1' AND "success" = 1`); standard device fields available include `datatype`, `device_id`, `register_id`, `success`, `tag`, `topic`, `value`.
- **Params:** `ignore_failed_data`, `ignore_null_value`, `database`, `metric_name`, `typed`, `period_secs`, `filter`

### `DataHub Subscribe`
Subscribes to a DataHub topic and emits each message as a downstream event. `topic` is required (no default). `ignore_null_value` and `ignore_failed_data` drop messages where `value` is null or `success=false`.
- **Params:** `topic`, `ignore_failed_data`, `ignore_null_value`

### `Generator`
Synthetic value generator for testing pipelines (sine, square, sawtooth, or formula using `t`). `timerInterval` controls emission rate; `formula`, `strength`, `periodicity`, `amplitude_multiplier`, `generatorType` shape the waveform.
- **Params:** `timerInterval`, `formula`, `strength`, `periodicity`, `amplitude_multiplier`, `generatorType`

### `Inject`
Emits a fixed payload on demand (`Invoke`), on a timer, or on a day-of-week schedule. `inject_field` and `inject_value` are required; `timing_mode` picks between timer (`timer_interval_type` + `timer_interval_value`) and weekly schedule (`monday`...`sunday` plus `execution_time`).
- **Params:** `inject_value_type`, `inject_value`, `execution_time`, `tuesday`, `thursday`, `friday`, `add_timestamp`, `timer_interval_type`, `wednesday`, `saturday`, `timing_mode`, `timer_interval_value`, `monday`, `sunday`, `inject_field`

## TRANSFORM (47)

### `AI` (Functions)
Sends the input message to a configured AI model as a prompt and emits the response. `ai_model` selects the deployed model; `system_prompt` shapes behavior; `temperature` (default 1.0) controls randomness; `max_completion_tokens` caps output length; enable `force_response_format_to_JSON?` for strict JSON output (you still must instruct JSON in the prompt).
- **Params:** `temperature`, `max_completion_tokens`, `force_response_format_to_JSON?`, `timerInterval`, `pass_through_value`, `ai_model`, `HTTP_timeout`, `system_prompt`

### `AI Responses` (Functions)
Multi-turn AI generation with optional web search (`enable_web_search`), code execution (`enable_code_execution`), and conversation memory (`max_message_history`). Driven on demand via `Invoke`. `ai_model_instructions` is the persistent system role.
- **Params:** `ai_model_instructions`, `pass_through_value`, `ai_model`, `HTTP_timeout`, `advanced_thinking_/_reasoning`, `enable_web_search`, `max_output_tokens`, `max_message_history`, `file_download_timeout`, `timerInterval`, `enable_code_execution`

### `AI Vision` (Functions)
Sends an image to a vision-capable AI model. Image source is either `file_path_for_image` (local file; supersedes payload) or a base64 image in the input payload. Accepts `jpg`, `png`, `gif`.
- **Params:** `system_prompt`, `temperature`, `max_completion_tokens`, `timerInterval`, `pass_through_value`, `ai_model`, `HTTP_timeout`, `file_path_for_image`

### `Anomaly Detection` (Functions)
Flags values outside N standard deviations of a rolling window's mean (3-sigma rule). Tune via `window_size` and `deviations`; `control_chart_mode?` bypasses the seasonality-tracking window expansion. Output adds `moving_average`, `moving_std_deviation`, `upper_limit`, `lower_limit`, `total_anomalies`, and replaces `value` with the anomaly flag when triggered.
- **Params:** `pass_through_value`, `topic_reset`, `control_chart_mode?`, `deviations`, `window_size`

### `ARIMA Filter` (Functions)
Auto-Regressive Integrated Moving Average model fit over a rolling `window_size` with optional `seasonality_size` and `number_of_models` for ensemble averaging.
- **Params:** `number_of_models`, `pass_through_value`, `window_size`, `seasonality_size`

### `Asset Online Percentage` (KPI)
Percentage of time the input tag was online (per its `success` field) over a configurable hour-of-day window. Set `start_hour` and `end_hour`; outputs `asset_online` as a percentage with the current timestamp.
- **Params:** `timerInterval`, `pass_through_value`, `device_reset`, `start_hour`, `end_hour`

### `Base Conversion` (Functions)
Converts numeric `value` between decimal, binary, octal, and hexadecimal bases. Non-decimal input must arrive as a string in `value`. Pick direction via the `conversion` enum.
- **Params:** `conversion`, `pass_through_value`

### `Change`
Edits the incoming message: `set` a field, `change` (find and replace a value), `delete` a field, or `move` one field to another. Set `mode`, `input_field`, `input_value`, `replace_with_value`; `update_timestamp` stamps the message after the edit.
- **Params:** `replace_with_value_type`, `replace_with_value`, `move_to_field`, `update_timestamp`, `mode`, `input_field`, `input_value_type`, `input_value`

### `Change of Value` (KPI)
Emits the input message only when `map_field_name` differs from the previous value by more than `delta_of_tolerance`. No output when the value is steady. `map_field_name` can be `value`, `asset_online`, or any payload field.
- **Params:** `map_field_name`, `delta_of_tolerance`, `timerInterval`, `pass_through_value`

### `Combination Processor` (Functions)
Combines fields from multiple input wires into one JSON output. Reference fields as `<wirename>_<fieldName>` in `fields_to_combine`. Pick `combination_type` and `what_timestamp_to_take?` to resolve timestamp collisions.
- **Params:** `combination_type`, `what_timestamp_to_take?`, `fields_to_combine`, `pass_through_value`

### `Compliance and Loss` (KPI)
Computes compliance percentage and production loss percentage. Requires two wire definitions: `manufactureEnd` (event trigger when a manufacturing cycle ends) and `defectiveUnit` (event trigger when a defective unit is discovered). Configure the in-range numeric ranges via `manufacture_from`/`manufacture_to` and `defective_from`/`defective_to`.
- **Params:** `manufacture_to`, `defective_from`, `defective_to`, `timerInterval`, `pass_through_value`, `manufacture_from`
- **Required wire definitions:**
  - `manufactureEnd` -- event trigger when a manufacturing cycle ends
  - `defectiveUnit` -- event trigger when a defective unit is discovered

### `Conversion` (Functions)
Built-in unit conversions for common engineering units (e.g. temperature, pressure). Pick the conversion from the `conversion` enum.
- **Params:** `conversion`, `pass_through_value`

### `Delay/Rate-Limit`
Throttles message flow either by delay (`delay_mode`: fixed, random between `delay_random_time_from`/`_to`, or payload-driven `delay` field) or rate limit (`rate_mode`: global or per-topic, configured via `rate_msg_count` per `rate_msg_time`). `action` chooses queue (buffered, max 1000) vs drop. Supports payload-based rate override via `rate_override_from_payload`.
- **Params:** `delay_mode`, `delay_time_units`, `delay_random_time_from`, `rate_mode`, `rate_msg_count`, `rate_msg_time`, `delay_time`, `delay_random_time_from_units`, `delay_random_time_to`, `delay_random_time_to_units`, `rate_msg_time_units`, `rate_override_from_payload`, `rate_intermediate_mode`, `action`

### `Expression` (Functions)
Evaluates a math/logical formula over named wire inputs. Each upstream wire's connecting name becomes a slot; reference it as `<wireName>_value` (e.g. formula `(Celsius_value * 9/5) + 32` requires a wire named `Celsius`). Supports `+ - * / % **`, comparators `< > <= >= == !=`, regex `=~ !~`, logical `&& ||`, ternary `?:`, and `sin/cos/exp/log/sqrt/abs`. `output_field_name` names the emitted field (default `value`).
- **Params:** `pass_through_value`, `expression`, `output_field_name`, `timerInterval`

### `Feature Extractor` (Functions)
Computes statistical features over a `window_size`: mean (`average`), `standard_deviation`, `variance`, `minimum`, `maximum`, `median`, `kurtosis`, `skewness`, `quartiles`, `inter_quartile_range`, `root_mean_square`, `zero_crossing_rate`, `mean_absolute_deviation`, `average_absolute_variation`. Each feature is toggled by its own bool param.
- **Params:** `average`, `standard_deviation`, `variance`, `timerInterval`, `minimum`, `kurtosis`, `inter_quartile_range`, `mean_absolute_deviation`, `pass_through_value`, `window_size`, `skewness`, `zero_crossing_rate`, `quartiles`, `maximum`, `median`, `root_mean_square`, `average_absolute_variation`

### `FileReader`
Reads a file from disk and emits its contents. `file_name` can be static or sourced from incoming payload's `filename` field, or computed via `generate_filename_from_expression`. `input_file_type` selects `value`, CSV, JSON, or binary; for CSV, `csv_columns_mode` (`indexed`/`from header`/`custom`) and `csv_custom_columns` shape the schema. `data_output_mode` chooses one-message-per-file vs one-message-per-record.
- **Params:** `file_name`, `input_file_type`, `csv_columns_mode`, `csv_custom_columns`, `generate_filename_from_expression`, `file_size_limit_in_mb`, `timer_interval_in_seconds`, `data_output_mode`, `csv_comma`

### `Gaussian Filter` (Functions)
Applies a Gaussian smoothing filter over a rolling window using its mean and `number_of_deviations`.
- **Params:** `window_size`, `number_of_deviations`, `timerInterval`, `pass_through_value`

### `Inputs Average`
Computes the arithmetic mean of `field_name` across multiple input wires. `processing_type` chooses event-driven vs synchronized (value-wire) aggregation.
- **Params:** `processing_type`, `field_name`, `pass_through_value`

### `Inputs Maximum`
Computes the max of `field_name` across multiple input wires. `processing_type` chooses event-driven vs synchronized aggregation.
- **Params:** `processing_type`, `field_name`, `pass_through_value`

### `Inputs Minimum`
Computes the min of `field_name` across multiple input wires. `processing_type` chooses event-driven vs synchronized aggregation.
- **Params:** `processing_type`, `field_name`, `pass_through_value`

### `Inputs Sum`
Computes the cumulative sum of `field_name` across multiple input wires. `processing_type` chooses event-driven vs synchronized aggregation.
- **Params:** `pass_through_value`, `processing_type`, `field_name`

### `JavaScript processor` (Functions)
Runs operator-provided JavaScript over the input(s). Input is exposed as the `values` array; iterate `for (i, message) in values` where `i` is the wire's connecting-definition name (for multi-input routing) and `message` is the payload. Supports add/remove/rename of any field.
- **Params:** `script`, `pass_through_value`

### `Join Processor`
Joins values from multiple wires into one record. `output_mode` chooses `map` (JSON-shaped, good for DB output) or `array`. `map_field_prefix` namespaces output fields; `input_source` keys by device name (requires `deviceName`+`tagName` in input) or by wire-definition name. `array_sort_by` and `array_sort_order` order array output.
- **Params:** `attach_devices`, `array_sort_by`, `array_sort_order`, `timestampOrder`, `pass_through_value`, `map_field_prefix`, `field`, `output_mode`, `input_source`

### `JSONata`
Transforms the input payload via a JSONata schema. Event-wire input lets you reference fields directly (e.g. `value`, `tagName`); value-wire input requires `wirename.fieldname` references (e.g. `Input_1.value`) and buffers each wire's last message until all are present.
- **Params:** `jsonata_schema`

### `Linear Prediction` (Functions)
Forecasts `number_of_predictions` future values via ordinary least-squares linear regression over the last `window_size` values. Outputs slope, intercept, prediction, and residual.
- **Params:** `window_size`, `number_of_predictions`, `polling_interval`, `timerInterval`, `pass_through_value`

### `Maintenance/Failure` (KPI)
Counts maintenance and failure events per cycle, time since last event, and timestamps of last events. Requires two wire definitions: `maintenance` (event trigger on maintenance event) and `failure` (event trigger on fault/failure event). Configure the in-range numeric ranges via `maintenance_from`/`maintenance_to` and `failure_from`/`failure_to`; `unit` sets the aggregation period.
- **Params:** `failure_from`, `failure_to`, `unit`, `timerInterval`, `pass_through_value`, `maintenance_from`, `maintenance_to`
- **Required wire definitions:**
  - `maintenance` -- event trigger on a maintenance event
  - `failure` -- event trigger on a fault/failure event

### `Manufacture Counter` (KPI)
Counts units manufactured per `unit` (hour/day/week/month) and reports capacity utilization vs `ideal_count`. Counter advances on the end-of-manufacture event arriving on the input wire (per the prose, name the upstream wire `manufactureEnd`; the API does NOT enforce this, but the KPI will not advance without it).
- **Params:** `timerInterval`, `pass_through_value`, `device_reset`, `unit`, `ideal_count`, `from_value`, `to_value`

### `Moving Average`
Rolling arithmetic mean over the last `window_size` values of `field_name`. FIFO, no weighting. `processing_type` picks scalar-per-value vs windowed-output emission.
- **Params:** `processing_type`, `field_name`, `pass_through_value`, `window_size`

### `Moving Maximum`
Rolling max over the last `window_size` values of `field_name`. FIFO.
- **Params:** `pass_through_value`, `window_size`, `processing_type`, `field_name`

### `Moving Minimum`
Rolling min over the last `window_size` values of `field_name`. FIFO.
- **Params:** `pass_through_value`, `window_size`, `processing_type`, `field_name`

### `Normalization` (Functions)
Normalizes each value to [0,1] over a rolling `window_size`. `mode` picks the normalization formula.
- **Params:** `mode`, `window_size`, `pass_through_value`

### `Online and Offline` (KPI)
Reports total ON and OFF durations of the input tag (per its `success` field), aggregated by `unit`. With `reset_on_status_change=true`, reports per-segment duration instead of cumulative.
- **Params:** `device_reset`, `reset_on_status_change`, `unit`, `timerInterval`, `pass_through_value`

### `PLC Uptime/Downtime Tracker` (KPI)
Tracks PLC uptime/downtime by matching incoming `value` against `uptime_value` (default 1) and `downtime_value` (default 0). Emits `system_status` (`uptime`/`downtime`), `last_downtime`, `current_downtime_period`, `time_since_last_downtime`, `current_uptime_period`, `last_uptime_timestamp`.
- **Params:** `downtime_value`, `uptime_value`, `timerInterval`, `pass_through_value`

### `Production Time/ CTR` (KPI)
Computes actual production time and Cycle Time Ratio (current vs `ideal_cycle_time`). Requires two wire definitions: `manufactureStart` (event trigger on start of manufacturing) and `manufactureEnd` (event trigger on end of manufacturing cycle). Configure in-range numeric ranges via `manufacture_start_from`/`_to` and `manufacture_end_from`/`_to`.
- **Params:** `manufacture_start_from`, `manufacture_start_to`, `manufacture_end_from`, `manufacture_end_to`, `ideal_cycle_time`, `timerInterval`, `pass_through_value`
- **Required wire definitions:**
  - `manufactureStart` -- event trigger on start of manufacturing
  - `manufactureEnd` -- event trigger on end of manufacturing cycle

### `Rise and Fall` (Functions)
Detects threshold-crossing events. Set `lower` and `upper` thresholds (with `tolerance`); emits the timestamp at which the value starts rising from `lower` and starts falling from `upper`, plus rise time and fall time in seconds.
- **Params:** `lower`, `tolerance`, `pass_through_value`, `kpi`, `upper`

### `Rounding` (Functions)
Rounds the input to `digits` decimal places using one of `RoundNearest`, `RoundUp`, `RoundDown`, or `RoundEven` (set via `method`). `digits=0` returns the integer part; `RoundEven` ignores `digits`.
- **Params:** `digits`, `method`, `pass_through_value`

### `Signal Decomposition` (Functions)
Decomposes the signal into Trend + Seasonality + Residue (`model_type=additive`) or Trend * Seasonality * Residue (`multiplicative`). Trend via linear regression, seasonality via naive differencing over `periodicity` lag.
- **Params:** `model_type`, `periodicity`, `pass_through_value`, `window_size`

### `Simple Window`
Maintains a FIFO window of size `window_size` over the input value and passes the window downstream as-is (no aggregation). `order` controls emission ordering; `value_type` constrains the input type.
- **Params:** `order`, `window_size`, `pass_through_value`, `value_type`

### `SPC Charts` (Functions)
Statistical Process Control: current mean, stddev, USL/LSL, Cp, Cpk; with `target_mean` set also Cpm and Cpkm. Flags Nelson Rules 1 through 8 violations on the output (point-beyond-3-sigma, runs, trends, alternation, etc.).
- **Params:** `window_size`, `target_mean`, `timerInterval`, `pass_through_value`

### `Statistical Functions` (Functions)
Runs normality tests over a `window_size`: Jarque-Bera, Cramer-Von-Mises, Anderson-Darling, D'Agostino-Pearson, Kolmogorov-Smirnov. Each test is toggled by its own bool param; outputs test statistic and p-value.
- **Params:** `window_size`, `jarque_bera`, `anderson_darling`, `cramer_von_mises`, `d_agostino_pearson`, `kolmogorov_smirnov`, `pass_through_value`

### `Statistical Prediction` (Functions)
Forecasts via Fourier extrapolation: FFT on the rolling `window_size`, reconstruct as sum of `number_of_harmonics` sinusoids, extrapolate `number_of_predictions` steps ahead. `frequency_difference` sets the sampling rate of discretization (default 1 sec).
- **Params:** `pass_through_value`, `display_prediction_on_current_timestamp`, `window_size`, `number_of_predictions`, `frequency_difference`, `number_of_harmonics`

### `Switch`
Routes the input downstream only when the rule on `field_name` against `check_value` (of `check_value_type`) holds. `rule` supports `== != < <= > >= contains is true/false/null is of type`. `output` filters which downstream wire to publish to (empty = all).
- **Params:** `rule`, `field_name`, `check_value`, `check_value_type`, `output`

### `Tengo script processor` (Functions)
Runs operator-provided Tengo (GoLang-like) script over the input(s). Same multi-wire iteration model as JavaScript processor (`for (i, message) in values`); has access to Tengo's standard library and a per-call `timeout`.
- **Params:** `timeout`, `script`, `pass_through_value`

### `TensorFlow images processor` (ML)
Feeds images (color or `gray`) to a saved TensorFlow model at `model_path`. Configure `tags`, `input_operation`, `output_operation`, `image_format`, `time_shift_ms`.
- **Params:** `image_format`, `time_shift_ms`, `pass_through_value`, `model_path`, `tags`, `input_operation`, `output_operation`, `gray`

### `TensorFlow processor` (ML)
Feeds time-series tensors (`number_of_inputs` x `window_size`) to a saved TensorFlow model at `model_path`. Configure `tags`, `input_operation`, `output_operation`, `time_shift_ms`.
- **Params:** `window_size`, `time_shift_ms`, `pass_through_value`, `model_path`, `number_of_inputs`, `tags`, `input_operation`, `output_operation`

### `Up/DownTime by Value` (KPI)
Reports up and downtime durations by comparing the input value to `desired_value` using `condition` (`>`, `<`, `==`, `!=`). `delta_of_tolerance` forgives round-off; `unit` sets aggregation period.
- **Params:** `pass_through_value`, `device_reset`, `unit`, `condition`, `desired_value`, `delta_of_tolerance`, `timerInterval`

### `XMR Chart` (Functions)
Individuals-Moving-Range control chart: central line (constant after initial window), moving ranges, average moving range, upper and lower natural process limits via `process_limit_multiplier`. Auto-adjusts central line when the process shows persistent drift.
- **Params:** `process_limit_multiplier`, `timerInterval`, `pass_through_value`, `window_size`

## SINK (5)

### `Database Output`
Writes incoming messages to a time-series database measurement. Set `measurement` (required, no default) and optionally `database` (default `tsdata`) and `typed` (default `autogen`).
- **Params:** `typed`, `measurement`, `database`

### `DataHub Publish`
Publishes incoming messages to a DataHub topic. `topic` is static by default; enable `dynamic_topic` to build the topic from payload fields using `wirename_fieldname` syntax (the wire's connecting name leaks into the topic expression).
- **Params:** `single_topic`, `dynamic_topic`, `topic`

### `FileWriter`
Writes incoming messages to a file as CSV, Parquet, or raw value. Supports append/replace/delete via `file_write_method`, dynamic filenames via `generate_filename_from_expression`, scheduled re-writes via `timer_interval_in_seconds`, and column selection via `columns_from_payload` / `custom_columns`.
- **Params:** `file_name`, `file_write_method`, `add_new_line`, `csv_comma`, `columns_from_payload`, `custom_columns`, `output_file_type`, `create_directories`, `generate_filename_from_expression`, `timer_interval_in_seconds`, `csv_header`, `parquet_capacity`

### `ImagePreview`
Renders an image from a payload field for UI preview. `image_property_name` names the payload field holding image data; `image_name` is the label; `image_width_name` sets width (height auto-scales).
- **Params:** `image_name`, `image_property_name`, `image_width_name`

### `StdOut`
Prints incoming messages to the analytics service console. Debug only, no parameters.
- **Params:** none
