# 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:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xander\_van\_Os](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/xander_van_os/32/4252_2.png) [@Xander\_van\_Os](https://community.homey.app/u/Xander_van_Os)\
**Post date:** [October 31, 2019, 8:34pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/1 "2019-10-31T20:34:07Z")

</div>

I want to receive a push message with the maximum and minimum temperature during the last day. This temp sensor is outdoors. I don’t get it done. I receive same temp for both max and minimum temp. So i think when the temp becomes higher this will set max temp. when temp becomes lower, this will set minimum temp. Can anyone show me with example flow what to do.? Using logica(type) etc. Thanks

---

<div class="post-metadata">

**Author:** ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)\
**Post date:** [October 31, 2019, 8:37pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/2 "2019-10-31T20:37:38Z")

</div>

> [@Xander\_van\_Os](#):
>
> during the last day.

What is during the last day?

And what did u try? Can u show us some screenies of the flows u tried and not working?

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [October 31, 2019, 9:03pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/3 "2019-10-31T21:03:50Z")

</div>

This is the way I do it. Every night I reset these values with a flow.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/f/afda42bae943eea2be32af57b2eca1b8339d9d34.jpeg) ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/c/5c3cab9756ff748c7d9fd0fbf0bd61e05f822126.jpeg)

---

<div class="post-metadata">

