Special

Special blocks provide essential control over program execution and event handling in your IoT system. These blocks enable you to:

  • Control program timing and execution

  • Handle MQTT events

  • Manage program state

  • Create event-driven behaviors

task

Creates a recurring task that executes at specified intervals. This is the primary execution loop required in every script - only one task block is allowed per script as it serves as the main program loop.

Parameters:

  • Iterations (Number): How many times to run (0 for infinite)

  • Interval (Number): Time between executions in milliseconds

Example:

Read temperature every 5 seconds and send an event with the value

task pass

Returns the current task iteration count. For infinite tasks (0 iterations), returns -1.

Returns:

  • Number (Number): -1 if infinite; otherwise a countdown from n-1 to 0

Example:

Create LED patterns based on iteration

A custom iterator implementation.

is event

Checks if a specific MQTT event exists in the queue.

Parameters:

  • Event Name (String): Name of the event to check

Returns:

  • Boolean: #t if event exists, () if not

Example:

Check and retrieve an event

pop event

Retrieves and removes the oldest event of the specified type from the queue.

Parameters:

  • Event Name (String): Name of the event to retrieve

Returns:

  • Value: The event value, or () if no event exists

Example:

Check and retrieve an event

push event

Sends an event with a value to the MQTT broker.

Parameters:

  • Event Name (String): Name of the event

  • Value: Value to send (number or boolean)

Example:

Send sensor readings

Last updated