Essential knowledge for configuring scripts

When making scripts, time [t] is a very important aspect. The following points should be taken into consideration:

  • When referencing back to previous values (e.g. IN[t-1] for sensor IN), the script gets these values from a sensor’s timestore. This timestore does not necessarily contain all the sensor’s past values. When referencing physical and virtual sensors, with a sensor frequency of 1 per second to 1 per minute, the timestore covers the last 65 mins. If the physical or virtual sensor has a different frequency the timestore holds previous sensor values for 65 x the sensor frequency. So, for example, a sensor with a frequency of 1 per hour, would have a timestore of 65 hours.
  • When referencing manual and time-based sensors the timestore is always 65 seconds.
  • If the script references data values before those values have been generated, then the script will simply stop and produce no data. This applies not only when referencing sensors but also to values generated within the same script. When referencing a sensor at a point in time where the sensor had not yet produced any data, there are two options:
  1. The sensor in question first generates data for the required duration.
  2. The sensor in question is configured with a missing value setting of ‘Use 0 as value’. We recommend changing this back to ‘Use last value received’ as soon as the sensor has been able to produce data for the required duration.

Example 1: Script A refers to the data value produced by Sensor X, 30 mins ago. Thus, Sensor X needs to produce data for at least 30 mins before Script A is activated.

Example 2: Script B refers to the data value produced by the script at an earlier point. This means that a script output sensor is also used as an input sensor. Either a second script should be configured that provides the sensor in question with values for the required duration or the missing value strategy could be changed temporarily.

 

 

Have more questions? Submit a request

Comments