GlowDash scripts are used in Action panels, worker functions in switches and the CommandLibrary functions.
The scripts is line-by-line interpreted, every line can contains on one command without any terminator. Lines starting with
//are comments. All variables are strings, but commands and operators interpret them as decimals or booleans as needed.
| Command | Brief Description |
|---|---|
| If | Conditional execution |
| Else | Alternate branch for If |
| EndIf | End of If block |
| While | Loop while condition is true |
| EndWhile | End of While loop |
| Return | Exit script (or function), optionally with a value |
| PrintConsole | Print text to the console (standard output) |
| PrintGlowdashConsole | Print text to the GlowDash console |
| Set | Set a variable to the value (And define if necessary) |
| Run | Run a named ProgramLibrary element |
| RunSet | Run ProgramLibrary and store return value in a variable |
| AddTo | Add a value to a variable |
| SubFrom | Subtract a value from a variable |
| MulWith | Multiply a variable by a value |
| DivWith | Divide a variable by a value |
| RoundDown | Round variable down |
| RoundUp | Round variable up |
| RoundMath | Round variable mathematically |
| AddMinutesToTime | Add minutes to a time string |
| WaitMs | Wait for milliseconds |
| CallHttp | Call an HTTP request (ignore result) |
| CallHttpStoreJson | Call HTTP and store JSON result |
| SetFromJsonReq | Extract a JSON element from HTTP response |
| SetFromStoredJson | Extract an element from stored JSON |
| RelatedPanel | Refresh related panels |
| LoadVariablesFromPanelId | Load variables from a panel |
| LoadVariablesFromPanelIdWithPrefix | Load variables with a prefix |
| PrintVariablesConsole | Print all variables to the console (standard output) |
| PrintVariablesGlowdashConsole | Print all variables to the GlowDash console |
| AddOneshotSchedule | Add a one-shot schedule |
| ModbusTcp | Read or write a Modbus TCP register or coil |
| ShellyRelay | Read or write Shelly devices (relay/cover) |
GlowDash scripts are normally stateless: each script execution runs independently and local variables do not persist between events. However, some use cases require sharing data between different script executions during the program's runtime (for example, implementing virtual switches or caching intermediate values).
To support this, GlowDash provides runtime state variables accessible through the state. prefix.
Variables whose names start with state. refer to a shared, in-memory storage that:
- Is global to the running GlowDash instance
- Is accessible from all scripts
- Persists between script executions
- Exists only during program runtime (not saved to disk)
- Is cleared when GlowDash restarts
This allows scripts triggered by different events to exchange data safely without introducing persistent storage.
State variables are used in the same way as normal variables, but with the state. prefix.
Set state.myflag true
If state.myflag booleq true
...
EndIf
At the Glowdash start the GlowdashStart library function is automatically started.
You can set state. variables there.
Runtime state variables are useful for:
- Virtual devices (e.g., software switches)
- Event coordination between scripts
- Temporary flags or counters
- Simple in-memory caching
- Remembering values between triggers
They are not intended for permanent storage. For persistent configuration or long-term data, external storage mechanisms should be used.
Expressions are used in If and While conditions. There are two forms:
- 1-operand expression:
<operator> <operand>— operator comes first, followed by a single value or variable. - 2-operand expression:
<operand1> <operator> <operand2>— value or variable on both sides of the operator.
Single-value (no operator) expressions are also accepted: a variable or literal is evaluated as boolean on its own.
Note: Parentheses and logical chaining (e.g.,
and,or) are not supported.
Note: In all commands where an argument is requested, you can use variable substitution with
{{variablename}}. For example,If {{color}} eq black.
Syntax: <operator> <value>
| Operator | Meaning |
|---|---|
| not | Negates the boolean value of <value> |
| isEmpty | True if <value> is empty or whitespace-only |
| isNotEmpty | True if <value> is not empty |
| isDefined | True if the variable named <value> is defined |
| isNotDefined | True if the variable named <value> is not defined |
Samples:
If isEmpty {{myvar}}
PrintGlowdashConsole myvar is empty
EndIf
If isNotEmpty {{myvar}}
PrintGlowdashConsole myvar has a value
EndIf
If isDefined state.myflag
PrintGlowdashConsole state.myflag is defined
EndIf
If isNotDefined myvar
Set myvar defaultvalue
EndIf
If not {{myflag}}
PrintConsole myflag is falsy
EndIf
Syntax: <value1> <operator> <value2>
| Operator | Meaning |
|---|---|
| == | Numerically equal |
| != | Numerically not equal |
| < | Numerically less |
| <= | Numerically less or equal |
| > | Numerically greater |
| >= | Numerically greater or equal |
| eq | Strings are equal |
| neq | Strings are not equal |
| in | String is in a comma-separated list |
| nin | String is not in a comma-separated list |
| booleq | Compare as boolean |
- Syntax:
If <expression> - Parameters:
<expression>: Logical condition. Supports 1-operand (<operator> <value>), 2-operand (<value> <operator> <value>), or single-value boolean forms. Brackets and logical chaining are not allowed.
- Description: Starts a conditional block. If the expression is true, executes the following lines until
ElseorEndIf. - Sample:
If {{count}} == 2
PrintConsole There is two
Else
PrintConsole There is not two
EndIf
If {{color}} eq black
PrintConsole The color is black
EndIf
If isEmpty {{myvar}}
Set myvar default
EndIf
If isDefined state.myflag
PrintConsole flag is set
EndIf
- Syntax:
While <expression> - Parameters:
<expression>: Logical condition. Supports 1-operand (<operator> <value>), 2-operand (<value> <operator> <value>), or single-value boolean forms. Brackets and logical chaining are not allowed.
- Description: Starts a loop. Executes the following lines while the expression is true, until
EndWhile. - Sample:
Set i 0
While {{i}} < 8
PrintConsole In cycle, i is {{i}}
AddTo i 1
EndWhile
- Syntax:
Return [value] - Parameters:
[value](optional): Value to return from the script.
- Description: Exits the script, optionally returning a value.
- Sample:
Return
Return true
Set state 1
Return {{state}}
- Syntax:
PrintConsole <text> - Parameters:
<text>: Text or variable to print.
- Description: Prints text to the console/log. Standard output.
- Sample:
PrintConsole Hello World
PrintConsole Variable name is {{name}}
- Syntax:
PrintGlowdashConsole <text> - Parameters:
<text>: Text or variable to print.
- Description: Prints text to the Glowdash console.
- Sample:
PrintGlowdashConsole Hello World
PrintGlowdashConsole Variable name is {{name}}
- Syntax:
Set <variable> <value> - Parameters:
<variable>: Variable name. Supports{{variablename}}substitution.<value>: Value to assign. Supports{{variablename}}substitution.
- Description: Define and sets a variable to a value. You can set already defined variables too.
- Sample:
Set catname Mirmur
Set catvar {{catname}}
Set catvar 3
- Syntax:
Run <programname> - Parameters:
<programname>: Name of ProgramLibrary element to run.
- Description: Runs a named ProgramLibrary element.
- Sample:
Run helloworld
- Syntax:
RunSet <variable> <programname> - Parameters:
<variable>: Variable to store return value.<programname>: Name of ProgramLibrary element to run.
- Description: Runs a ProgramLibrary element and stores its return value.
- Sample:
RunSet result helloworld
- Syntax:
AddTo <variable> <value> - Parameters:
<variable>: Variable name.<value>: Value to add.
- Description: Adds value to variable (numeric).
- Sample:
Set myvar 2
// myvar is 2
AddTo myvar 5
// myvar is 5
Set increment 3
AddTo myvar {{increment}}
// myvar is 8
PrintConsole Variable myvar is {{myvar}}
- Syntax:
SubFrom <variable> <value> - Parameters:
<variable>: Variable name.<value>: Value to subtract.
- Description: Subtracts value from variable (numeric).
- Sample:
Set myvar 24
SubFrom myvar 2
// myvar is 22
- Syntax:
MulWith <variable> <value> - Parameters:
<variable>: Variable name.<value>: Value to multiply.
- Description: Multiplies variable by value (numeric).
- Sample:
Set myvar 2
MulWith myvar 3
// myvar is 6
- Syntax:
DivWith <variable> <value> - Parameters:
<variable>: Variable name.<value>: Value to divide.
- Description: Divides variable by value (numeric).
- Sample:
Set myvar 22
DivWith myvar 2
// myvar 11
- Syntax:
AddMinutesToTime <variable> <minutes> - Parameters:
<variable>: Variable containing time string (HH:MM).<minutes>: Minutes to add.
- Description: Adds minutes to a time string.
- Sample:
Set time 14:45
AddMinutesToTime time 35
PrintConsole {{time}}
// time is 15:20
- Syntax:
WaitMs <milliseconds> - Parameters:
<milliseconds>: Milliseconds to wait.
- Description: Pauses script for specified time.
- Sample:
WaitMs 1000
Set waitsec 5
MulWith waitsec 1000
WaitMs {{waitsec}}
- Syntax:
CallHttp <url> - Parameters:
<url>: HTTP request URL.
- Description: Calls an HTTP request and ignores the result. After execution, the variable
LastHttpCallSuccessis set totrueif the request succeeded, orfalseif it failed. - Sample:
CallHttp http://example.com/api
Set SwDeviceIp 192.168.1.22
CallHttp http://{{SwDeviceIp}}/rpc/Switch.Set?id=0&on=true
If {{LastHttpCallSuccess}} booleq false
Return error
EndIf
- Syntax:
CallHttpStoreJson <variable> <url> - Parameters:
<variable>: Variable to store JSON result.<url>: HTTP request URL.
- Description: Calls an HTTP request and stores the JSON result in a variable. This variables are different namespaces than other,
variables. They can not used in substitutions. After execution, the variable
LastHttpCallSuccessis set totrueif the request succeeded, orfalseif it failed. - Sample:
CallHttpStoreJson myjson http://example.com/api
Set SwDeviceIp 192.168.1.22
CallHttpStoreJson myjson http://{{Sw.DeviceIp}}/rpc/Switch.GetStatus?id=0
If {{LastHttpCallSuccess}} booleq false
Return error
EndIf
- Syntax:
SetFromJsonReq <variable> <url> <jsonpath> - Parameters:
<variable>: Variable to store extracted value.<url>: HTTP request URL.<jsonpath>: JSON path to extract.
- Description: Calls an HTTP request, extracts the specified element from the JSON response, and stores it in a variable. After execution, the variable
LastHttpCallSuccessis set totrueif the request succeeded, orfalseif it failed. - Sample:
SetFromJsonReq myvar http://example.com/api /element/path
Set SwDeviceIp 192.168.1.22
SetFromJsonReq myvar http://{{Sw.DeviceIp}}/rpc/Switch.GetStatus?id=0 /output
If {{LastHttpCallSuccess}} booleq false
Return error
EndIf
Retrun {{myvar}}
- Syntax:
SetFromStoredJson <variable> <jsonvar> <jsonpath> - Parameters:
<variable>: Variable to store extracted value.<jsonvar>: Variable containing stored JSON. This variables are different namespaces than other, variables. They can not used in substitutions.<jsonpath>: JSON path to extract.
- Description: Extracts element from previously stored JSON.
- Sample:
SetFromStoredJson myvar myjson /element/path
Set SwDeviceIp 192.168.1.22
CallHttpStoreJson myjson http://{{Sw.DeviceIp}}/rpc/Switch.GetStatus?id=0
If {{LastHttpCallSuccess}} booleq false
Return error
EndIf
SetFromStoredJson myvar myjson /output
Retrun {{myvar}}
- Syntax:
RelatedPanel <type> <ip> <deviceid> - Parameters:
<type>: Panel type.<ip>: Device IP address.<deviceid>: Device ID.
- Description: Refreshes related panels after script runs.
- Sample:
RelatedPanel Switch 192.168.1.101 0
- Syntax:
LoadVariablesFromPanelId <panelid> - Parameters:
<panelid>: Panel ID to load variables from.
- Description: Loads exposed variables from the specified panel. For a Switch panel, the following variables may be loaded:
| Variable | Example Value |
|---|---|
| Panel.Id | sw1 |
| Panel.Title | Living Room |
| Panel.DeviceType | Shelly |
| Panel.SubPage | |
| Panel.Index | 1 |
| Panel.PowerInfo | true |
| Panel.DeviceIp | 192.168.1.10 |
| Panel.InDeviceId | 0 |
| Panel.State | 1 |
| Panel.InputState | 1 |
| Panel.Watt | 12.50 |
| Panel.Volt | 230.00 |
| Panel.TextualState | true |
| Panel.TextualOppositeState | false |
- Sample:
LoadVariablesFromPanelId sw1
// After execution, variables like Panel.Id, Panel.Title, Panel.DeviceType, etc. are available.
- Syntax:
LoadVariablesFromPanelIdWithPrefix <prefix> <panelid> - Parameters:
<prefix>: Prefix for loaded variables.<panelid>: Panel ID to load variables from.
- Description: Loads exposed variables from the specified panel, adding the given prefix to each variable name. For a Switch panel with prefix
MySw_, the following variables may be loaded:
| Variable | Example Value |
|---|---|
| MySw_Panel.Id | sw1 |
| MySw_Panel.Title | Living Room |
| MySw_Panel.DeviceType | Shelly |
| MySw_Panel.SubPage | |
| MySw_Panel.Index | 1 |
| MySw_Panel.PowerInfo | true |
| MySw_Panel.DeviceIp | 192.168.1.10 |
| MySw_Panel.InDeviceId | 0 |
| MySw_Panel.State | 1 |
| MySw_Panel.InputState | 1 |
| MySw_Panel.Watt | 12.50 |
| MySw_Panel.Volt | 230.00 |
| MySw_Panel.TextualState | true |
| MySw_Panel.TextualOppositeState | false |
- Sample:
LoadVariablesFromPanelIdWithPrefix MySw_ sw1
// After execution, variables like MySw_Panel.Id, MySw_Panel.Title, etc. are available.
- Syntax:
PrintVariablesConsole - Parameters: None
- Description: Prints all variables to console/log. Standard output.
- Sample:
PrintVariablesConsole
- Syntax:
PrintVariablesGlowdashConsole - Parameters: None
- Description: Prints all variables to GlowDash console.
- Sample:
PrintVariablesGlowdashConsole
- Syntax:
RoundDown <variable> - Parameters:
<variable>: Variable name containing a numeric value.
- Description: Rounds the variable down to the nearest integer.
- Sample:
Set myvar 5.12
RoundDown myvar
// myvar is 5.0
- Syntax:
RoundUp <variable> - Parameters:
<variable>: Variable name containing a numeric value.
- Description: Rounds the variable up to the nearest integer.
- Sample:
Set myvar 5.12
RoundUp myvar
// myvar is 6.0
- Syntax:
RoundMath <variable> - Parameters:
<variable>: Variable name containing a numeric value.
- Description: Rounds the variable to the nearest integer using standard mathematical rounding.
- Sample:
Set myvar 5.12
RoundMath myvar
// myvar is 5.0
Set myvar 3.72
RoundMath myvar
// myvar is 4.0
- Syntax:
AddOneshotSchedule <panelid> <action> <time> - Parameters:
<panelid>: Panel ID to schedule.<action>: Action activated in panel (e.g., 'on', 'off', 'run' in actions).<time>: Time string (HH:MM) for the schedule.
- Description: Adds a one-shot schedule for the specified panel and state at the given time.
- Sample:
AddOneshotSchedule tswid001 off 15:30
Set swofftime {{Time.TimeHM}}
AddMinutesToTime swofftime 30
AddOneshotSchedule tswid001 off {{swofftime}}
AddOneshotSchedule ac004 run 19:15
- Syntax:
ModbusTcp <variable> <host:port> <unitId> <operation> <address> - Parameters:
<variable>: For read operations: variable name to store the result. For write operations: variable or literal value to write.<host:port>: IP address and port of the Modbus TCP device (e.g.,192.168.1.50:502).<unitId>: Modbus unit ID (slave address), typically1.<operation>: One ofreadcoil,readinput,readregister,writecoil,writeregister.<address>: Register or coil address (decimal).
- Description: Communicates with a Modbus TCP device. After execution,
LastModbusTcpCallSuccessis set totrueif the operation succeeded, orfalseif it failed.
| Operation | Description | Result stored in variable |
|---|---|---|
readcoil |
Read a single coil (FC 0x01), result is true/false |
yes |
readinput |
Read a single input register (FC 0x04), result is decimal integer | yes |
writecoil |
Write a single coil (FC 0x05), value from <variable> |
no |
- Sample:
// Read a coil at address 5 from device at 192.168.1.50, unit 1
ModbusTcp coilstate 192.168.1.50:502 1 readcoil 5
If not {{LastModbusTcpCallSuccess}}
PrintGlowdashConsole Modbus read failed
EndIf
PrintGlowdashConsole Coil state: {{coilstate}}
Return {{coilstate}}
// Read input register at address 200
ModbusTcp sensorval 192.168.1.50:502 1 readinput 200
PrintConsole Sensor value: {{sensorval}}
// Write a coil at address 3 with value from variable
Set relaystate true
ModbusTcp {{relaystate}} 192.168.1.50:502 1 writecoil 3
- Syntax:
ShellyRelay <variable> <host[:port]> readrelay <inDeviceId>ShellyRelay <variable> <host[:port]> readcover <inDeviceId>ShellyRelay <value> <host[:port]> setrelay <inDeviceId>ShellyRelay <action> <host[:port]> setcover <inDeviceId>
- Parameters:
<variable>: For read operations, variable name to store result.<value>: Forsetrelay, boolean-like value (true,false,1,0,on,off, etc.).<action>: Forsetcover, command string passed to the Shelly cover action handler.<host[:port]>: Device IP/host, optional port. If port is omitted, default is80.<operation>: One ofreadrelay,setrelay,readcover,setcover.<inDeviceId>: Shelly channel/index (for example0,1, ...).
- Description: Communicates with a Shelly device relay or cover endpoint. After execution,
LastShellyRelayCallSuccessis set totrueif the operation succeeded, orfalseif it failed.
| Operation | Description | Variables set |
|---|---|---|
readrelay |
Reads relay status and input state | <variable> (true/false), <variable>.StateInt (0/1), <variable>.StateBool (true/false), <variable>.InputState (true/false) |
setrelay |
Sets relay on/off from <value> |
no operation-specific output variable |
readcover |
Reads cover position and named state | <variable> (position integer), <variable>.Position, <variable>.NamedState |
setcover |
Sends a cover action command from <action> |
no operation-specific output variable |
- Sample:
// Read relay state from channel 0
ShellyRelay relayState 192.168.1.22 readrelay 0
If not {{LastShellyRelayCallSuccess}}
PrintGlowdashConsole Shelly relay read failed
Return error
EndIf
PrintGlowdashConsole Relay state: {{relayState}} (input={{relayState.InputState}})
// Set relay on
Set desiredState true
ShellyRelay {{desiredState}} 192.168.1.22 setrelay 0
// Read cover status
ShellyRelay coverPos 192.168.1.23 readcover 1
PrintConsole Cover position: {{coverPos}} ({{coverPos.NamedState}})
// Control cover
ShellyRelay open 192.168.1.23 setcover 1
When a script starts, several variables related to the current date and time are automatically set and available for use. These are:
| Variable | Description | Example Value |
|---|---|---|
| Time.Hour | Current hour (00-23) | 14 |
| Time.Minute | Current minute (00-59) | 05 |
| Time.TimeHM | Current time, hour and minute (HH:MM) | 14:05 |
| Time.TimeHMS | Current time, hour, minute, second (HH:MM:SS) | 14:05:23 |
| Time.Second | Current second (00-59) | 23 |
| Time.SecOfDay | Seconds since midnight | 50723 |
| Time.WeekDay | Day of week (0=Sunday, 6=Saturday) | 2 |
| Time.Month | Current month (1-12) | 2 |
| Time.Day | Current day of month (1-31) | 27 |
| Time.Year | Current year | 2026 |
| Time.YearDay | Day of year (1-366) | 58 |
These variables are available in every script and can be used directly in expressions and commands.
See big-sample-config.yml for real-world examples.
RelatedPanel Shading 192.168.1.102 0
CallHttp http://192.168.1.102/rpc/Cover.Open?id=0
SetFromJsonReq cstate http://192.168.1.102/rpc/Cover.GetStatus?id=0 /state
While {{cstate}} nin open,stopped,closed
WaitMs 1000
SetFromJsonReq cstate http://192.168.1.102/rpc/Cover.GetStatus?id=0 /state
EndWhile
RelatedPanel Shading {{Panel.DeviceIp}} {{Panel.InDeviceId}}
Set BackOpenTime 300
Set DeviceIp {{Panel.DeviceIp}}
Set DeviceId {{Panel.InDeviceId}}
Set MinDownPos 70
SetFromJsonReq CoverPos http://{{DeviceIp}}/rpc/Cover.GetStatus?id={{DeviceId}} /current_pos
//PrintConsole CoverPos is {{CoverPos}} % ({{TIME.HOUR}}:{{TIME.MINUTE}})
Set MinDownPosPlus2 {{MinDownPos}}
AddTo MinDownPosPlus2 2
If {{CoverPos}} > {{MinDownPosPlus2}}
//Smaller than min%, down to min%.
CallHttp http://{{DeviceIp}}/rpc/Cover.GoToPosition?id={{DeviceId}}&pos={{MinDownPos}}
Set cstate none
While {{cstate}} nin open,stopped,closed
WaitMs 1000
SetFromJsonReq cstate http://{{DeviceIp}}/rpc/Cover.GetStatus?id={{DeviceId}} /state
EndWhile
Else
CallHttp http://{{DeviceIp}}/rpc/Cover.Close?id={{DeviceId}}
WaitMs 2000
CallHttp http://{{DeviceIp}}/rpc/Cover.Stop?id={{DeviceId}}
EndIf
WaitMs 200
CallHttp http://{{DeviceIp}}/rpc/Cover.Open?id={{DeviceId}}
WaitMs {{BackOpenTime}}
CallHttp http://{{DeviceIp}}/rpc/Cover.Stop?id={{DeviceId}}