Skip to content
← Public packages

@kentcdodds/hydrawise

Server-side Hunter Hydrawise controller and zone helpers backed by the hydrawiseApiKey secret.

AGENTS.md

112 lines · 3.4 KB · Markdown

@kentcdodds/hydrawise — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke / dryRun execute snippets, and edge cases. Secrets by name only — never paste key values. Do not disable live webhooks or jobs (including the enabled weekday-status cron).

Secrets

NameScopeNotes
hydrawiseApiKeyuserQuery param api_key on api.hydrawise.com

Host: api.hydrawise.com. Placeholder shape: {{secret:hydrawiseApiKey}} (resolved by Kody's fetch gateway).

Depends on @kentcdodds/discord for weekday-status Discord posts.

Import paths

ExportImport
root (dispatch + named helpers + request)kody:@kentcdodds/hydrawise
weekday-statuskody:@kentcdodds/hydrawise/weekday-status

Prefer static kody:@kentcdodds/hydrawise / .../weekday-status imports from execute. Do not lead with packages.invoke.

Named helpers also available from the root module: getControllers, getStatus, listZones, runZone, runAllZones, stopZone, stopAllZones, suspendZone, suspendAllZones, resumeZoneSchedule, resumeAllZoneSchedules, request, isSoftSkipError.

Smoke test (read-only)

List zones (no irrigation side effects):

import hydrawise from 'kody:@kentcdodds/hydrawise'

export default async function main() {
	return await hydrawise({ action: 'list-zones' })
	// => { zones, nextPollSeconds, ... }
}

Or named helper:

import { listZones, getControllers } from 'kody:@kentcdodds/hydrawise'

export default async function main() {
	const controllers = await getControllers()
	const zones = await listZones()
	return { controllers, zones }
}

Weekday status without posting Discord:

import weekdayStatus from 'kody:@kentcdodds/hydrawise/weekday-status'

export default async function main() {
	return await weekdayStatus({ dryRun: true })
	// => { ok: true, dryRun: true, content, posted: false, ... }
}

Raw REST escape hatch:

import { request } from 'kody:@kentcdodds/hydrawise'

export default async function main() {
	return await request('customerdetails.php')
}

Mutations (explicit only)

Mutating actions hit setzone.php. Use only when the user explicitly requests irrigation changes:

  • run-zone / run-all-zones (needs seconds)
  • stop-zone / stop-all-zones
  • suspend-zone / suspend-all-zones (needs untilEpochSeconds)
  • resume-zone-schedule / resume-all-zone-schedules
import { runZone } from 'kody:@kentcdodds/hydrawise'

export default async function main() {
	// Only when the user explicitly asked to run a zone
	return await runZone({ relayId: 1, seconds: 60 })
}

Edge cases

  • Endpoints: customerdetails.php, statusschedule.php, setzone.php on https://api.hydrawise.com/api/v1/.
  • Morning briefing contract: { action: 'list-zones' } → { zones, nextPollSeconds } with zone fields number, nextRunInSeconds, nextRunTimeLabel, runDurationSeconds.
  • weekday-status is read-only against Hydrawise; it never runs or suspends zones. Soft-skips outages and HTTP 429 (isSoftSkipError) instead of error-spamming Discord.
  • Job weekday-status is cron 0 8 * * 1-5 America/Denver and enabled — do not turn it off as part of docs or smoke work.
  • Cross-package: if another package imports this one, hydrawiseApiKey must also be approved for the calling package.