I have exactly this use case, but instead of triggering a flow on each temparature change, I have created a HomeyScript. This HomeyScript calculates the min and max temperature based on the log from Insights.
My script:
let MinVarName="MinTemp";
let MaxVarName="MaxTemp";
//uri = tuinsensor(Philips Hue)
//id = temperatuur
let entries = await Homey.insights.getLogEntries({uri: "homey:device:3245df43-c818-2289-98c6-ec033472dbf3",
id: "measure_temperature",
resolution: "last24Hours"});
//console.log(entries);
var lowest = Number.POSITIVE_INFINITY;
var highest = Number.NEGATIVE_INFINITY;
var tmp;
for (var i=entries.values.length-1; i>=0; i--) {
tmp = entries.values[i].v;
if (tmp != null && tmp < lowest) {
lowest = tmp;
}
if (tmp != null && tmp > highest){
highest = tmp;
}
}
console.log("Max: " + highest + " Min: " + lowest);
await setTagValue(MinVarName, {type: "number", title: MinVarName}, lowest );
await setTagValue(MaxVarName, {type: "number", title: MaxVarName}, highest );
return true;
Every morning I run this script from a flow and then the flow updates two variables with the min and max temperature.