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://global.discourse-cdn.com/business4/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://global.discourse-cdn.com/business4/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://global.discourse-cdn.com/business4/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
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