Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Pump: an interval-cycle schedule on the Switch interface (with #585) #596
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
The tower pump now has its own switch and an interval-cycle schedule beside the grow light. It is shown on the Grow card on /admin and controlled from the terminal, all owner-only, with its settings in `pump.json`.
shipped merged
The tower pump now has its own switch and an interval-cycle schedule beside the grow light. It is shown on the Grow card on /admin and controlled from the terminal, all owner-only, with its settings in pump.json.
This pull is stacked on #588. The light code it builds on (light.ts, light-switch.ts and the owner-only /grow routes) is not on main yet, so this branch starts at #588's head (504b549) and its diff includes #588's commits until that pull is merged. Merge #588 first; the commit to review here is the last one.
What changed
- Schedule: a
Cycleschedule ({onMinutes, offMinutes}, each 1–1440) sits besidePhotoperiodinlight-schedule.ts. It is counted from the Unix epoch, so every clock agrees, and a reboot lands in the same part of the cycle. - Device:
Lighttakes a device name ("light" | "pump"), and the arm server keeps one of each, inlight.jsonandpump.jsonwith their own.log.jsonl. With no switch, the pump says "Pump: not run (no switch set up)". The dark-period caution stays the light's alone. - Routes:
GET /growreturns{light, pump}, and changes go toPOST /grow/lightandPOST /grow/pump. All three are in the relay's owner-only and admin-only sets, so anyone else gets 404. - /admin: the Grow card shows a Pump section under the light, with its own override buttons, a schedule form where you pick daily or cycle, and switch forms. An older Pi that answers only for the light shows "the arm server is older than the pump".
- Terminal:
/growshows both devices, and/grow [light|pump] on|off|clear|schedule …|switch …changes one. A command with no device word is the light's, so/grow onstill works as it did in #588.
Most of this is #588's own first commit (ba57a7e), which had the pump before 12ee14a took it out; I reverted that removal. On top of it, I rewrote the README section, kept /grow on working for the light, and added tests.
Tests: new pump tests in light.test.ts cover the cycle math, reboot catch-up (the Pi sleeps through four changes and boot() sets the state the cycle says now), and an override that ends at the cycle's next change. The endpoint test checks the pump runs apart from the light, and the terminal test checks that a command with no device word goes to the light. No existing test was changed to make it pass. I ran the light, light-endpoint, terminal, admin-relay, readme and server suites (155 pass, 0 fail), and tsc is clean for the files I touched. I did not run the whole suite or design-lint: no file under src/web/ changed.
Not done: there are no cycle presets beyond the 5 on / 25 off default, and no flow sensing. I didn't try it on real hardware.
To try it: on the preview, sign in as the owner and open /admin → Grow. Set a switch on the Pump, then a cycle (for example 5 min on, 25 min off), and it reads "On until hh:mm". In the terminal, /grow pump schedule 5 25 does the same.
🤖 Generated with Claude Code
I merged main into the branch and pushed it as 3579424; it adds the workshop (#592). The light, endpoint, terminal, admin-relay, readme, stations and server tests pass: 166 pass, 0 fail.
Conflicts (I kept both sides in each):
README.md: the "Grow light and pump" section stays, and #592's "The workshop: stations on /" section follows it.terminal.ts:HELPlists both/grow [light|pump …]and/stations [set <json>], andTypedtakes both thegrowandstationscommands.terminal.ts, the terminal's constructor: it takesreadGrow13th andreadStations14th, so it holds both.tty.ts: it importsgrowReaderandstationsReaderand passes both, in that order.
One test changed: stations.test.ts:208 built the terminal with stationsReader as the 13th argument. That slot is now the grow reader, so I added a null before it. Only the argument position was out of date; the test checks the same thing.
tsc is clean for every file I touched. It still reports errors elsewhere, in hops.ts, stations.ts and src/ui/* among others, and the merge did not change any of those files.
This pull is still stacked on #588: merge #588 first.
🤖 Generated with Claude Code
Approved, with two caveats. I read the diff up to where it was cut off (light.test.ts onward), so I did not see the terminal.ts, relay.ts and server.ts changes. I judged those from the tests and the README. I could not check the pump card on the preview: /admin and /grow answer 404 to me, as the owner-only design says. The workshop home on the preview serves normally.
The pump is a second Light device named "pump". It has an interval-cycle schedule counted from the epoch, with its own pump.json and log. The tests cover the cycle math, DST, boot catch-up, the owner-only 404s, the same-origin and moderator checks, and the byte-capped body. The card is plain forms with no script. Each driver sits in a <details>, and inputs and summaries are at least 44px, so it works on a 360px phone with a thumb. Server output is escaped and parsed field by field. The README covers both the page and the terminal.
Next, in order:
- Make the "Set up a switch" link (
#light) show only to someone who can edit. A moderator on /admin sees a link to forms that are not rendered for them. - Merge #588 first and rebase. This pull carries its commits, and the #582 light and pump scope together are larger than the direction's small-pulls rule. Keep the care work (#585) in its own pull.
The tower pump now has its own switch and an interval-cycle schedule beside the grow light. It is shown on the Grow card on /admin and controlled from the terminal, all owner-only, with its settings in
pump.json.This pull is stacked on #588. The light code it builds on (
light.ts,light-switch.tsand the owner-only/growroutes) is not onmainyet, so this branch starts at #588's head (504b549) and its diff includes #588's commits until that pull is merged. Merge #588 first; the commit to review here is the last one.What changed
Cycleschedule ({onMinutes, offMinutes}, each 1–1440) sits besidePhotoperiodinlight-schedule.ts. It is counted from the Unix epoch, so every clock agrees, and a reboot lands in the same part of the cycle.Lighttakes a device name ("light" | "pump"), and the arm server keeps one of each, inlight.jsonandpump.jsonwith their own.log.jsonl. With no switch, the pump says "Pump: not run (no switch set up)". The dark-period caution stays the light's alone.GET /growreturns{light, pump}, and changes go toPOST /grow/lightandPOST /grow/pump. All three are in the relay's owner-only and admin-only sets, so anyone else gets 404./growshows both devices, and/grow [light|pump] on|off|clear|schedule …|switch …changes one. A command with no device word is the light's, so/grow onstill works as it did in #588.Most of this is #588's own first commit (
ba57a7e), which had the pump before12ee14atook it out; I reverted that removal. On top of it, I rewrote the README section, kept/grow onworking for the light, and added tests.Tests: new pump tests in
light.test.tscover the cycle math, reboot catch-up (the Pi sleeps through four changes andboot()sets the state the cycle says now), and an override that ends at the cycle's next change. The endpoint test checks the pump runs apart from the light, and the terminal test checks that a command with no device word goes to the light. No existing test was changed to make it pass. I ran the light, light-endpoint, terminal, admin-relay, readme and server suites (155 pass, 0 fail), andtscis clean for the files I touched. I did not run the whole suite ordesign-lint: no file undersrc/web/changed.Not done: there are no cycle presets beyond the 5 on / 25 off default, and no flow sensing. I didn't try it on real hardware.
To try it: on the preview, sign in as the owner and open /admin → Grow. Set a switch on the Pump, then a cycle (for example 5 min on, 25 min off), and it reads "On until hh:mm". In the terminal,
/grow pump schedule 5 25does the same.🤖 Generated with Claude Code
Closes #595