Make a query with the temperature and ambient light measurements for two different thermostats and use it the Rule Designer.
Create a new Query
Click on the query tile and select ‘New Query’ on the right.
We are able to add default values, these will be used for all series, unless overridden within the series spec itself.
Now we add series for one thermostat, notice the default already being filled in. We also give the series a human friendly name so that it is easy to read.
After that we add the same metrics for the other thermostat and give them names.
View the data
Now we can view the data, note that the series get the human friendly name.
Save the Query
Before we can use the query within a rule, we first have to save the Query. You are also able to add a description for clarifying what the query is useful for and tags that can be used during search.
Open the Rule Designer
Now click the ‘Open query in Rule Designer’ button in the top right.
This will open a new browser tab in which we see the Rule Designer with one sensor.
When we look at the properties of this sensor we see that the name of our query is already filled in.
And when we click the ‘Test’ button for this sensor we see that data is being gathered according to the query.
Connect the query sensor to a BYOML sensor
In the past you had to use multiple timeseries sensors in combination with a script sensor to create valid input for a BYOML sensor like so:
Now all this can be reduced to a single sensor that gets the same data:
We are also able to do some post processing in the query sensor. We are able to delete timestamps by filling in ‘true’ for the ‘removeTimestamps’ property. If we want the output to be columnwise instead of rowwise, we can fill in ‘true’ for the ‘columnwise’ property. The BYOML algorithm we use expects the input to have no timestamps, so we configure the query sensor like this:
To use the returned data directly in the BYOML sensor we have to only pass the ‘data’ part that gets returned by the query sensor. So we alter the properties of the BYOML sensor like so:
Where ‘queryData’ is the name of the query sensor.