**Author:** ![Bosund](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bosund/32/9132_2.png) [@Bosund](https://community.homey.app/u/Bosund)\
**Post date:** [October 31, 2019, 9:05pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/4 "2019-10-31T21:05:41Z")

</div>

This does it for me.  
This flow sets the minimum temperature of the day  
[https://homey.app/f/h5uEzU](https://homey.app/f/h5uEzU)

This sets the max temperature of the day  
[https://homey.app/f/NCiEzU](https://homey.app/f/NCiEzU)

This sends a message to a user and resets the variables.  
[https://homey.app/f/5ZoEzU](https://homey.app/f/5ZoEzU)

I use it to tell the time and temperature of max and min temp in our greenhouse.

Kind regards.

Bo

---

<div class="post-metadata">

**Author:** ![Xander\_van\_Os](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/xander_van_os/32/4252_2.png) [@Xander\_van\_Os](https://community.homey.app/u/Xander_van_Os)\
**Post date:** [November 1, 2019, 7:17pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/5 "2019-11-01T19:17:57Z")

</div>

Thanks gonna give it a try

---

<div class="post-metadata">

**Author:** ![Dqsp](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dqsp/32/13266_2.png) [@Dqsp](https://community.homey.app/u/Dqsp)\
**Post date:** [May 22, 2020, 10:35am UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/6 "2020-05-22T10:35:30Z")

</div>

Thanks for this! Works like a charm!

For the ones not so familiar with logic: add the Drivhus:mintemp (or greenhouse:mintemp or kas:mintemp) as a text/string variable (or with the app Better Logic). Once you have added the string it can be used as a tag in a flow.

---

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

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 27, 2023, 9:16am UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/8 "2023-09-27T09:16:15Z")

</div>

Hi. This is almost what I want. Pasted the code in a new script and run it and it fails on line #1 for

“let MinVarName=“MinTemp”;”

> SyntaxError: Invalid or unexpected token

I’m not smart enough to spot the errors, but just smart enough to foresee that I might need a different ID for my device providing the temperatuers (Telldus Weather Station)?

Is that correct? How do I find the ID to use? Is it a given that I find the temperatures in the same attibute (entries.values[i].v)?

Thanks.

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [September 27, 2023, 12:28pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/9 "2023-09-27T12:28:30Z")

</div>

Try it again now that I changed the post, as the post converted all double quotes to so called “smart quotes” which are an invalid character.

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 27, 2023, 7:38pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/10 "2023-09-27T19:38:38Z")

</div>

Super, now it works passed line 2 :-), but now it fails on the ID I think.  
Here’s the error.

```auto
❌ Script Error
⚠️ Not Found: Log with ID measure_temperature: Not Found: Log with ID measure_temperature
    at /app/node_modules/athom-api/dist/index.js:1:1247257
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 28, 2023, 1:00am UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/11 "2023-09-28T01:00:28Z")

</div>

Hi,  
You cannot use the device ID from an other users’ script, you have to look up the ID for _your_ variable to make it work 😉  
~~This works for me:~~  
!! Forget the code below, it’s for Logics variables, not for devices 🫢

```auto
// Retrieve a Variable ID
//
// Replace varName with your var name
let varName = "my_temperature_variable"
// end of user input
const logicVars = await Homey.logic.getVariables()
for (var iLogicVar in logicVars){
  if (logicVars[iLogicVar].name == varName)
  log("Variable: " + logicVars[iLogicVar].name + "\nValue: " + logicVars[iLogicVar].value + "\nID: " + logicVars[iLogicVar].id)
}

```

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 28, 2023, 8:07am UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/12 "2023-09-28T08:07:08Z")

</div>

Yepp, I guessed that all along Peter\_Kawa. I’m just a little at loss on how to find the ID. Any suggestions? 🙂

From my first post:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/4/84a7de0e2799df0156bb38b3dca0da06c8ad166f.png)

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 28, 2023, 9:11am UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/13 "2023-09-28T09:11:14Z")

</div>

In my quest to get this script working, I’ve drafted this piece of code (part of a bigger loop on devices):

```auto
   if (device.name=="Utetemp") {
     log(`\n${device.class}:\t${device.name}\nID:\t${device.id}\nDriver:\t${device.driverId}`);
     for (const capability of Object.values(device.capabilitiesObj)) {
       log(`${capability.title}:\t${capability.value}\t${capability.id}`);
     }
   }

```

Which outputs:

```auto
 sensor: Utetemp
 ID: 0a81e149-e8ff-4452-b6ba-c73537a9f52a
 Driver: homey:app:com.weather-sensors:temphum
 Battery alarm: false alarm_battery
 Humidity: 82 measure_humidity
 Temperature: 16.5 measure_temperature

```

Which reveals the ID and verifies the property. I’ve inserted the ID, but still the code fails with this message:

```auto
 ❌ Script Error
 ⚠️ Not Found: Log with ID measure_temperature: Not Found: Log with ID measure_temperature

```

If I just read this, it’s like there’s no entries with temperatures from that device in Insights. But I can indeed view the history values there:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/8/8812d7a00185f1a3a8e04ee99ed1ad6d452e3eee.png)

What’s the next thing I should investigate?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 28, 2023, 4:28pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/14 "2023-09-28T16:28:26Z")

</div>

Oh wait, my bad, I was **out of coffee** appearantly 🫣  
Logics variables are not the same as device tags like measure\_temperature so forget my post pls.

Found the culprit:  
The `let entries = ` line should be one long line. The script of Tycho had new line and tabs in it somehow:

 ![Screenshot_13](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/c/9c03918f76d284a42fc08de6a28471d3d5f7f3ee.png)

This code works with the right device ID:

```auto
// retreive_insights_value.js

let MinVarName="MinTemp"; 
let MaxVarName="MaxTemp";

//uri = Temp Koelkast (Aqara weather sensor)
//id = temperatuur
let entries = await Homey.insights.getLogEntries({uri: "homey:device:715639e1-817b-4af1-97ac-955733a02569", id: "measure_temperature", resolution: "last24Hours"});

// To check
//console.log("All insights values of last 24h", 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;
    }
}

await tag(MinVarName, lowest); 
await tag(MaxVarName, highest); 

console.log("Temp Koelkast: \nMax: " + highest + "°C\nMin: " + lowest + "°C");
return true;

```

Note the creating/updating of HS tags (`await tag(name, var)` is different (“simplyfied”) nowadays!

Script output:

> ![Screenshot_14](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/4/9424fac1905bc15b9f3a89c432fdfe2e9f19d85b.png)

And the HS tags are available, see [MaxTemp] and [MinTemp] :  
 ![Screenshot_15](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/f/3f5bf8ab26172c1ec7eaf44409c36fd178955aa4.png)

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 28, 2023, 5:45pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/15 "2023-09-28T17:45:20Z")

</div>

Am not sure what’s not working at my end, but the output’s the same. Paste your script, subst the ID and run. It fails on the let entries = … call ang gives the same message as earlier:

❌ Script Error  
⚠ Not Found: Log with ID measure\_temperature: Not Found: Log with ID measure\_temperature  
at /app/node\_modules/athom-api/dist/index.js:1:1247257  
at process.processTicksAndRejections (node:internal/process/task\_queues:95:5)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 28, 2023, 6:24pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/16 "2023-09-28T18:24:06Z")

</div>

Did you try with an other sensor or capability? I can’t reproduce your exact error by crippling the ID or the capability. In those cases it’s:

```auto

———————————————————
❌ Script Error

⚠️ log_not_found: Could not find that Log
    at /node_modules/athom-api/dist/index.js:1:1247257
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

```

(note my error lacks `/app` in front of `/node_modules/ath......`)

**Wait, are you using a Pro 2023?**  
Change the resolution to `yesterday` and test the script pls?

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 28, 2023, 8:47pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/17 "2023-09-28T20:47:48Z")

</div>

Yes, this runs on a Homey Pro 2023. Tried with `yesterday`:  
let entries = await Homey.insights.getLogEntries({uri: “homey:device:0a81e149-e8ff-4452-b6ba-c73537a9f52a”, id: “measure\_temperature”, resolution: “yesterday”});

…but it yielded the same results:

❌ Script Error  
⚠ Not Found: Log with ID measure\_temperature: Not Found: Log with ID measure\_temperature  
at /app/node\_modules/athom-api/dist/index.js:1:1247257  
at process.processTicksAndRejections (node:internal/process/task\_queues:95:5)

---

<div class="post-metadata">

**Author:** ![mrPilloft](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mrpilloft/32/87781_2.png) [@mrPilloft](https://community.homey.app/u/mrPilloft)\
**Post date:** [September 28, 2023, 9:14pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/18 "2023-09-28T21:14:58Z")

</div>

Just tried with another device, a SONOS speaker.

```auto
//uri = SONOS Living Room, 5de31c51-771b-46e7-9ed1-5699e9ab8ed9 (homey:app:com.sonos:cloud)
//id = speaker_duration
let entries = await Homey.insights.getLogEntries({uri: "homey:device:5de31c51-771b-46e7-9ed1-5699e9ab8ed9", id: "speaker_duration", resolution: "yesterday"}); //last24Hours

```

Was it a success? Not so much 🙂

```auto
❌ Script Error
⚠️ Not Found: Log with ID speaker_duration: Not Found: Log with ID speaker_duration
    at /app/node_modules/athom-api/dist/index.js:1:1247257
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

```

Is it likely that my method of discovering IDs and capabilities is WAAAAAAY off? This is how I do it (for each device):

```auto
    log(`\n${device.class}:\t${device.name}\nID:\t${device.id}\nDriver\t${device.driverId}`);
    for (const capability of Object.values(device.capabilitiesObj)) {
      log(`${capability.title}:\t${capability.value}\t${capability.id}`);
    }

```

This outputs among a lots of stuff this:

```auto
speaker: Living Room
ID: 5de31c51-771b-46e7-9ed1-5699e9ab8ed9
Driver: homey:app:com.sonos:cloud
Duration: 449 speaker_duration

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 28, 2023, 11:10pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/19 "2023-09-28T23:10:50Z")

