# Highest and lowest outdoors temperature during day

**URL:** <https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027>\
**Category:** Flows\
**Created:** [October 31, 2019, 8:34pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027 "2019-10-31T20:34:07Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Tycho](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tycho/32/16864_2.png) [@Tycho](https://community.homey.app/u/Tycho)\
**Post date:** [May 23, 2020, 6:46pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/7 "2020-05-23T18:46:10Z")

</div>

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:

```auto
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.

---

_[View the full topic](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027)._
