Technical: Services Legacy - ad-ha/kidschores-ha GitHub Wiki
Version: v0.5.0b3
Scope: Service Definitions, Logic, and Edge Cases
Files: services.py, services.yaml
These services drive the primary "Claim -> Approve" loop. They mirror the UI buttons but expose additional parameters for automation.
Description: Approves a chore, awards points, and advances the schedule. Permission: Parent/Admin only.
-
Key Inputs:
kid_name,chore_name. -
💡 Feature: Points Override (
points_awarded)- You can optionally pass a float value to
points_awarded. - Use Case: Award partial points for a "good enough" job, or double points for speed. Overrides the chore's default configuration for this specific instance.
- You can optionally pass a float value to
-
⚠️ Trap: This service triggers the "One-Click" logic. If the chore ispending(not claimed), it will Claim AND Approve it instantly. Be careful with automations triggering this accidentally.
Description: Marks a chore as 'Claimed'. Permission: Kid/Admin.
-
⚠️ Trap: This service enforces User ID Authorization. If triggered via an automation context that isn't linked to the specific Kid profile (or an Admin), it will fail withnot_authorized_action.
Description: Rejects a claim or completion. Permission: Parent/Admin.
-
Logic: Reverts state to
pending. -
💡 Feature: Shared First Reset: If used on a "Shared First" chore (where one kid won and others were locked out), this resets ALL assigned kids to
pending. This re-opens the race for everyone, not just the kid being disapproved.
Direct manipulation of the point economy.
Description: Standard lifecycle for item redemption. Permission: Redeem (Kid/Admin), Approve/Disapprove (Parent/Admin).
-
⚠️ Trap:redeem_rewardperforms a balance check (kid_points >= cost). If the kid is short on points, the service call raises an error and stops execution. Handle this in automations/scripts. -
Logic: Points are only deducted on
approve_reward.
Description: Ad-hoc point modification.
-
Logic:
-
apply_penalty: Deducts points (converts positive input to negative internally). -
apply_bonus: Adds points.
-
-
Metadata: These actions log to the
penalty_appliesandbonus_appliescounters, which are visible in dashboard helpers and sensors.
These services manipulate the Due Dates and Recurrence logic directly.
Description: Sets a hard deadline (ISO Timestamp).
-
Inputs:
chore_name,due_date(Optional),kid_name(Optional). -
💡 Feature: Independent Targeting:
- If the chore is Independent, providing
kid_nameupdates ONLY that kid's due date. Other kids stay on their own schedule.
- If the chore is Independent, providing
-
⚠️ Trap: Shared Chore Targeting:- If the chore is Shared, you CANNOT provide
kid_name. The service will fail. Shared chores must have a global due date.
- If the chore is Shared, you CANNOT provide
-
⚠️ Trap: Past Dates: The service validator (voluptuous) allows datetime strings, but the Coordinator logic throws an error if the date is in the past. -
Clear Date: Sending an empty
due_dateclears the deadline.
Description: Advances a recurring chore to its next logical slot without awarding points.
-
Inputs:
chore_name,kid_name(Optional). -
Logic:
- Calculates
next_duebased on Frequency + Applicable Days. - Updates the due date.
-
Resets State: Forces state to
pending.
- Calculates
- Use Case: "Skip today" buttons on dashboards for sick days or holidays.
Used for bulk operations or fixing data states.
Description: Forces overdue items back to pending and reschedules them to their next occurrence based on recurrence pattern.
-
Granularity: Highly flexible targeting.
-
chore_nameonly: Resets that chore for everyone. -
kid_nameonly: Resets ALL overdue chores for that kid. - Both: Resets specific chore for specific kid.
- Neither: Global reset of all overdue items.
-
-
⚠️ Trap: Recurring Chores Only- This service ONLY works on chores with a recurrence pattern (daily, weekly, etc.).
- One-time or manual chores (no recurrence configured) cannot be reset using this service.
- The service relies on recurrence logic to calculate the "next occurrence" for rescheduling.
-
💡 Completion Criteria Interaction:
INDEPENDENT Chores:
- Each kid maintains their own schedule and state.
- Resetting one kid's overdue chore does NOT affect other kids' instances.
- Example: Sarah's "Make Bed" is overdue → reset → only Sarah's instance goes to
pending. Alex's "Make Bed" remains untouched.
SHARED Chores:
- Single chore instance with global due date shared by all assigned kids.
- Resetting affects ALL assigned kids simultaneously (all return to
pending). - Example: "Take Out Trash" shared by Sarah and Alex → reset → both kids return to
pendingstate. - Use Case: Chore was completed by one kid but went overdue before parent approval.
SHARED FIRST Chores:
- Winner's completion locks out other kids until next cycle.
- If winner's chore is overdue and reset, all kids become eligible again (race reopens).
- Example: Alex won "First to Feed Dog" but went overdue → reset → Sarah and Alex both eligible to claim again.
- Technical Detail: Reset clears the "winner lock" state, returning chore to competitive mode.
MULTI-APPROVAL Chores:
- Each kid must complete independently, but all completions required for chore to cycle.
- Resetting one kid's overdue completion does NOT affect other kids' completions.
- Example: "Walk Dog Together" requires 2 approvals → Sarah completed, Alex overdue → reset Alex → Sarah's completion remains intact, Alex returns to
pending. - Technical Detail: Each kid's state tracked separately; reset only modifies specified kid's state.
-
Rescheduling Logic:
- Calculates
next_duebased on chore's Frequency setting (daily, weekly, monthly, custom). - Respects Applicable Days configuration (e.g., weekdays only, specific days).
- Sets chore state to
pendingand updates due date to next logical occurrence. - Does NOT award points (clean slate for next cycle).
- Calculates
-
Edge Cases:
- Multiple Overdue: If kid has multiple overdue instances of same recurring chore (rare), reset advances to next occurrence.
- Paused Chores: Reset will reschedule even if chore was manually paused (due date will be set).
-
Approved but Overdue: If chore was approved but system still considers it overdue (timing edge case), reset forces back to
pending.
Description: The "Soft Reset."
Action: Sets ALL chores to pending. Resets approval_period_start to now.
Use Case: Debugging a schedule that got desynchronized.
Description: Resets the Counters (e.g., "Times Applied"), not the definitions. Use Case: Monthly "Clean Slate." If you track "Penalties this month," run this automation on the 1st.
Description: Revokes badges. Logic: _ Specific Badge + Kid: Revokes one. _ Badge only: Revokes that badge for everyone. * Kid only: Revokes ALL badges for that kid.
Description: Links a Kid Profile to a Parent Profile (creating a Shadow Kid).
-
⚠️ Trap: Name Matching: Thenamefield must match BOTH an existing Parent Name and an existing Kid Name (case-insensitive). If names don't match, the link fails. -
Actions:
linkorunlink. -
Behavior: Unlinking renames the kid to
[Name]_unlinkedto preserve history rather than deleting data.
Description: The "Factory Reset."
Action: 1. Creates a backup (kidschores_data_<timestamp>_reset). 2. Wipes the .storage/kidschores_data file. 3. Cleans the Entity Registry. 4. Reloads the integration.
Use Case: Nuclear option for corrupted data or fresh installs.