</div>

Hmmmm I’m starting to think things work slightly different on the 2023 model…

Yes you can check @ [https://tools.developer.homey.app/tools/devices](https://tools.developer.homey.app/tools/devices) and search for your device to doublecheck the ID and capabilities  
Your script and result looks good to me.

Feel free to try this script, but I doubt the results will differ

```auto
// Enter the deviceName
let deviceName = "Temp Koelkast"
//
const myDevices = await Homey.devices.getDevices();
for (var iMyDevice in myDevices){
  if (myDevices[iMyDevice].name == deviceName) {
  log(`Device:\t ${myDevices[iMyDevice].name} \nZone:\t ${myDevices[iMyDevice].zoneName}\nID:\t ${myDevices[iMyDevice].id} \nCapabilities: ${myDevices[iMyDevice].capabilities}`)
  }
};
if (deviceName == "") {
  return false
} else {
  return true;
}

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 28, 2023, 11:17pm UTC](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027/20 "2023-09-28T23:17:58Z")

</div>

Jeroen, @Jero

Sorry to bother you, but you might have a clue why this code errors on a Pro 2023 and runs fine on a Pro 2019?

```auto
let entries = await Homey.insights.getLogEntries({uri: "homey:device:715639e1-817b-4af1-97ac-955733a02569", id: "measure_temperature", resolution: "last24Hours"});

```

Error:

> [@mrPilloft](#):
>
> ❌ Script Error  
> ⚠ Not Found: Log with ID measure\_temperature: Not Found: Log with ID measure\_temperature  
> at /app/node\_modules/athom-api/dist/index.js:1:1247257  
> at process.processTicksAndRejections (node:internal/process/task\_queues:95:5)

[Next page](https://community.homey.app/t/highest-and-lowest-outdoors-temperature-during-day/20027.md?page=2)
