# How to simulate "for each" loop without explicitly placing each entity?

**URL:** <https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241>\
**Category:** Flows\
**Tags:** flow\
**Created:** [January 29, 2025, 4:59pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241 "2025-01-29T16:59:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![semolex](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/semolex/32/124504_2.png) [@semolex](https://community.homey.app/u/semolex)\
**Post date:** [January 29, 2025, 4:59pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/1 "2025-01-29T16:59:51Z")

</div>

Hello there  
I have more like a “UI de-cluttering” question rather than complain.  
I am trying to achieve following result:

1. I have 10 thermostats for underfloor water heating and a boiler
2. I want to check if ALL thermostats are reached target temperature or current temperature \> target
3. if ALL true → Heating Off else On  
Since I have 10 thermostats flow becomes actually very long both horizontally and vertically and “connectors” are dangling all around.  
Is there is anything that can represent a Boolean group?  
I tried app but it only has a _When_ card and unfortunately I found no way to configure a Boolean output for ALL entities.  
Technically speaking I would like to have something like a virtual device etc. that will output

```auto
for thermostat in thermostats_group:
      if thermostat.target_temperature > thermostat.current_temperature:
          return False
      return True

```

So I can use this inverse logic device to check if any thermostat is in the heating mode and act accordingly.  
My current approaches:

 ![Screenshot 2025-01-29 at 18.46.50](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/c/ccaa8e9035cefa0d67933b14e0d998c52a7d7b1b.png)  
 ![Screenshot 2025-01-29 at 18.46.58](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/c/cc92f9f7e6a2e92a0536ed919767b79250c5515c.png)

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![ArnarS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arnars/32/33981_2.png) [@ArnarS](https://community.homey.app/u/ArnarS)\
**Post date:** [January 29, 2025, 5:44pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/2 "2025-01-29T17:44:35Z")

</div>

One way to ‘de-clutter’ this would be to use homeyscript to loop through each thermostat and which could return a true/false to use in the flow

---

<div class="post-metadata">

**Author:** ![semolex](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/semolex/32/124504_2.png) [@semolex](https://community.homey.app/u/semolex)\
**Post date:** [January 29, 2025, 8:23pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/3 "2025-01-29T20:23:41Z")

</div>

Yeah, probably most optimal solution  
I tried to avoid using script since I have HA for that 🙂  
Would be great to have additional features someday in the future

Thanks

---

<div class="post-metadata">

**Author:** ![Anders\_Gregow](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/anders_gregow/32/61721_2.png) [@Anders\_Gregow](https://community.homey.app/u/Anders_Gregow)\
**Post date:** [January 29, 2025, 9:10pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/4 "2025-01-29T21:10:36Z")

</div>

Have you testet the app `<group>`?

Or create a JSON with the values using JSON handler app. It then has a card to loop through all values.

---

<div class="post-metadata">

**Author:** ![semolex](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/semolex/32/124504_2.png) [@semolex](https://community.homey.app/u/semolex)\
**Post date:** [January 29, 2025, 9:28pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/5 "2025-01-29T21:28:10Z")

</div>

Yes, group device provided only When card  
And capabilities are either ‘mean, average’ etc  
Found no way to create something like template sensor in HA

---

<div class="post-metadata">

**Author:** ![semolex](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/semolex/32/124504_2.png) [@semolex](https://community.homey.app/u/semolex)\
**Post date:** [January 29, 2025, 9:29pm UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/6 "2025-01-29T21:29:56Z")

</div>

JSON app seems reasonable as well, thanks

---

<div class="post-metadata">

**Author:** ![Anders\_Gregow](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/anders_gregow/32/61721_2.png) [@Anders\_Gregow](https://community.homey.app/u/Anders_Gregow)\
**Post date:** [January 30, 2025, 6:28am UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/7 "2025-01-30T06:28:27Z")

</div>

Maybe also check Device capabilities app. It is very customable.

---

<div class="post-metadata">

**Author:** ![dsdevries](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dsdevries/32/80220_2.png) [@dsdevries](https://community.homey.app/u/dsdevries)\
**Post date:** [February 3, 2025, 10:43am UTC](https://community.homey.app/t/how-to-simulate-for-each-loop-without-explicitly-placing-each-entity/129241/8 "2025-02-03T10:43:42Z")

</div>

You could also check out the VThermo app. I use it to create virtual thermostats. When you create a virtual thermostat, it has a lot of options to control its state based on other thermostats or thermometers. You can set its temperature to be an average, a minimum or a maximum of its child thermometers or other thermostats. This allows you to even make complex combinations.
