Skip to content

Add server-side scheduling that runs jobs the way the cloud does - #179

Merged
Lash-L merged 27 commits into
Python-roborock:mainfrom
virtitnerd:feat/schedule-store
Nov 22, 2026
Merged

Lash-L merged 27 commits into
Python-roborock:mainfrom
virtitnerd:feat/schedule-store

Conversation

@virtitnerd

@virtitnerd virtitnerd commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Roborock schedules are run by the cloud: the official app writes each one as a job (/user/devices/{duid}/jobs) and the cloud starts the clean when it is due. Against this server those calls had nowhere to go, so clients like LocalRock saw no schedules, could never create one, and a schedule made in the official app never ran. This covers both the legacy get/set/upd/del_timer robots and robots on the newer server_timer protocol.

Changes

  • A schedule store per device (cron, enabled state, vac/mop settings), persisted in the existing inventory, with an HTTP API to create, update and delete schedules (the official app's /jobs calls). POST returns the new job id as a string and PUT/DELETE return "done", because IotApi declares these calls as ApiReturn<String> (the exact cloud strings are unverified). Creating with an empty id, which is what the official app posts, assigns one.
  • set_timer, and upd_timer/del_timer for a stored job, are answered from the store, in LocalRock's layout and in the official app's (no status element). get_timer goes to the robot and the store's jobs are added to its reply; if the robot has not answered after 6 seconds, the store's timers are sent alone. Timers the store does not hold, and patrol timers, go to the robot. Editing merges settings rather than resetting them; an empty action object leaves existing settings alone. One-time schedules (day and month pinned, e.g. 15 23 18 10 *) are listed with their date, the form the robot and the official app use. A settings entry's name, the official app's link to the robot-side timer, is kept so a client can find that timer to edit or delete it.
  • Crons accept day and month names (MON-FRI, JAN) and weekday ranges that wrap or reach Sunday.
  • A cron runner that evaluates each device's schedules against its own timezone and starts the clean when one is due, through the existing routine runner (extended to start without a saved scene).
  • How a schedule is started. A job that carries a robot-side timer id (name) is run the way the cloud runs it: the robot is sent server_scheduled_start with the job's settings entry. The robot accepts it for room and whole-home schedules, and for a room schedule it records the clean as "Schedules" in its history. A job without a timer id (one saved through legacy set_timer) is started with the plainer commands: a whole-home clean is one app_start carrying the schedule's fields plus source: 3 (which the robot also records as "Schedules"), and a room schedule is the settings commands followed by a segment clean. If the robot refuses that single app_start with -10005, the settings are sent as separate commands. A job that has a timer id is never retried another way: a refusal can mean the timer is off or gone, and an ordinary clean would bypass that. Scenes and routines are untouched; the new step types are produced only by schedules.
  • Native timers are read in both the usual [name, on|off] layout and the S6 MaxV layout (["Y <name> 1 1 <cron> app_start", 0], where upd_server_timer needs the whole string).
  • The native sync keeps one connection per robot and backs off while a robot is unreachable; the scheduler caches the inventory by file id, size and modification time. Missed-run behaviour is documented in docs/schedules.md.

Deliberately out of scope

get/set/upd/del_server_timer are not answered from the store. They are forwarded to the robot, which keeps those entries and from which the official app reads them back. Answering them locally, which I tried and reverted during development, hid the robot's real schedules from every client, and the official app then deleted the entries it no longer recognized. A parametrized test guards that this stays so. What runs a server_timer schedule here is its /jobs record, which the runner fires like any other job.

How the start was found

The robot does not run a server_timer entry by itself: with the runner told to skip those jobs, four scheduled times passed with the robot idle. So the server has to start them. Starting a clean with the settings commands and an empty app_start works but the robot records it as started by "App". Sending server_scheduled_start (the method name inside the job) with only the job's settings is refused with -10005 "Invalid timer", and with a bare id with "Param should be name + fan + segment"; with the job's whole settings entry including name it runs (a room schedule's history reads "Schedules | Rooms"). Separately, app_start takes a source field and source: 3 is recorded as "Schedules" (other spellings tried, such as start_type, are ignored).

Merge order and dependencies

Related

#88 is the same territory; I held this back for a bit specifically to avoid stepping on that work. Happy to coordinate however's easiest, this doesn't need to be the one that lands if yours is further along, consider it an alternative or reference rather than a race.

Tested

pytest: 692 passed. Verified live on a Roborock Qrevo. End to end: a one-time whole-home schedule created from LocalRock was run by the server at its scheduled minute with exactly one command, server_scheduled_start carrying the job's settings entry, which the robot answered ok; the robot's history shows it as "Schedules | Full". Commands sent to the robot directly: server_scheduled_start for a room schedule (history: "Schedules | Rooms"), and app_start with source: 3 (history: "Schedules | Full"). The fallback paths are covered by unit tests against a fake robot that answers -10005.

Not run on hardware by me: the S6 MaxV native layout and the official app's set_timer payloads are covered by unit tests only. C9H13NO3-dev ran an S6 MaxV (a10, firmware 02.62.46) against earlier heads and reported schedules firing (see the comments above); the changes since then have not been run on an S6. The write response strings are not verified against the real cloud.

Closes #88

@virtitnerd
virtitnerd marked this pull request as draft October 18, 2026 03:05
@virtitnerd
virtitnerd marked this pull request as ready for review October 18, 2026 13:21
@virtitnerd
virtitnerd marked this pull request as draft October 18, 2026 14:08
@virtitnerd
virtitnerd force-pushed the feat/schedule-store branch 2 times, most recently from 297fc12 to 59bf2e6 Compare October 18, 2026 17:13
@virtitnerd virtitnerd changed the title Add server-side scheduling for cloud-managed (legacy set_timer) robots Add server-side scheduling that runs jobs the way the cloud does Oct 18, 2026
@virtitnerd
virtitnerd marked this pull request as ready for review October 18, 2026 17:30
@Lash-L Lash-L self-assigned this Oct 22, 2026
@virtitnerd

Copy link
Copy Markdown
Contributor Author

A status note, in case it helps with review: this PR is still mergeable and clean against main after today's commits, and I have not needed to change it since the last push.

Other work now builds on it, so it is the piece the rest is waiting for:

If it is easier to review in pieces, I can split it: the store and its API first, then the executor that fires jobs. Just say which you would prefer, or point me at anything you want changed first.

@C9H13NO3-dev

Copy link
Copy Markdown

Test report: S6 MaxV (roborock.vacuum.a10, firmware 02.62.46) on top of main @ 02a1770, PR head ce54133. The full test suite passes (582 passed).

Before this PR (on main)

  • LocalRock's set_timer ([[id, ["on", [cron, ["start_clean", {}]]]]]) is forwarded to the robot. The robot rejects it with -10005 "Timer format error: data should be json".
  • The robot does accept the legacy layout [[id, [cron, ["start_clean", {"segments":"","fan_power":102,"water_box_mode":202,"repeat":1}]]]]. It turns it into a server timer (get_server_timer → ["Y <id> 1 1 <cron> app_start", 0]) and leaves get_timer empty.
  • Confirms what you found: the robot does not run that entry itself. I set a timer for 2 minutes ahead in the robot's timezone (get_timezone → Europe/Berlin). The robot stayed docked, sent nothing to the server at the due minute, and the server sent it nothing.
  • Side note for the native sync: upd_server_timer only accepts [[<full "Y …" entry string>, "on"|"off"]] here. After that, the entry shows as ["Y …", "off", 0]. del_server_timer also needs the full entry string. A bare id returns ok but changes nothing.

With this PR

  • The same LocalRock set_timer payload is answered locally (['ok']), and get_timer over MQTT lists it.
  • At the due minute the runner logged Schedule … fired: started and sent app_start [{repeat:1, segments:"0", clean_mop:1, map_index:-1, source:3}]. The robot went to state 5 (cleaning) right away. ✅
  • del_timer removes the job from the store.

One rough edge: right after a container restart, native_schedule_sync.refresh logs Could not save native schedule reconciliation with a CancelledError traceback. That's because the robot hasn't reconnected over MQTT yet, so get_server_timer times out. Later polls succeed. It might be worth skipping or retrying quietly until the device's rr/d topic is known.

@virtitnerd

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough test. I fixed the restart traceback: a timed-out MQTT read was being caught by the save-failure handler because TimeoutError is an OSError, so it now logs quietly at debug level and only real save failures warn. I'm leaving the full-entry timer format as an observation for now, since the sync only replays what the app sent.

virtitnerd added a commit to virtitnerd/local_roborock_server that referenced this pull request Nov 14, 2026
The map backup and capabilities probes reach the robot through the routine
runner's get_routine_runner(), which comes with the schedule store (Python-roborock#179).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Lash-L Lash-L added area: routines Routines, scenes, schedules and cleaning execution. feature PR adding capability; under this two-type scheme also covers additive documentation. labels Nov 15, 2026
@Lash-L

Lash-L commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

@C9H13NO3-dev I appreciate you testing out this PR!

@virtitnerd - this PR has conflicts now, can you fix?

@virtitnerd

Copy link
Copy Markdown
Contributor Author

Rebased on the current main and fixed the conflicts. Same 9 commits. The conflicts were in devices/service.py, routine_runner.py, its tests and known_limitations.md. In each one I kept what main changed (the new inventory imports and device name limits, the _OPTIONAL_SETTING_COMMANDS set and its test, the updated limitations bullets) and put the schedule changes on top. The full test suite passes on the rebased branch (611 passed).

@C9H13NO3-dev

C9H13NO3-dev commented Nov 15, 2026 •

Copy link
Copy Markdown

Follow-up test on the rebased head a1a1991 (on main @ 32608dd), same S6 MaxV (roborock.vacuum.a10, firmware 02.62.46).

  • Full test suite: 611 passed.
  • Upgraded in place from the old head ce54133 with the existing data directory. The robot reconnected on its own, with no re-pairing.
  • Restart noise is fixed. On ce54133 every restart logged two Could not save native schedule reconciliation warnings with tracebacks (CancelledError → TimeoutError). The same thing happened every night around 03:20 local time, when this robot drops off MQTT for a moment. In 3 days I saw 10 of them, all TimeoutError, none real save failures. On a1a1991, after a restart: 0 warnings, and get_server_timer polls resume once the robot is back.
  • LocalRock-format timer lifecycle, sent over MQTT through the server: set_timer [[id, ["on", [cron, ["start_clean", {}]]]]] → ok. get_timer lists it (normalised to {"repeat":1,"segments":"0"}). upd_timer off and upd_timer on both apply and show up in get_timer. del_timer removes it. The robot's own get_server_timer was not changed and the robot stayed docked.
  • Real-world result from the previous head: a schedule imported from the Roborock cloud (00 10 * * ?, Europe/Berlin) fired every day at 10:00 local time on Nov 13, 14 and 15 (Schedule 6720712 … fired: started followed by Completed routine scene=Schedule 6720712). That one stays enabled on this head, so the next run will be on a1a1991.

Thanks for the quick fix!

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: changes requested

The core design holds up. The store, the at-most-once occurrence claims, atomic persistence (temp file, fsync, os.replace) and restart/rollback safety are all sound, and 611 tests pass at a1a1991.

Confirmed:

  • The four job routes match IotApi.java: GET/POST user/devices/{duid}/jobs and PUT/DELETE .../jobs/{jobId}.
  • TimerBean has the fields cron, enabled, id, param, repeated.
  • The app's native flow (set_server_timer to the robot, then a cloud job {id, method:"server_scheduled_start", params} via rrAddOrEditTimer) matches your job model.
  • TimerBean has no timeZoneId, so defaulting to network.timezone is reasonable.
  • Scene TIMER triggers are correctly left alone.

Blocking:

  1. The official app's set_timer layout is rejected (shared/timer_rpc.py:88-104, interceptor at :183-228).
    • The app writes [[id, [cron, ["start_clean", {...}]]]], with no status element (tanos module_3621.js setTimerOnRobot; patrol timers use app_start_patrol).
    • _parse_set_timer reads that as status=cron and cron="start_clean", giving ('id', False, 'start_clean', {}), and the client gets back an error with code -1.
    • Because every get/set/upd/del_timer is now answered locally, the robot's own legacy timers also disappear from get_timer.
    • The tests only cover LocalRock's ["on", [cron, action]] layout.
  2. The write responses probably don't match the app's types (routes/user/devices/jobs.py:101,148-149,214). IotApi declares POST/PUT/DELETE as ApiReturn<String>; only GET is ApiReturn<List<TimerBean>>. Returning the job object in result would likely fail Gson parsing, so the app would show failure even though the job was saved. Not tested live.
  3. Native dispatch and sync assume [name, "on"|"off", …] (routine_runner.py _run_steps, native_schedule_sync.py:29-37,97-111). The S6 MaxV reported ["Y <id> 1 1 <cron> app_start", 0], and upd_server_timer needs the full entry string. On that firmware, native-linked jobs never match, so they don't fire and enable/disable never syncs. The successful S6 run was on a head from before #213's verification step.

Should fix:
4. Constant polling. Every device with a native-linked job gets a new MQTT connection and a get_server_timer call every 30s, indefinitely (native_schedule_sync.py:240-266). The scheduler also reloads the whole inventory JSON every 20s (schedule_runner.py:268). Both block the event loop.
5. Smaller issues:

  • The PR body's fallback description contradicts docs/schedules.md and fallback_commands_for_step, which say native starts never fall back.
  • Day names like MON are rejected (schedule_runner.py:95-98).
  • A failed set_timer save raises inside the interceptor, and the request is then forwarded to the robot anyway.
  1. Please document the missed-run behaviour.
    • There's no catch-up, and the first tick only sets a baseline, so a job due during a restart is lost.
    • An occurrence is consumed when the robot is offline or a routine is running.
    • A one-time job is then disabled.

Conflicts: clean with main, #224, #283 and #285. #247 conflicts in routine_runner.py and its tests; keep both sides.

Tests: add the official app's real set_timer payloads, get_server_timer replies from other firmware, and the write response shape.

I've converted this PR to draft while these are addressed. Mark it ready for review again once they're fixed and it will go through another review.


This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.

@Lash-L Lash-L added the failing auto review Automated review requested changes before merge label Nov 21, 2026
virtitnerd and others added 7 commits November 21, 2026 19:23
A cron such as "00 11 ? * MON-FRI" was rejected by the scheduler and by the job routes. Day
names (SUN to SAT) and month names (JAN to DEC) now work in lists, ranges and steps, in any
case. get_timer writes them out as numbers, since robot clients read digits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…les.md

States what happens to an occurrence when the server is down, the robot is offline or busy, or
its native timer is off: no catch-up, the first tick is only a baseline, the occurrence is
consumed, and a one-time job is disabled either way. Also records the string results of the job
writes (unverified against the cloud), how get_timer is merged, the S6 MaxV timer layout and the
read back-off.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The official app posts a new schedule with "id":"" and expects the cloud to assign one. The store
only generated an id for None, so the job was saved with an empty id, the create answered with an
empty string, a second create was refused as a duplicate and the scheduler skipped the job.
None, an empty string and whitespace now all mean assign an id.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Writes replace the file through a temp file, so two writes inside one coarse mtime tick that
leave the size unchanged would have been missed. The file id changes with every replacement.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MON-SUN, FRI-SUN and 6-0 style ranges were rejected as out of range; they now run to the end of
the week or wrap past Saturday. A day-of-month or day-of-week field that starts with * (such as
*/2) now counts as unrestricted, which is how Vixie cron decides between AND and OR for the two
day fields (from memory of its entry.c, not re-checked against the source here; the cloud's own
rule is not known).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…bot errors

- With the store holding timers and the robot offline, a forwarded get_timer got no reply at all.
  The bridge now asks the interceptor for a fallback and, if the robot has not answered after
  6 seconds, replies with the store's timers.
- A robot error reply to get_timer was turned into a success carrying only the store's timers.
  Error replies now pass through unchanged.
- One imported job with a cron get_timer cannot show (for example an unknown day name) raised
  KeyError and hid every other timer. That job is skipped. get_timer also writes Sunday as 0 and
  expands wrapping ranges for clients that only know 0 to 6.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comments and docstrings added by this PR are cut to two lines, and the two overlapping
missed-run sections of schedules.md are one. The docs also state the get_timer fallback.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@virtitnerd

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review. Everything below is on the pushed head e3ca337, and the full suite passes there (692 passed). I rewrote the branch history before pushing, so the hashes from earlier commits no longer exist.

Blocking

  1. Official set_timer layout. You were right. [[id, [cron, ["start_clean", {...}]]]] was read as status=cron and answered with -1. set_timer now accepts [id, [status, [cron, action]]], [id, status, [cron, action]] and the official layout with no status element, which is stored as enabled (b437ef1). The robot's own timers are no longer hidden: get_timer goes to the robot and the store's jobs are added to its reply, and upd_timer and del_timer for an id the store does not hold go to the robot. Patrol timers (app_start_patrol) are forwarded, because the server cannot start a patrol. If the robot has not answered get_timer after 6 seconds, the store's timers are sent alone so an offline robot still shows them, and a robot error reply is passed through unchanged (15212dc). The patrol payload beyond the action name is not captured anywhere I have, so that test uses a minimal body.
  2. Write responses. POST now returns the new job id as a plain string in result, and PUT and DELETE return "done" (ad0da1b). That matches IotApi's ApiReturn<String> and python-roborock's job tests. I could not find a captured cloud response for these calls, so the exact strings are not verified against the real service, and none of this was tested live. The two constants are WRITE_DONE and the POST return in routes/user/devices/jobs.py. The official app's create body carries "id": ""; an empty or blank id now means "assign one" (b80e279), with a test for two creates in a row. Ordering note: LocalRock before Rework schedules: options, server_timer support, SmartPlan, Once and Repeat DonSidro/LocalRock#37 reads the POST result as an object, so it saves the job but reports a failure. Add documentation for updating to stable #37 accepts both shapes, so please merge it first or together.
  3. S6 MaxV native entries. shared/native_timers.py reads both the [name, "on"|"off", ...] layout and the S6 layout (["Y <id> 1 1 <cron> app_start", 0], ["Y ...", "off", 0]). Dispatch in _run_steps, the periodic read, the HTTP enable path and the observed upd_server_timer all use it. upd_server_timer is sent the whole entry string the robot listed, then confirmed by reading back (518e2df). I do not have an S6, so this is covered by unit tests only, using the reply from the test report plus a fake S6 that ignores a bare id. It is not run on hardware.

Should fix

  1. Polling (05bd287). One MQTT connection per robot, dropped after any failed or cancelled read. An unreachable robot is retried after 30 s, then 60, 120 and so on up to 10 minutes; a forwarded native write still triggers an immediate read. The scheduler and the sync read the inventory through a cache that reparses only when the file's id, size or modification time changes (4ec6465). The job read and the reconciliation write run in a worker thread. Robots with no native-linked job are still never connected to.
  2. Smaller issues.
    • The PR body was wrong and the docs are right: native starts never fall back. The description is updated.
    • Day and month names (MON, MON-FRI, JAN) work in lists, ranges and steps (58ab1f6). Ranges that wrap or reach Sunday (MON-SUN, FRI-SUN, 6-0) work too, and a day field starting with * counts as unrestricted as in Vixie cron (from memory; the cloud's own rule is unknown). get_timer writes names and 7 back as 0 to 6 (da01b1e).
    • A failed set_timer or upd_timer save now answers with an error and is not forwarded to the robot (b437ef1, with a test).
  3. Missed runs are documented in docs/schedules.md (8f6e116, with the two overlapping sections merged and long comments shortened in e3ca337). There is no catch-up, the first tick only sets a baseline, an occurrence is consumed when the robot is offline, its native timer is off or a routine is running, and a one-time job is disabled either way.

Tests. Added: the official app's set_timer payloads, the interceptor and bridge get_timer merge, the S6 replies, the write response shape, cron names, connection reuse and back-off, and the cached inventory.

Conflicts. #247 still conflicts in routine_runner.py and its tests. I have not resolved it here; whichever lands second keeps both sides.

For #213 (pponce). It builds on this PR, so these are the names to know: TimerRpcInterceptor.request_fallback, timer_rpc.FALLBACK_SECONDS, MqttTopicBridge(request_fallback=...), shared.native_timers, NativeScheduleSync.aclose, inventory_io.CachedInventory, timer_rpc.ForwardToRobot (raised by handle_timer_request for timers the store does not own) and TimerRpcInterceptor.merge_response. MqttTopicBridge also takes an optional response_rewriter, and NativeScheduleSync.refresh now keeps its connection between calls. No existing public name was renamed; schedule_runner.load_inventory is still importable.

The PR description is updated to match. I will mark this ready for review again.

@virtitnerd
virtitnerd marked this pull request as ready for review November 22, 2026 02:52

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: passed (nits) (re-review at e3ca3378)

Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.

Earlier findings:

Finding Status
The official app's set_timer layout was rejected, and the robot's own timers hidden Fixed. [id,[cron,[action,{…}]]] is accepted. Patrol timers go to the robot. get_timer asks the robot and adds the store's entries to its reply, with a 6s fallback. Unknown ids for upd_timer/del_timer are forwarded. Matches tanos setTimerOnRobot.
Write responses didn't match ApiReturn<String> Fixed. POST returns the id as a string and PUT/DELETE return "done" (IotApi.java). The exact cloud strings are unverifiable.
Native timers assumed [name,"on"/"off"] Fixed in unit tests. Both layouts are parsed, and upd_server_timer sends the full entry string. Not verified on an S6, including whether it accepts server_scheduled_start.
Polling and inventory reloads Mostly fixed. One reused MQTT connection per robot with back-off, and the inventory is cached. A 30s get_server_timer read per robot remains, which is acceptable.
Fallback description, MON day names, failed save still forwarded, missed-run docs Fixed.

Worth fixing before merge:

  1. Editing a robot-owned legacy timer creates a copy (timer_rpc.py:162-182).
    • The app re-sends set_timer with the existing timer's id (name = state.name || …).
    • The store saves a copy while the robot keeps the original, and merge_response then hides the store's copy, so the edit looks lost.
    • On firmware that runs its own timers, the robot could also start a second clean.
    • Fix: forward set_timer to the robot when the store doesn't own the id.
  2. The app may send a positional action, ["start_clean", fan_power, segments(, map_id)] (tanos module_3621.js ~4229). _parse_set_timer would then see no settings and run a whole-home clean at the default fan power. The decompiled code is ambiguous here, so map the positional fields or forward the request.
  3. Merging with #294 breaks this PR. #294 deletes DEFAULT_TIMEZONE, which jobs.py:8 and schedule_runner.py:14 import, so tests/test_schedules.py and tests/test_timer_rpc.py fail with an ImportError. Use #294's default_timezone(ctx) instead, which also stops EU users falling back to New York time.

Minor:

  • A robot error reply to get_timer hides the store's timers.
  • _pending entries are never cleared after a merge.
  • SUN-SUN parses as the whole week.

Checks: all 692 tests pass. It merges cleanly with main. #247 still conflicts in routine_runner.py; keep both sides.


This is an automated review by Claude Code, checked against the decompiled Roborock app (APK + device plugin bundles, refreshed 2026-11-21), python-roborock and a vacuum firmware dump. It can be incorrect, so please reply if any finding looks wrong.

@Lash-L Lash-L added passed auto review Automated review found no blocking issues and removed failing auto review Automated review requested changes before merge labels Nov 22, 2026
virtitnerd and others added 7 commits November 22, 2026 11:10
PR 294 deletes shared.constants.DEFAULT_TIMEZONE, which jobs.py and
schedule_runner.py import, so merging both broke test collection. server_timezone()
uses data_helpers.default_timezone(ctx) when it exists (294) and otherwise the
configured zone, then America/New_York, so the branch works with and without 294.
ScheduleRunner and the timer interceptor now fall back to it instead of a fixed
New York default, so EU installs get their region's zone once 294 lands.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With 294 merged, default_timezone(ctx) reads ctx.timezone and raised on the
minimal contexts several tests and callers pass. Fall back to the configured zone
and then America/New_York instead of failing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A robot that answers get_timer with an error (firmware without the legacy
timers) made the app show that error and none of the store's schedules. Reply
with the store's timers instead; with an empty store the error still passes
through unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Entries lingered for 30 seconds after the merge and only left when the next
get_timer pruned them. The reply path now removes its own entry; the fallback
still sees the answered flag on the object it holds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The app edits a legacy timer by re-sending set_timer with its id. The store saved
a copy while the robot kept the original, and the merged get_timer then hid the
copy, so the edit looked lost (and a robot running its own timers could start
twice). The interceptor now remembers the ids in each robot's last get_timer reply
and forwards set_timer for one the store does not own. New ids still go to the
store. The list is in memory, so it is empty after a server restart until the app
reads the timer list again, which it does before offering an edit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
For robots without order-segment clean the app sends
["start_clean", fan_power, segments(, map_id)] (decompiled timer screen builds
mode as fan_power). _parse_set_timer saw no settings object and stored a whole-home
clean at the default fan power. Map fan_power and segments; forward the request to
the robot when a map id is present or the fan power is not a number, since the store
has no per-map timers and the exact map id meaning is unverified.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A range ending on SUN was stretched to the end of the week, which turned SUN-SUN
into every day. The stretch now applies only when the range starts after Sunday.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 22, 2026
Python-roborock#179, Python-roborock#213 and Python-roborock#214 import DEFAULT_TIMEZONE from shared.constants.
Removing it would break them with an ImportError, whichever PR merges
second. default_timezone now falls back to it instead of a new
FALLBACK_TIMEZONE, so the value stays America/New_York.

config.example.toml now asks users to set network.timezone if their
timezone differs from the region default, such as Europe/London in the
eu region.

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the back and forth on this. Looks good and I appreciate the contribution!

@Lash-L
Lash-L merged commit 4c7bfcd into Python-roborock:main Nov 22, 2026
3 checks passed
@virtitnerd
virtitnerd deleted the feat/schedule-store branch November 22, 2026 19:42
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 22, 2026
GET /user/devices/<duid>/jobs computed nextFireTime in network.timezone,
else America/New_York. The schedule runner of Python-roborock#179 uses default_timezone,
which falls back to the region's zone. Take an eu server without
network.timezone and a job at 08:00 without timeZoneId: the job ran at
08:00 in Berlin, but its nextFireTime named 08:00 in New York. The route
now uses default_timezone too.
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 22, 2026
Python-roborock#179, Python-roborock#213 and Python-roborock#214 import DEFAULT_TIMEZONE from shared.constants.
Removing it would break them with an ImportError, whichever PR merges
second. default_timezone now falls back to it instead of a new
FALLBACK_TIMEZONE, so the value stays America/New_York.

config.example.toml now asks users to set network.timezone if their
timezone differs from the region default, such as Europe/London in the
eu region.
Hoeze added a commit to Hoeze/local_roborock_server that referenced this pull request Nov 22, 2026
GET /user/devices/<duid>/jobs computed nextFireTime in network.timezone,
else America/New_York. The schedule runner of Python-roborock#179 uses default_timezone,
which falls back to the region's zone. Take an eu server without
network.timezone and a job at 08:00 without timeZoneId: the job ran at
08:00 in Berlin, but its nextFireTime named 08:00 in New York. The route
now uses default_timezone too.
Lash-L pushed a commit that referenced this pull request Nov 28, 2026
)

* fix(devices): default the device time zone to the server time zone

Devices without their own time zone got America/New_York in the home
data and in the device detail. network.timezone and the region reached
only the location route. The device lists now use the same default:
network.timezone if set, else the time zone of the region, for example
Europe/Berlin for eu.

* fix(devices): keep DEFAULT_TIMEZONE as the fallback of default_timezone

#179, #213 and #214 import DEFAULT_TIMEZONE from shared.constants.
Removing it would break them with an ImportError, whichever PR merges
second. default_timezone now falls back to it instead of a new
FALLBACK_TIMEZONE, so the value stays America/New_York.

config.example.toml now asks users to set network.timezone if their
timezone differs from the region default, such as Europe/London in the
eu region.

* fix(devices): compute nextFireTime in the schedule runner's time zone

GET /user/devices/<duid>/jobs computed nextFireTime in network.timezone,
else America/New_York. The schedule runner of #179 uses default_timezone,
which falls back to the region's zone. Take an eu server without
network.timezone and a job at 08:00 without timeZoneId: the job ran at
08:00 in Berlin, but its nextFireTime named 08:00 in New York. The route
now uses default_timezone too.

* test(schedules): cover server_timezone with the real region helper

The comment that main has no data_helpers.default_timezone goes stale
with this branch, so it now says what the test covers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: routines Routines, scenes, schedules and cleaning execution. feature PR adding capability; under this two-type scheme also covers additive documentation. passed auto review Automated review found no blocking issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduling

4 participants