Configurable time trigger

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.

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 :wink: )

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

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?

Maybe here are some useful ideas:

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

1 Like

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


Not used by myself, but, may-be the IcalCalendar App for Homey | Homey 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.

1 Like

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”
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
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”
This updates every minute, so it gets updated when the car reports longer or shorter charging times

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

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

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

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

I finetuned it a bit, it works great now.

The flows:

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)

1 Like

I wonder why you mix BetterLogic and native Logic?

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

Thanks, Peter

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

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

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

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

I see, and agree.


@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)

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:


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

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 :hugs:

Got something :wink:

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


  • Script:
// 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');
} 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 } });




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


  • Script:
// 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');
} 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 } });




  • Variables:
    The ones starting with “A.” are the ones to edit or readout
    Screenshot from 2022-06-13 04-06-13
    The ones starting with “AB.” are the other used Vars:
    Screenshot from 2022-06-13 04-06-54


  • Finding a variable ID & its details:
// 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)

1 Like