# Use CPU load percentage in LOGIC

**URL:** <https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104>\
**Category:** Ideas & Suggestions\
**Created:** [February 28, 2024, 10:15am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104 "2024-02-28T10:15:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 28, 2024, 10:15am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/1 "2024-02-28T10:15:41Z")

</div>

I would like to be able to use the CPU load percentage as a value in Homey’s logic.

The data is available in Insights, and at times, the load peaks. Flows that run every x seconds/minutes that aren’t related to immediate tasks like lighting, could be skipped when the system load is too high.

It seems small, but would help me a lot.

 ![Scherm­afbeelding 2024-02-28 om 11.13.39](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/5/4564ff2beaec94567686de8d149c2f5943000ee6.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 28, 2024, 10:36am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/2 "2024-02-28T10:36:20Z")

</div>

Or try to find out what’s causing the peaks…

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [February 28, 2024, 11:17am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/3 "2024-02-28T11:17:34Z")

</div>

have you tried the sysInternals app?

> **[sysInternals](https://homey.app/en-gb/app/com.sysInternals/sysInternals/)**
>
> Shows Homey’s System Internals

---

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 28, 2024, 1:00pm UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/4 "2024-02-28T13:00:09Z")

</div>

If I knew, I would’ve reduced the load of course. I have a ton of very complex flows, with lots of calculations running frequently (not every 10 seconds, but still quite often).

I cannot trace back those peaks. But if I can skip some calculations at high CPU load, that could be a solution as well.

---

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 28, 2024, 1:00pm UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/5 "2024-02-28T13:00:29Z")

</div>

Thank you Adrian, I didn’t know there was an app for that. Will try it!

---

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 28, 2024, 1:24pm UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/6 "2024-02-28T13:24:50Z")

</div>

Thank you so much, this is exactly what I’m looking for! I will integrate it in my flows, and hopefully the peak CPU loads will no longer interfere with delayed switching of my lighting.

---

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 29, 2024, 7:29am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/7 "2024-02-29T07:29:32Z")

</div>

@robertklep @Adrian_Rockall

I created a variable when CPU load (1min) exceeds 39%, then 90% of my periodically started flows won’t start until the next time, and when the CPU load is below 30% again. This was implemented yesterday around 16:00.

I was quite hopeful this would help. But sadly, this hasn’t changed anything. I checked the CPU usage of all my apps, and there is no single app that could be responsible for peak CPU loads.

 ![Scherm­afbeelding 2024-02-29 om 08.24.18](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/7/27edbf78254d5e3148cde9fb0781b203007b6661.png)

Is there anything else I could check? My RAM usage is around 75-80%, but rarely exceeds 80%.

Thank you for thinking with me.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 29, 2024, 7:34am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/8 "2024-02-29T07:34:27Z")

</div>

Do you actually disable those periodic flows, or did you add a guard to then (“AND cpu load \< 30”)? Because with a guard your flows are still started, they just don’t continue. It might be worthwhile to see what happens if you actually disable those flows so they don’t get started at all.

Other than that, there are a few apps that can provide flow logging, which might be useful to see if there are specific flows running at the same time the peaks occur.

---

<div class="post-metadata">

**Author:** ![TKroon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tkroon/32/9504_2.png) [@TKroon](https://community.homey.app/u/TKroon)\
**Post date:** [February 29, 2024, 7:52am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/9 "2024-02-29T07:52:04Z")

</div>

I start flows, but the first card is the check of the CPU load. Do you still think it will make a difference whether I disable the entire flow? There are more flow sections in each advanced flow, so in that case I could split them up, and disable only the periodically started sections.

Do you have suggestions of those flow logging apps?

 ![Scherm­afbeelding 2024-02-29 om 08.49.50](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/d/4d5564f137dc9e0aabc8b7652be802efeabf3221.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 29, 2024, 8:34am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/10 "2024-02-29T08:34:25Z")

</div>

I don’t know if it’ll make a difference, but it’s something to check. I can’t recommend any logging apps since I don’t use them myself.

---

<div class="post-metadata">

**Author:** ![Eko\_taas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eko_taas/32/74256_2.png) [@Eko\_taas](https://community.homey.app/u/Eko_taas)\
**Post date:** [September 16, 2024, 11:03am UTC](https://community.homey.app/t/use-cpu-load-percentage-in-logic/105104/11 "2024-09-16T11:03:00Z")

</div>

Came across this topic when looking for something else…

Tried to use sysinternals originally, but wanted to have troubled App-CPUvalue instead (I have rather heavy HomeyScrip every 15min).

so created this (propably ugly but working code):

> // Fetch current CPU load of App  
> const targetApp = args[0]; // Get the target app from the arguments
> 
> > const appsInfo = await Homey.apps.getApps();  
> > for (let entry of Object.values(appsInfo)) {  
> > let appName = entry.name;  
> > if (appName !== targetApp) {  
> > continue; // Skip this iteration if the app name doesn’t match  
> > }  
> > // If the app name matches, get CPU and memory usage  
> > let cpuLoad = entry.usage.cpu; // Access the CPU usage  
> > let memUsage = entry.usage.mem; // Access the memory usage  
> > console.log(`App: ${appName}, CPU Load: ${cpuLoad}, Memory Usage: ${memUsage}`);  
> > return cpuLoad; // Return the CPU load if found  
> > }  
> > // If no app matches the target app, return -1 to indicate no match  
> > return -1;

Then flows like this:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/7/5714515397e6ce398df8bf8cd2d6ad206a9e7d94.png)

And

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/a/2a65840ee4a1b285e3d4d26783bdc73c47ff5780.png)

---- update —

Improved upper part of flow when tuned some low-prio flows to run even faster (now also 5sec  
(+ 3sec delay) level wo issue) as blocking to be too slow to stop…

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/0/104d2b42cdb8cc83318283ef6e9438a6a1d57d00.png)

Small explanation:

- HomeyScript as before
- “10.10…” is flow where (all of my) lodash functions are introduced like in example  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/3/333b1e2ee2246b14bef9cf948a39895c9700c949.png)
- “testing only…” card is testing just one of them to verify if passes (as if HomeyScript taken down they are gone as well)
- Any Low-prio flow can be (safely) started with e.g. (running check just to double sure if wished):  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/9/e9c80774cc15be42d76dc6ac328b337ea30c0c7a.png)

And updated insights for the same - blocking shorter than before but yet more effective:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/d/1d5c4777fbdb53bf77eb5968e983646ce504f0d9.png)
