# Running action every X hours

**URL:** <https://community.homey.app/t/running-action-every-x-hours/58282>\
**Category:** Questions & Help\
**Created:** [January 12, 2022, 9:46am UTC](https://community.homey.app/t/running-action-every-x-hours/58282 "2022-01-12T09:46:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaderag](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vaderag/32/150_2.png) [@vaderag](https://community.homey.app/u/vaderag)\
**Post date:** [January 12, 2022, 9:46am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/1 "2022-01-12T09:46:00Z")

</div>

Can someone help me out here - I feel there is an easy way to do this but I can’t see it

I want a flow which turns on a device (my underfloor heating) for 1 hours, then off for 2 hours - I’ve worked out that this is the most energy efficient way to power it by using insights

But, I can’t see an easy way to do this in a flow - I tried the below, but you can only have 3 OR statements  
There doesnt seem to be a logic tag associated with time, so I can’t do a calculation against it, (and there doesnt even seem to be a time is exactly x for that matter either)

Am I missing something obvious?

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

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [January 12, 2022, 10:09am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/2 "2022-01-12T10:09:04Z")

</div>

This flow will definitely not work, as it cannot be simultaneously between 23:55 - 00:05, 02:55 - 03:05 and so on. Maybe you just want to show what times you need with this flow, I don’t know.

Why are there so many users who always want to realize everything in just one flow? Why don’t create multiple flows?  
For example, for my “You have mail” automation, I created 15 flows. This is not a problem for Homey.  
And if the flows are well structured and named, then it’s also no problem for the user to keep track of them.

For your use case you need 3 flows to turn on the heater, and 3 flows to turn off the heater. So that’s not many flows.  
I am not familiar with Homey Script, but it should be possible to realize it with one flow, maximum 2 flows.

---

<div class="post-metadata">

**Author:** ![vaderag](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vaderag/32/150_2.png) [@vaderag](https://community.homey.app/u/vaderag)\
**Post date:** [January 12, 2022, 10:13am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/3 "2022-01-12T10:13:10Z")

</div>

Yeah I know it won’t work. I wanted each of those in OR (as stated), but it maxes out at 3 OR

It should be very simple to do in one flow - the three OR is arbitrary restriction

There is no way to do it with three flows without some shared logic unless I’m mistaken… And as stated, there appears to be no way to get logic from the time variable

I could do every 3 hours, but then how does the off flow know that it’s not one of the on times?

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [January 12, 2022, 10:33am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/4 "2022-01-12T10:33:46Z")

</div>

> [@vaderag](#):
>
> It should be very simple to do in one flow - the three OR is arbitrary restriction

This is something you have to discuss with Athom.

**Turning underfloor heating on**

_ **Flow 1 of 3** _  
If…  
– Every hour  
And…  
– The time is 00:00  
Or  
– The time is 03:00  
Or  
– The time is 06:00  
Then…  
– Turn on

_ **Flow 2 of 3** _  
If…  
– Every hour  
And…  
– The time is 09:00  
Or  
– The time is 12:00  
Or  
– The time is 15:00  
Then…  
– Turn on

_ **Flow 3 of 3** _  
If…  
– Every hour  
And…  
– The time is 18:00  
Or  
– The time is 21:00  
Then…  
– Turn on

**Turning underfloor heating off**

_ **Flow 1 of 3** _  
If…  
– Every hour  
And…  
– The time is 01:00  
Or  
– The time is 04:00  
Or  
– The time is 07:00  
Then…  
– Turn off

_ **Flow 2 of 3** _  
If…  
– Every hour  
And…  
– The time is 10:00  
Or  
– The time is 13:00  
Or  
– The time is 16:00  
Then…  
– Turn off

_ **Flow 3 of 3** _  
If…  
– Every hour  
And…  
– The time is 19:00  
Or  
– The time is 22:00  
Then…  
– Turn off

---

<div class="post-metadata">

**Author:** ![vaderag](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vaderag/32/150_2.png) [@vaderag](https://community.homey.app/u/vaderag)\
**Post date:** [January 12, 2022, 10:36am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/5 "2022-01-12T10:36:08Z")

</div>

If I’d written code like that in university I’d have failed  
But yeah, it’ll do the job I guess…

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [January 12, 2022, 10:40am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/6 "2022-01-12T10:40:41Z")

</div>

Why not:  
Every 3 hours  
Switch ON  
Switch OFF with a delay of 1 hour

---

<div class="post-metadata">

**Author:** ![vaderag](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vaderag/32/150_2.png) [@vaderag](https://community.homey.app/u/vaderag)\
**Post date:** [January 12, 2022, 10:50am UTC](https://community.homey.app/t/running-action-every-x-hours/58282/7 "2022-01-12T10:50:51Z")

</div>

Legend. That’s a great idea!

---

<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:** [January 12, 2022, 12:01pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/8 "2022-01-12T12:01:52Z")

</div>

That’s what I thought too (although there might be an issue with an OFF not being executed if Homey reboots between the start of the flow and the end of the delay).

---

<div class="post-metadata">

**Author:** ![vaderag](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/vaderag/32/150_2.png) [@vaderag](https://community.homey.app/u/vaderag)\
**Post date:** [January 12, 2022, 12:02pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/9 "2022-01-12T12:02:48Z")

</div>

Turns out if you run the flow manually at any point it messes things up

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [January 12, 2022, 12:54pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/10 "2022-01-12T12:54:10Z")

</div>

These are very unclear information!

Change the flow to “Every 3 **minutes** ” and a delay of 1 **minute** and use a lamp to switch on and off (instead of the underfloor heating). Then you can check relatively quickly whether the flow works or not.

---

<div class="post-metadata">

**Author:** ![Sebas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sebas/32/33892_2.png) [@Sebas](https://community.homey.app/u/Sebas)\
**Post date:** [January 12, 2022, 2:10pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/11 "2022-01-12T14:10:19Z")

</div>

I would do I like this using the “Countdown app”

First make a numeric variable “Underfloor\_Steps”  
Second make a timer using the countdown app “Underfloor Heating”

THEN  
Copy these 2 flows and start it using the test flow function

---

<div class="post-metadata">

**Author:** ![Henrik\_Johnsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/henrik_johnsson/32/13707_2.png) [@Henrik\_Johnsson](https://community.homey.app/u/Henrik_Johnsson)\
**Post date:** [January 12, 2022, 4:08pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/12 "2022-01-12T16:08:04Z")

</div>

That could also be boiled down to a single flow I think by adding an else clause. And to shrink it further, maybe skip the variable and use the state of the pump in the “And…” statement.

---

<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:** [January 12, 2022, 7:06pm UTC](https://community.homey.app/t/running-action-every-x-hours/58282/13 "2022-01-12T19:06:55Z")

</div>

> [@DirkG](#):
>
> > [@vaderag](#):
> >
> > - the three OR is arbitrary restriction
> 
> This is something you have to discuss with Athom.

There is a way however.

- Invert the condition cards
- Use ‘And’ instead of ‘Or’
- The desired action cards should be placed at “THEN ELSE”
- At the “THEN” section, a dummy card has to be inserted, like FlowComments / Timeline / Toggle an unused Bool variable etc.
