DiscoveryVIP · Hands-On AI
PROJECT 28

Household Maintenance Planner

Recurring home maintenance is easy to forget.

Try interactive applicationDownload complete source

What this teaches

Calculate next due date and status as of 2026-11-25. Air filters, inspections and seasonal chores.

Start without an account in the local application. Read/edit the input, predict a result, run the current source and verify output. A local document preview is not a real Google Doc; a fixture is not a live model response.

Input and expected result

Input tab: Maintenance. Entry function: planMaintenance().

TaskLast doneInterval days
Filter2026-10-0130
Smoke alarm test2026-11-2030

Expected baseline: Filter overdue; smoke alarm test upcoming

Exact Workspace setup

  1. Download and unzip this project. Use one separate bound script per lesson.
  2. Create a dedicated Drive folder. Create a native Google Sheet inside it, and import starter.csv into a tab named Maintenance. Check the exact headers above.
  3. Open the Sheet → Extensions → Apps Script. Paste finished Code.gs into the script editor. Save.
  4. Choose planMaintenance in the function selector → Run. Review actual requested permissions. Reload the Sheet for the Workshop menu.
  5. Compare output with the baseline above. Check generated documents/drafts manually. No email should be sent.
  6. Perform the original challenge, investigate a failure and test duplicate/partial runs before scheduling. Do not install a trigger just because one manual run succeeded.

Understand the implementation

UTC date addition avoids daylight-saving shifts; compare ISO dates.

Key operations: getValues(); JavaScript transformations; setValues(); validation and calculations

Focused source spotlight

This is an excerpt, not a standalone script. The complete implementation follows.

function planMaintenance(){
// Add interval days in UTC to avoid daylight-saving date shifts.
output('Schedule',['Task','Next due','Status'],input('Maintenance').map(([task,last,interval])=>{const d=new Date(day(last)+'T00:00:00Z');d.setUTCDate(d.getUTCDate()+num(interval));const due=d.toISOString().slice(0,10);return [task,due,due<'2026-11-25'?'Overdue':'Upcoming'];}));
}

Complete Code.gs

// Household Maintenance Planner
// Entry point: planMaintenance; source data stays intact unless explicitly noted.
function onOpen(){SpreadsheetApp.getUi().createMenu("Workshop").addItem("Run application","planMaintenance").addToUi();}
function planMaintenance(){
// Add interval days in UTC to avoid daylight-saving date shifts.
output('Schedule',['Task','Next due','Status'],input('Maintenance').map(([task,last,interval])=>{const d=new Date(day(last)+'T00:00:00Z');d.setUTCDate(d.getUTCDate()+num(interval));const due=d.toISOString().slice(0,10);return [task,due,due<'2026-11-25'?'Overdue':'Upcoming'];}));
}
function input(name) { const s=SpreadsheetApp.getActive().getSheetByName(name); if(!s) throw Error('Missing tab: '+name); return s.getDataRange().getValues().slice(1).filter(r=>r.some(v=>v!=='')); }
function output(name,headers,rows) { const ss=SpreadsheetApp.getActive(); const s=ss.getSheetByName(name)||ss.insertSheet(name); s.clearContents(); s.getRange(1,1,1,headers.length).setValues([headers]).setFontWeight('bold'); if(rows.length) s.getRange(2,1,rows.length,headers.length).setValues(rows.map(r=>r.map(v=>typeof v==='string' && /^[=+@-]/.test(v)?"'"+v:v))); s.setFrozenRows(1); return s; }
function num(v){if(v===''||!Number.isFinite(Number(v))) throw Error('Invalid number: '+v); return Number(v);}
function day(v){return v instanceof Date?Utilities.formatDate(v,SpreadsheetApp.getActive().getSpreadsheetTimeZone(),'yyyy-MM-dd'):String(v).slice(0,10);}

Four guided activities

Discover and run

Recurring home maintenance is easy to forget.

  1. Inspect the editable Maintenance table. The starter has 2 records.
  2. Write your predicted result in Prediction. Click Run application.
  3. Compare Output with: Filter overdue; smoke alarm test upcoming
  4. Click Verify baseline; explain one result in Notes.

Expected: Filter overdue; smoke alarm test upcoming

Understand and modify

Set Filter last done to 2026-11-20; expect Upcoming.

  1. Open Source and read planMaintenance. Select the entry function in the walkthrough.
  2. Return to Application. Click Prepare original challenge to create a separate challenge starting state.
  3. For AI projects inspect the revised recorded fixture: this is supplied response data, not newly generated AI.
  4. Run application and use Verify challenge; approval/sidebar projects show extra required steps.

Expected: Set Filter last done to 2026-11-20; expect Upcoming.

Investigate and repair

