What is an event-driven system and how does it work ?
This means that Iotmanager responds to events. This is sometimes difficult for beginners to understand, so we'll try to tell you more about it.
Actions in Iotmanager they are divided into two types: those that create events and those that don't.
For example we created a temperature sensor dallas1, any change in the values of this sensor is an event and a string in the script: if dallas1 then {rele1 = 1; var1 = dallas1/5} It will work.
For another example, you created the variable var1 and assigned it a value in the configurator, let's say 5.
You want to assign a value to another variable based on this variable:
if var1 > 4 then var2 = var1*10;
If you put this line in the script and turn on your device, the assignment will not work for you. Because there was no event, the mere presence of a variable value is not an event.
Our script is not a file that is regularly executed. It works like this: an event occurs that causes the script to check for any matches to this event and
if any, run this line.
In order for the above line to be executed, something must happen. For example, you changed the var1 variable from the web or application. This event and the string will be executed.
If you really need to execute this line at some point, then you need to generate an auxiliary event (timer triggering, cron, time arrival) and bind your string to this event in the condition.
For example:
if cron1 & var1 > 4 then var2 = var1*10;
Or
if timer1 == 0 & var1 > 4 then var2 = var1*10;
Events can also be generated by the system itself:
onStart — event created at startup after performing all system preparatory operations (WiFi, MQTT, etc.);
onInit — an event created at startup, before working with the network, but after the basic loading of the element configuration.
You can set conditions for such events in scripts as usual, creating the effect of setting the controller's values first before it starts working in the main scenario.
In the end, I would also like to say that it is possible to perform a so-called silent event, this is when an event, for example, a temperature change occurred and was even displayed on the web screen in the application,
however, it did not affect the scenario. You should describe this yourself, if the corresponding module allows it in the element parameters, and use the: =operator in the script.