Frequently asked questions
How to perform C-Bus Automation Controller LUA Script logging
FAQ000268381
23 October 2024
C-Bus LUA Script log function is usual to help determine what values various LUS Script functions including C-Bus functions including Measurement Application and User Parameter functions etc. The use of the show Logs(1) to display Current logs window and selecting Show logs for only current script(2) and Clear and running script containing log functions will display any log string messages and parameters (variables).Default Log Helper Function
The LUA Script Editor contains Helpers - under the Alerts and Logs - contains a log variables function helper which when left clicked enters an example containing some different parameters to log. The results shown in the Current logs window of running a script containing the default log helper is as follows
Logging Descriptive String and Value
Using log function can be prefixed with a string as well as the parameter(variable) to provide understanding of what it being logged. All arguments are logged to the Current logs window in example below we see argument 1 being the description and argument 2 being the variables(parameter) value.
Logging Multiple Parameters or Concatenated Strings
Using log functions containing multiple strings and/or parameters eg log('string', parameter, parameter, parameters, ....) to see descriptions and multiple variables at the specified execution point in the LUA script. Knowing what various C-Bus groups, C-Bus levels, measurement values, user defined setpoints are at a specific point in the LUA script can help determine why a block of LUA script code is or isn't being executed.
Additionally using "tostring(variable)" to convert boolean, integer, floating value's into strings and " .. " to concatenate strings allows you to condense log messages into a single line. This allows complex logic with multiple conditional statements to be checked for expected and actual execution whilst troubleshooting LUA scripting.
SwValues = 'Reed Switch: ' .. tostring(SwReed) .. ', Switch Loops: ' .. tostring(SwLoops) .. ', Switch Value: ' .. tostring(SwValue)
log('Switch Values', SwReed, SwLoops, SwValue)
returns
* string: Reed Switch: true, Switch Loops: 5, Switch Value: 83.35