Special
Special blocks provide essential control over program execution and event handling. These blocks let you create the main program loop, handle MQTT events, and build event-driven device behaviors.
task

The main execution loop for your script. This block repeatedly executes the code inside it at a specified interval. Every script requires exactly one task block - it serves as your program's entry point and controls when your device logic runs.
Parameters:
Iterations (Number): How many times to run. Set to
0for infinite execution (most common)Interval (Number): Time between executions in milliseconds
Example:

task pass

Returns the current iteration counter for the task. Useful for creating behaviors that change over time or execute only on specific iterations.
Returns:
Number:
-1for infinite tasks (iterations = 0), otherwise counts down fromn-1to0
This block only works inside a task block. Using it elsewhere will cause an error.

Example:

is event
Checks whether a specific MQTT event is waiting in the queue. Use this to conditionally process events when they arrive.
Parameters:
Event Name (String): The name of the event to check for
Returns:
Boolean:
#t(true) if the event exists in the queue,()(false) if not
This block returns true as long as the event remains in the queue. To remove the event, use the pop event block.
Example:

pop event
Retrieves and removes the oldest event of the specified type from the queue. Use this to access event data sent via MQTT.
Parameters:
Event Name (String): The name of the event to retrieve
Returns:
Number: The event payload value, or
()(empty) if no event exists
Event payloads are always of type Number. If you need to send other data types, encode them as numbers.
Example:

push event

Sends an event with a value to the MQTT broker. Use this to publish sensor readings, status updates, or trigger actions on other devices or dashboards.
Parameters:
Event Name (String): The name of the event to publish
Value (Number/Boolean): The value to send
Event payloads are always sent as Number type. Boolean values are automatically converted: true → 1, false → 0.
Example:

Last updated
