Since I’m just experimenting with it a bit, I thought I’d start a thread about it. There doesn’t seem to be any instructions/help for this (online help in the web frontend would be great). So let’s try to find out what you put where, what you can currently do with it and what you should modify to make better use of it.
Let’s start with the variables:
First you can choose between the variable types. As is usual with programming languages, you have to decide on a format such as Integer (integer values), Float (with decimal places), Boolean (True/False), and so on.
The variable now gets a name and a value (according to the selected format). What I noticed in this regard is that you can no longer change the name once it has been saved. I don’t know whether that’s intentional or whether it makes sense. I would imagine that it makes sense for the name to be fixed when using this variable in LUA scripts, as these no longer work after changing the name. But is this actually the scope of the variable at this point? Presumably the purpose of the variable definition in the web frontend is that you don’t have to write a LUA script yourself. If you write a LUA script yourself, you will probably write the variables directly into the script. However, if you use the variables in MeshBots, the name could be renamed automatically (this also works for device names).
Now the question is, what do I do with these variables?
These variables can be used as triggers, for example as a comparison value:
But why should you use a variable at this point instead of entering the value directly? One of the advantages would be, for example, if this variable was used in several MeshBots. If you now want to change this value, you don’t need to adjust it in all MeshBots, just change the variable.
Unfortunately, it is not yet possible to use variables in actions.
Now let’s move on to the expressions. Here too, a name is defined which cannot then be changed:
In contrast to variables, there is no data format to choose from. The expression is filled with data from the field “Please enter a valid LUA code with return statement”. It is expected that a value will be read out using a LUA code line. Practically, you can directly choose a device with the appropriate capability. Let’s take a thermostat with the current setpoint heating as an example:
After clicking on the Add Reference button, the following code is inserted:
But with this line you get an error message. The term “return” is still missing. Maybe this should also be inserted automatically when you add the device to the script.
With this you now get both the value and the unit in the expression:
In some cases it makes sense to leave out the unit, for example if you want to calculate values with different units. Then add the characters “.value” to the end of the script. And you get an expression without units:
Here you can also easily insert calculations of values.
Average values from multiple devices:
Or increase a value by a fixed value:
You can now use these expressions in the triggers of the MeshBots like you would with the variables:
Unfortunately, also the expressions cannot currently be used in the actions.
Now it would be interesting to know whether and for what you use variables and expressions.
The following examples spontaneously come to mind:
-
Global variables used in many meshbots, all of which should work with the same values. If you make changes, you only have to adjust the value in one place. It would now make sense if these variables could also be filled dynamically using a MeshBot Action.
-
Average room temperature. The room temperature can be calculated using an expression based on several temperature sensors distributed throughout the room
What scenarios could you imagine and what could/should be changed at this point so that the user can handle it with little or no programming knowledge?