@pierre-gilles, is this mockup already functional?
(Public access) Mockup: Retrieve a state over time.
Functional Specification
- « Retrieve the last state » becomes « Retrieve a state »
- The state of a device can be retrieved in several ways:
- Last value
- Relative time (X minutes ago)
- By date
- Over a period
Details of the mentioned possibilities
1. Last value
This is exactly what is currently done, and quite clear 
2. Relative time
Here the idea is to be able to say: I want to compare the value from 10 minutes ago (based on the scene execution time).
We will be able to compare two values 10 minutes apart, without having to wait!
If the scene runs at 12:00 and the user has chosen « 10 minutes ago, » the value will be compared to that of 11:50:00 (±30s to find a value). If no value is found between 11:49:30 and 11:50:30, the test fails.
3. By date
This is a bit similar to relative time, but you can specify a very precise date without any particular limit. We will therefore be able to compare values several days or even months apart.
Here, you can imagine comparing a value to a « reference value » on a specific date.
Note here: the user must be alerted if they choose a date for which there is no value.
4. Over a period
This is the most interesting in my opinion: the user will be able to compare a value with all those retrieved over a certain period of time.
Examples:
- You can check if a motion sensor detected movement in the last 10 minutes (based on the scene execution time).
- You can check if a plug has consumed a certain level of instantaneous power in the last 30 minutes
- etc…
In the case of a sensor (or actuator) whose values can change very regularly and are not necessarily binary (temperature, power consumption in watts, brightness in lux, etc.), the « reference » value used in the scene for the test will be compared to all those recorded.
If I want to check that my plug has consumed less than 15W in the last 30 minutes, the test will be written as: « My plug » < « 15W » in the « last 30 minutes ». Gladys will then check in the database if all the values retrieved in the last 30 minutes do not exceed 15W.
Retrieval of test values
As with the « retrieve the last value » block, the value used during tests should be automatically retrieved (value recording time + value).
Example:
- I perform a test on the device « my-sensor » to check if there has been movement in the last 10 minutes, i.e. between 11:50 and 12:00 (scene execution time).
- If movement was recorded at 11:56, two variables are created in the scene: « my-sensor-test-1-value » and « my-sensor-test-1-time ».
- I am able to send a message with these two variables to alert me « motion detected (value = 1) at 11:56. »