A task holds the whole night, not one end of it
One command per task was the wrong unit. A charging window is two commands and reads as one intention, so it was two rows that had to be named twice, switched off twice, and kept in step by hand — and there was nowhere to put the third thing, the ease down to 10 A once the house is asleep. So a task holds a flow. Steps are rows in the editor: an action, a time, and the ceiling under the one action that takes one. The chargers and the days belong to the task, because they are the same for every step of a night, and the switch governs all of it. The steps keep the order they were written rather than being sorted by the clock. A night crosses midnight, and clock order files "start at 23:00" last, behind the stop that closes it — which is not the flow anybody described. Nothing about firing depends on the order: every step is timed on its own, and the sweep asks each one whether its minute has come. Run now moved onto the step. A flow is not a thing that can happen at once — firing a start and the stop that closes it back to back would leave the charger where it began and prove nothing — so the button fires the one line it sits on, and the outcome names the step by its time. The stored shape changes with it: action/amps/time give way to a steps list. The collection was a day old and empty, so this replaces them outright rather than carrying a compatibility path for a schema nothing has run on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0f48093d1a
commit
2b4f4f034d
@@ -152,14 +152,26 @@ type HomeCharger struct {
|
||||
Created string `json:"created,omitempty"`
|
||||
}
|
||||
|
||||
// ChargingTask is one line of the home-charger scheduler: an action, a time of
|
||||
// day, the days it repeats on, and the chargers it acts on. It belongs to the
|
||||
// person, like the chargers themselves — one list covering every charger they
|
||||
// own, rather than a separate schedule inside each one.
|
||||
// ChargingStep is one command in a task's flow: what to do, and at what time
|
||||
// of day. A step is the smallest thing the scheduler sends.
|
||||
type ChargingStep struct {
|
||||
// start, stop, limit (to Amps) or boost.
|
||||
Action string `json:"action"`
|
||||
Amps float64 `json:"amps,omitempty"`
|
||||
|
||||
// A 24-hour "HH:MM", read in the task's zone.
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
// ChargingTask is one entry in the home-charger scheduler: a flow of steps, the
|
||||
// days it repeats on, and the chargers it acts on. It belongs to the person,
|
||||
// like the chargers themselves — one list covering every charger they own,
|
||||
// rather than a separate schedule inside each one.
|
||||
//
|
||||
// The charger's own cloud schedule can only say "charge between these hours,
|
||||
// every day, on this one box". This says "at 23:00 on weeknights, cap these two
|
||||
// chargers at 10 A" — several tasks, each naming its own chargers.
|
||||
// every day, on this one box". This says "start at 23:00, cap to 10 A at 01:00,
|
||||
// stop at 06:30 — on weeknights, on these two chargers", as one named thing that
|
||||
// is switched on and off as one.
|
||||
type ChargingTask struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -169,16 +181,14 @@ type ChargingTask struct {
|
||||
// them" is a standing wish, not the list that happened to exist that day.
|
||||
Chargers []string `json:"chargers"`
|
||||
|
||||
// What to do: start, stop, limit (to Amps) or boost. One action per task; a
|
||||
// charging window is the two tasks that open and close it, which is also how
|
||||
// it is edited and how it is switched off.
|
||||
Action string `json:"action"`
|
||||
Amps float64 `json:"amps,omitempty"`
|
||||
// The flow, in the order it runs. A whole charging window lives in one task
|
||||
// rather than in the two that used to open and close it: it is named once,
|
||||
// switched off once, and reads as the one intention it is.
|
||||
Steps []ChargingStep `json:"steps"`
|
||||
|
||||
// When, as a 24-hour "HH:MM" read in Zone — the IANA zone the browser was in
|
||||
// The IANA zone the steps' times are read in — the one the browser was in
|
||||
// when the task was written. The server's own clock is not the one the user
|
||||
// set the time by, and a laptop that travels must not move the schedule.
|
||||
Time string `json:"time"`
|
||||
// set 23:00 by, and a laptop that travels must not move the schedule.
|
||||
Zone string `json:"zone,omitempty"`
|
||||
|
||||
// The weekdays it repeats on, 0=Sunday … 6=Saturday. Empty means every day.
|
||||
@@ -186,8 +196,9 @@ type ChargingTask struct {
|
||||
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// What happened the last time it fired, so a task that has been failing
|
||||
// quietly for a week says so in the list rather than in a log nobody reads.
|
||||
// What happened the last time a step of it fired, so a task that has been
|
||||
// failing quietly for a week says so in the list rather than in a log nobody
|
||||
// reads.
|
||||
LastRun string `json:"lastRun,omitempty"` // RFC3339, UTC
|
||||
LastResult string `json:"lastResult,omitempty"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user