ngardiner / TWCManager

Control power delivered by a Tesla Wall Charger using two wires screwed into its RS-485 terminals.
The Unlicense
131 stars 55 forks source link

One-time scheduled charging #240

Open MikeBishop opened 3 years ago

MikeBishop commented 3 years ago

This might be something to construct outside of TWCManager using the APIs, but @dschuesae's work made me wonder whether it would be possible to send a command that says "Have the car charged to X limit by Y time." Effectively a Charge Now (in that it's a one-off and overrides other policies), but something that doesn't take effect immediately.

I'd think we could generalize the logic from scheduled completion and enable a "Charge Now" that starts sometime in the future.

ngardiner commented 3 years ago

Totally agree, With the scheduled charging refactoring I think it would be quite straightforward to add a list of one-off schedules that take effect at a given date/time and give those precedence. In addition, having an API call providing that function might be very useful for automation - ie if we see a weather condition coming up, queue up a once-off full charge for the day before.

MikeBishop commented 3 years ago

Well, that particular use-case I let Tesla do for me by having a policy that triggers on Storm Watch. 😁 But for those using other EMSes, yes, that's a good scenario.

I have an automation that I can trigger any time the day before a trip; it waits until 5 AM and sends a Charge Now command. But what I actually want is the car to reach 100% around 8:30 when I'm about to leave; if the car is already at 90%, it doesn't need to start that early.

Currently, if I see the charge level is already high from solar, I just don't set that; I wait until I'm up in the morning to do the Charge Now command. But I'd like to just say we're going on a trip, then let it decide when to start in the morning.

MikeBishop commented 3 years ago

Some thoughts on this last night. Here's a rough design of how we could approach this:

If we're up for such a big change, I would suggest we not begin (or at least, don't merge any of it) until after we've cut a final v1.2.1; this will probably be disruptive in the short term. If we're not up for such a big change, I totally understand.

MikeBishop commented 3 years ago

I was starting to write such a recurrence object as an exercise, when I discovered dateutil already has a recurrence rule class (rrule) that seems like it would cover what we need for that. The format for entering rules isn't terribly friendly, but we might be able to translate something easily enough or just include some good examples.