# Configurable time trigger

**URL:** <https://community.homey.app/t/configurable-time-trigger/63532>\
**Category:** Ideas & Suggestions\
**Created:** [May 11, 2022, 7:04pm UTC](https://community.homey.app/t/configurable-time-trigger/63532 "2022-05-11T19:04:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [May 11, 2022, 7:04pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/1 "2022-05-11T19:04:45Z")

</div>

I would like to have an option to set a certain time, f.e. 17:00 and than have Homey count backwards the time needed to charge my car, in order to start charging in time.

However, this is not the problem, I can create flows for that; what I’m looking for is how to have easy access to set a (any) time (17:00 in this example) without having to browse to a flow and edit the flow.

If f.e. it would be possible to create and set a time variable (which is not possible), I could set the variable to the time I need the car to be fully charged.

I’m surely overlooking some easy option, but I don’t see any way to do this.

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [May 11, 2022, 8:01pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/2 "2022-05-11T20:01:44Z")

</div>

If it would charge within 120 minutes I would go for a Alarm (expecting you to use a Homey Pro, na for _Homey (beta)_ )

But I am afraid you need more time and this is a limitation in the Flow Trigger.  
( Or maybe you just need Faster Chargers 😉 )

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

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [May 11, 2022, 8:09pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/3 "2022-05-11T20:09:59Z")

</div>

never used an alarm (always thought; why the hell would I want to set an alarm in Homey with all the alarms on my phone, watch etc)…

Maybe underestimated the functionality, so this might be a use case. I’ll see whats possible with alarms

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [May 12, 2022, 7:01am UTC](https://community.homey.app/t/configurable-time-trigger/63532/4 "2022-05-12T07:01:46Z")

</div>

Alarms are not what I’m looking for.

My usecase:

- set a time to leave (i.e. the time I need to get in my car)
- have Homey calculate back the time to start charging, based on the “chargingtime left” (number of minutes) value that the car reports
- start charging on “time-to-leave” -/- “chargingtime left” = “start charging time”

I don’t see any way to easily set a specifica time (other than the alarms), and I don’t see any way to calculate “time (hh:mm)” minus “x minutes” = “wanted time”

Anyone point me in the right direction?

---

<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:** [May 12, 2022, 3:07pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/5 "2022-05-12T15:07:23Z")

</div>

Maybe here are some useful ideas:

> [@HomeyScript seconden naar uren, minuten en seconden](https://community.homey.app/t/homeyscript-seconden-naar-uren-minuten-en-seconden/47643):
>
> Echt super nuttig is dit niet, maar wel leuk voor de mensen die graag dingen bijhouden. Ik heb dit HomeyScript gemaakt om de uitkomst van een stopwatch leesbaarder te maken. Ik heb deze apps daarvoor in gebruik: Met chronograph kun je een stopwatch starten en stoppen. De tijd daartussen wordt opgeslagen in de tag: looptijd (s) Dit is dan opgeslagen in seconden, bijvoorbeeld 42123 seconden. Maar dan weet je nog niet bijster veel. Dus… als je dan het volgende invult bij Als dan zie je de uitk…

---

<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:** [May 12, 2022, 4:44pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/6 "2022-05-12T16:44:37Z")

</div>

The app which could possibly do this, is  
Flow Utilities, I’ve given the devs your usecase, maybe they’ll know a way…

---

<div class="post-metadata">

**Author:** ![RobbertV](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robbertv/32/37250_2.png) [@RobbertV](https://community.homey.app/u/RobbertV)\
**Post date:** [May 12, 2022, 6:25pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/7 "2022-05-12T18:25:52Z")

</div>

Thanks @Peter_Kawa for letting us know about this case. We are going to investigate how Flow Utilities can help with that.

We will share the results on our topic: [[APP][Pro] Flow Utilities - #110 by Peter\_Kawa](https://community.homey.app/t/app-pro-flow-utilities/53027/110)

---

<div class="post-metadata">

**Author:** ![Cuprum](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/cuprum/32/41409_2.png) [@Cuprum](https://community.homey.app/u/Cuprum)\
**Post date:** [May 13, 2022, 5:08am UTC](https://community.homey.app/t/configurable-time-trigger/63532/8 "2022-05-13T05:08:45Z")

</div>

> [@zakraket](#):
>
> However, this is not the problem, I can create flows for that; what I’m looking for is how to have easy access to set a (any) time (17:00 in this example) without having to browse to a flow and edit the flow.

Not used by myself, but, may-be the [IcalCalendar App for Homey | Homey](https://homey.app/en-ca/app/no.runely.calendar/IcalCalendar/) is a possibility? I think there are also other integrations with (different)calendars/planners. Just set a event “I need a car”, and if this event appears in calendar, then Homey picks it up.

Yeah, another possibility is to do some dashboard with special features… or use some time capable (virtual) device.

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [May 20, 2022, 1:50pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/9 "2022-05-20T13:50:47Z")

</div>

Could it be done with Better Logic, specifically the Mathjs cards?

Say I need to leave at 17:00, and my car needs 3 hours to charge to full (according to the car), I need the car to start charging at 14:00

I don’t really need to work with times; if I use numeric times, 1700 instead of 17:00, I can calculate (( **1700** \*60/100)-( **180** ))/0.6 = **1400**

I only need a flow that, f.e. every 5 minutes, converts current time to a number and if that number \> 1400, start charging.

I found $timenow$ to convert current time to a number, I basically need $timenow$ epoch - current date epoch (today 0:00 epoch) which gives me the numeric time to compare to 1400

Anyone know how?

edit: okay, found a solution using Better logic, need to test but I think this works

Calculate epoch for “today 0:00”  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/4/5484ee0b259570f9b8ea662615e679be573e2098.png)  
Maybe this can be done in the next step but I don’t know the Mathjs to get “today 0:00” epoch

Calculate epoch $timenow$ to current time (HH,MM) in **decimal** format  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/f/fff82fc4871f3492c8b548f827b12033b128c0e5.png)  
small error; /60 needs to be /60/0,6 to get a correct “decimal time”

Calculate startingtime based on current charging time left againts “leave time”  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/4/14350396bc58ab02604f4d60225a459dcc645d29.png)  
This updates every minute, so it gets updated when the car reports longer or shorter charging times

If “now” \> “starting time” then start charging

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/c/5c6367296d75047aa92b23427c4824955acff960.png)  
The **A3 Start Laden** flow checks for charging state, battery level, charging plug etc  
The second logic condition makes it possible to set a time earlier than iNowEpoch which results in “tomorrow”  
I disable flows 3 and 4 (and also some other flows, f.e. to stop charging when solar is low) to prevent things from running while car is forced to charge

If I change the Leavetime to 0 (outside 700-2200), this disables the previous flows or enables them

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

I reset the Leavetime to 0 when the car is fully charged, so when I need to leave, I only need to set the Leavetime to somewhere between 1-2359

---

<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:** [June 2, 2022, 10:26pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/10 "2022-06-02T22:26:16Z")

</div>

Quite impressive, I copied it, but it doesn’t work yet

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [June 3, 2022, 6:32am UTC](https://community.homey.app/t/configurable-time-trigger/63532/11 "2022-06-03T06:32:21Z")

</div>

I finetuned it a bit, it works great now.

The flows:

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

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

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

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

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/f/6fb9c98ed42f3f88722faba11b65403a14779b46.png)

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

I have a few flows that set certain default times on certain days of the week (like when I go work out on wed/sun)

---

<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:** [June 4, 2022, 3:15pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/12 "2022-06-04T15:15:40Z")

</div>

Thanks!  
I wonder why you mix BetterLogic and native Logic?

And, which flow is this? It’s not in your overview.

 ![Screenshot_20220604-171228_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/c/8c7f1e203c409ce687766f8085fa73ebb0e303c5.jpeg)

Thanks, Peter

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [June 5, 2022, 5:52pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/13 "2022-06-05T17:52:16Z")

</div>

It’s the #3 bereken startijd (laadtijd)

Flowname not updated in the caller flow correctly after I changed the name of the flow. I want the StartChargingTime to update when I update my “vertrektijd” but also when the battery updates (f.e. when I set a vertrektijd at 17:00 but need the car before that to do a quick shopping the StartChargingTime needs to be recalculated for the updated battery level.  
So I need to triggers to calculate

I like normal logic better because the values are more easy and quick to read (and set!) then in Better Logic. I only use BetterLogic because it can do the Execute mathjs step.  
I set the times in normal Logic

---

<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:** [June 5, 2022, 8:22pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/14 "2022-06-05T20:22:55Z")

</div>

Thanks for explaining.  
It is working like a charm, if the remaining charge time is (around) 60 minutes or 120 or 180.

 ![Screenshot_20220605-221832_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/d/ddeb0b93279865247a0af5ad5edbeae7a972e147.jpeg)

When it’s 90 minutes, the time is incorrect, it should be 2215:

 ![Screenshot_20220605-224241_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/d/edaccfc3c71003a670bbe9155339a83322448de0.jpeg)

> [@zakraket](#):
>
> It’s the #3 bereken startijd (laadtijd)

Ah, okay. It isn’t needed imho, because that flow is triggered by a changed variable. Just enabling that flow is sufficient.

> [@zakraket](#):
>
> I like normal logic better because the values are more easy and quick to read (and set!) then in Better Logic. I only use BetterLogic because it can do the Execute mathjs step.  
> I set the times in normal Logic

I see, and agree.

~Peter

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [June 6, 2022, 5:54am UTC](https://community.homey.app/t/configurable-time-trigger/63532/15 "2022-06-06T05:54:03Z")

</div>

@Peter_Kawa have not noticed any wrong times so far Did you do something to recalculate the ones to represent normal times?  
My times are always decimal, i.e. 17:15 is 1725, 17:45 is 1775  
In your screenshots it seems like you converted (f.e.) 17:45 → 1775 \> 1745?  
Did not think of this but would make it easier to work with of course

About starting the #3 Flow; the trigger is a variable change, but in this case the variable change (setting a time) triggers enabling the flows. Would the #3 Flow than also trigger? It’s disabled on the moment I set a time  
Could try this

(Could you remove my name pls? Gr Zakraket)

---

<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:** [June 6, 2022, 11:50am UTC](https://community.homey.app/t/configurable-time-trigger/63532/16 "2022-06-06T11:50:40Z")

</div>

> [@zakraket](#):
>
> My times are always decimal, i.e. 17:15 is 1725, 17:45 is 1775

Oh I didn’t get that!  
The times are indeed correct if you look at them as decimal.

1350 = 13.5 = 13:30h and that’s correct:

 ![Screenshot_20220606-134911_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/1/710cb141d6c6d2f59247aeab9bd2d83259a0e5fb.jpeg)

Thanks!

---

<div class="post-metadata">

**Author:** ![zakraket](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/zakraket/32/17470_2.png) [@zakraket](https://community.homey.app/u/zakraket)\
**Post date:** [June 9, 2022, 7:52am UTC](https://community.homey.app/t/configurable-time-trigger/63532/17 "2022-06-09T07:52:12Z")

</div>

It’s probably possible (and not too difficult) to convert them to normal time values (but numeric), so 17:45 \> 1775 \> 1745, but I’m fine with this a.t.m., maybe I’ll think of something

---

<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:** [June 9, 2022, 2:47pm UTC](https://community.homey.app/t/configurable-time-trigger/63532/18 "2022-06-09T14:47:09Z")

</div>

Yea I was thinking of some sort of formula too, but too lazy atm.  
I’ve canged the time outputs to decimals, like 1550 becomes 15.50 .  
Then, _to me_, it’s more clear the time is 15 ½ hrs, and not 15:50hrs 🤗

---

<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:** [June 13, 2022, 12:19am UTC](https://community.homey.app/t/configurable-time-trigger/63532/19 "2022-06-13T00:19:56Z")

</div>

Got something 😉

- Flow 1 - Convert departure time to numeric time  
(To be able to enter the departure time as normal time 00:00 format)

.

- Script:

```auto
// convertTime2NumericTime.js - Convert time to Numeric time (like: 15:30h -> 1550)

let timeIn = args[0]
let timeNumeric = 0;

if (timeIn == '' || timeIn == undefined) {
    console.log ('Missing argument');
    return(false);
} else {
  // If the hour is 1 - 9, add a leading 0 so time is formatted as f.i. 09:30
  var charCount = Array.from(timeIn.toString()).length;
  if (charCount < 5) {
    timeIn = "0" + timeIn;
  }

  // Split the hours and minutes
  hours = timeIn.slice(0,2);
  minutes = timeIn.toString().slice(-2);

  // Converting from minutes to Numeric hours
  hoursNumeric = Math.round(minutes / 0.6 ,0);
    // In case result = 0 -> make sure minutes are displayed as 00
  if (hoursNumeric < "1") {
    hoursNumeric = hoursNumeric + "0";
  }

  timeNumeric = hours + hoursNumeric;
  
  // Update Logics stringVar AB.timeNumeric
 await Homey.logic.updateVariable({id: 'Variable_ID_here', variable: { value: timeNumeric } });

}

return(true);

```

.

- Flow 2 - When numeric time “Start Charging time” changed, convert it to normal time format 00:00

.

- Script:

```auto
// convertNumeric2NormalTime.js - Convert numeric time to normal time (like: '1550' -> 15:30)

let timeNumeric = args[0]

// make sure timeNumeric it has no digits, round to zero digits
timeNumeric = Math.round(timeNumeric ,0)

let timeNormal = 0;

if (timeNumeric == '' || timeNumeric == undefined) {
    console.log ('Missing argument');
    return(false);
} else {
  // If the hour is 1 - 9, add a leading 0
  var charCountHrs = Array.from(timeNumeric.toString()).length;
  if (charCountHrs < 4) {
    timeNumeric = "0" + timeNumeric;
  }
  // Split the hours and numeric hours
  hours = timeNumeric.toString().slice(0,2);
  hoursNumeric = (timeNumeric).toString().slice(-2);
  // change f.i. 25 to 0.25
  hoursNumeric = hoursNumeric / 100;
  // converting from Numeric hours to minutes
  minutes = Math.round(hoursNumeric * 60 ,0);

  // In case result = 1 digit, then make sure minutes are displayed as 0x
  if (minutes < 10) {
    minutes = "0" + minutes;
  }

  timeNormal = hours + ":" + minutes;
 
  // Update Logics stringVar AB.timeNormal
  await Homey.logic.updateVariable({id: 'Variable_ID_here', variable: { value: timeNormal } });

}

return(true);

```

.

- Variables:  
The ones starting with “A.” are the ones to edit or readout  
 ![Screenshot from 2022-06-13 04-06-13](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/2/a27d58b8cc61a2ef364cb1a7e61ccaf6afc51102.png)  
.  
The ones starting with “AB.” are the other used Vars:  
 ![Screenshot from 2022-06-13 04-06-54](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/c/5c73aa5b7f5ba7b6a1ac8f4550f8d8fbcfae6e10.png)

.

- Finding a variable ID & its details:

```auto
// Replace MyVar with your variable name
let varName = "MyVar"

const logicVars = await Homey.logic.getVariables()
for (var iLogicVar in logicVars){
  if (logicVars[iLogicVar].name == varName)
  log("Variable: " + logicVars[iLogicVar].name + "\nType:\t " + logicVars[iLogicVar].type + "\nValue:\t " + logicVars[iLogicVar].value + "\nID:\t " + logicVars[iLogicVar].id)
}

```

---

<div class="post-metadata">

**Author:** ![Patrick\_Van\_Deursen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/patrick_van_deursen/32/56539_2.png) [@Patrick\_Van\_Deursen](https://community.homey.app/u/Patrick_Van_Deursen)\
**Post date:** [October 25, 2024, 6:40am UTC](https://community.homey.app/t/configurable-time-trigger/63532/20 "2024-10-25T06:40:16Z")

</div>

timey is a maybe new possible solution for your initial problem. time can now be set as a variable:

> **[Timey](https://homey.app/nl-nl/app/no.kjeet90.timey/Timey/)**
>
> Make your time flows dynamic with variables

[Next page](https://community.homey.app/t/configurable-time-trigger/63532.md?page=2)