Bad maintenance date

  1. Save a snapshot if you want to keep your experiment.
  2. Click Inject investigation. Set Filter Last done to not-a-date.
  3. Run application and inspect Output and Execution trace. Some investigations produce wrong/stale content rather than exceptions.
  4. Repair it: Use 2026-10-01. Invalid dates fail during toISOString. Run again and explain the root cause.

Expected: The baseline date helper is permissive; strict calendar validation is a useful extension.

Extend and automate

Add completion history and reminders

  1. Open Prompts. Select Extend and adapt the requirement to your goal.
  2. Build the feature in Source or export the complete project to Apps Script.
  3. Retest baseline and original challenge before considering scheduling.
  4. Use Resources → Automation readiness. Use a rolling current date and daily schedule; add completion history.

Expected: The baseline still works; independent extension checks are designed and reviewed by you.

Original exercise

Set Filter last done to 2026-11-20; expect Upcoming.

Debugging and troubleshooting

Bad maintenance date

Set Filter Last done to not-a-date.

Hint 1

Check the exact input/response contract and identify the affected field.

Hint 2

UTC date addition avoids daylight-saving shifts; compare ISO dates.

Hint 3 and repair

Use 2026-10-01. Invalid dates fail during toISOString.

The baseline date helper is permissive; strict calendar validation is a useful extension.

Missing tab: check its exact name. Missing document: ensure unique native companion Docs share the Sheet’s dedicated folder. Authorization failure: review source and contact your administrator. Recorded response exhausted: add a new explicit fixture; no live AI is running. Invalid JSON: repair syntax before validating schema. Valid but unsupported content: compare each claim with source records.

Build prompt

Build a complete container-bound Apps Script app named Household Maintenance Planner. Input tab Maintenance, headers Task|Last done|Interval days. Implement planMaintenance() to calculate next due date and status as of 2026-11-25. Add a menu, preserve inputs, validate data, explain code and test against: Filter overdue; smoke alarm test upcoming. For AI use callGemini and treat input as data; never send email.
Match the reference entry point planMaintenance and its output behavior. Reference: https://github.com/lsvekis/Google-Apps-Script-Workshop/tree/main/28-household-maintenance-planner. Base version limitations: Fixed demonstration date; no reminder action.

Extension prompt

Improve the existing application: Add completion history and reminders. Preserve working features and provide complete code and regression tests.
Automation option: Use a rolling current date and daily schedule; add completion history. Keep this separate from the baseline exercise.

Knowledge check and answer key

  1. Which input tab does planMaintenance read?
    Answer

    Maintenance

  2. Which function starts the original application?
    Answer

    planMaintenance

  3. What is the baseline output you must verify?
    Answer

    Filter overdue; smoke alarm test upcoming

  4. Does this project need runtime Gemini in the real Workspace baseline?
    Answer

    No; Gemini can help during development only.

  5. What limitation matters before scheduling?
    Answer

    Fixed demonstration date; no reminder action.

Safe automation

Use a rolling current date and daily schedule; add completion history.

Known limitation

Fixed demonstration date; no reminder action.

Reflect and extend

Explain the transformation using one actual input row. Which incorrect value could still pass structural validation? What happens if the function runs twice or fails after creating one output? Write your explanation before building this extension: Add completion history and reminders

Source alignment

Physical slide 56; printed sequence 43 of 48. Reference source SHA-256 b2ac87b9caae350bfa3835d6a252b5f942a558af32b98bff854c98816ffd03b0.

Pinned repository reference · Full source manifest

Five-minute presenter demonstration

0:00–0:45

Action: Open Input. Read Maintenance headers and first row.

Recurring home maintenance is easy to forget. This application is useful for Air filters, inspections and seasonal chores. We will run the verified reference code against fictional data.

0:45–1:30

Action: Ask for predictions. Click Run application, then Verify baseline.

Our baseline is Filter overdue; smoke alarm test upcoming The browser displays local results. It has not connected to Google or a model.

1:30–3:00

Action: Open Source. Select planMaintenance in the code walkthrough.

UTC date addition avoids daylight-saving shifts; compare ISO dates. The complete code is available to edit and download. The excerpt is not a standalone script.

3:00–4:15

Action: Click Prepare original challenge, inspect the changed inputs, and Run application. Complete extra review/sidebar steps if listed.

Set Filter last done to 2026-11-20; expect Upcoming. For AI lessons we edit a recorded response as well as source data. That response must be checked, not trusted.

4:15–5:00

Action: Click Verify challenge. Open Guide and read Automation considerations.

The important limitation is: Fixed demonstration date; no reminder action. Before scheduling: Use a rolling current date and daily schedule; add completion history. Explain the result yourself before moving on.

Launch temporary demo