Skip to content

WITH Functional Keyword

Feature Since Version Notes
WITH >v1.4.6 Specifies attributes/values

1. Overview

  • Description: The WITH keyword is a versatile connector used in many LOT constructs. Its primary role is to associate a value or detail with a preceding keyword or identifier.

2. Usage Contexts

WITH is commonly used in the following scenarios:

  1. PUBLISH TOPIC ... WITH <value>: Specifies the payload to be published.
  2. KEEP TOPIC ... WITH <value>: Specifies the value to be stored internally.
  3. DEFINE MODEL <Name> WITH TOPIC "<baseTopic>": Specifies the base output topic for the model.
  4. DEFINE RULE <Name> WITH PRIORITY <value>: Specifies the priority of the rule.
  5. DEFINE ROUTE <Name> WITH TYPE <type>: Specifies the type of the route (e.g., MQTT_BRIDGE).
  6. ADD "<propName>" WITH <definition> (in Models): Specifies the definition (value, expression, topic reference) of a model property.
  7. ADD ... WITH <configOption> <value> (in Routes): Specifies configuration options for source, destination, or mappings.
  8. SET "<varName>" WITH <value>: An alternative syntax for assigning values to temporary variables (often = is used).

3. Syntax Examples

Refer to the documentation for the specific keywords that utilize WITH for detailed syntax and examples:

General Pattern:

<Some Keyword or Identifier> WITH <Attribute or Value>

Specific Examples:

PUBLISH TOPIC "status" WITH "active"

DEFINE MODEL MyModel WITH TOPIC "output/base"

DEFINE RULE MyRule WITH PRIORITY 1

ADD "temperature" WITH TOPIC "sensors/temp"

ADD SOURCE_CONFIG WITH BROKER_ADDRESS "127.0.0.1"

ADD MAPPING Map1 WITH SOURCE_TOPIC "in/#"

4. Notes & Additional Information

  • WITH acts as a bridge linking a keyword/identifier to its associated parameters or values.
  • Its exact meaning depends on the context provided by the preceding keyword (PUBLISH, DEFINE, ADD, etc.).