Configurable time trigger

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