Repository navigation
fix(devices): default the device time zone to the server time zone - #294
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the region-aware time zone fallback changes to home data and device details.
No open issues 🎉
What changed in this PR
This PR extends the region-aware time zone behavior introduced for /location to home data and device details. Devices without their own time zone use network.timezone when configured, otherwise the region default; device-specific values remain unchanged.
Changes:
- Centralizes time zone fallback logic in
default_timezone(ctx)and reuses it across responses. - Adds regression coverage for regional defaults, configured overrides, and device-specific time zones.
- Documents the expanded configuration behavior.
| File | Description |
|---|---|
tests/test_home_data_online.py |
Tests time zone defaults and overrides in home and device-detail responses. |
tests/conftest.py |
Adds region and time zone options to the configuration helper. |
src/roborock_local_server/bundled_backend/shared/data_helpers.py |
Houses the shared time zone resolver and region mapping. |
src/roborock_local_server/bundled_backend/shared/constants.py |
Removes the fixed device time zone constant. |
src/roborock_local_server/bundled_backend/https_server/routes/user/devices/service.py |
Uses the shared fallback for device normalization and details. |
src/roborock_local_server/bundled_backend/https_server/routes/bootstrap/location.py |
Delegates time zone resolution to the shared helper. |
src/roborock_local_server/bundled_backend/https_server/endpoint_rules.py |
Applies the shared fallback when normalizing home-data devices. |
config.example.toml |
Clarifies that the time zone setting also applies to devices lacking one. |
Review effort: Balanced
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Confirmed:
- Defaults: devices without a time zone now get
network.timezone, else the region default, in both home data and/user/devices/<duid>. An existingtimeZoneIdstill wins, and the cloud import keeps it. - Field format:
timeZoneIdis an IANA name string in the APK'sDeviceBean/DeviceBean2/DeviceRespBean. - Host-independent: the host time zone isn't used, so Docker or the HA add-on running in UTC makes no difference.
- Robot behaviour is unchanged. V1 bundles set the robot's time zone from the phone (
set_app_timezone), and timers and scenes readget_timezonefrom the robot. B01 bundles never readtimeZoneId.
Unverifiable: the visible effect in the app.
Breaks #179 after merge. There's no text conflict, but #179 imports DEFAULT_TIMEZONE (jobs.py:8, schedule_runner.py:14), which this PR removes, so its schedule and timer tests fail with an ImportError. Either keep DEFAULT_TIMEZONE as an alias here, or have #179 switch to default_timezone(ctx); that's noted on #179 too. #213 and #214 need the same.
Nits:
eualways givesEurope/Berlin, an hour off for the UK, Ireland and Portugal. The docs could tell those users to setnetwork.timezone.- The default at
service.py:632is never reached.
Checks: all 506 tests pass. It merges cleanly with #292 and #293. #295 conflicts on an import line in endpoint_rules.py.
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.
|
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.
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.
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.
The comment that main has no data_helpers.default_timezone goes stale with this branch, so it now says what the test covers.
43af641 to
6db64e9
Compare
Lash-L
left a comment
There was a problem hiding this comment.
Automated review: passed (nits)
Now that this has passed the automated review, I'll do a human review and then either request changes or merge it.
Since the last review (9962136 → 6db64e9)
- Breaks #179 after merge: fixed.
DEFAULT_TIMEZONEstays inshared/constants.py:7, anddefault_timezonefalls back to it (shared/data_helpers.py:80). #179 is now on main, and itsserver_timezone(shared/schedule_runner.py:167) picks up the real helper. #213 and #214 can still import the constant. euis an hour off for the UK, Ireland and Portugal: fixed.config.example.tomlnow tells those users to setnetwork.timezone.- Unreachable default at
service.py:632: kept on purpose (main has the same structure). Fine. - New:
nextFireTimenow uses the runner's zone.device_jobs_payload(routes/user/devices/service.py:734) callsdefault_timezone(ctx), the same zone theScheduleRunnerfalls back to (schedule_runner.py:286). Before this change, aneuserver withoutnetwork.timezoneshowed a time in New York for a job the runner fires in Berlin.
Confirmed:
- DST: in a scratch run,
0 8 * * *ineugives 06:00Z in July and 07:00Z on the fall-back day.30 2 * * *skips the missing 02:30 on 2026-03-29 and fires once, at the first 02:30, on 2026-10-25.usand unknown regions stay onAmerica/New_York. - Host time zone isn't used. Nothing reads
/etc/localtimeorTZ, so a UTC or tz-less container gives the same result.network.timezoneis checked at load time (config.py:225). - Field format:
timeZoneIdis a plain string in the APK beans (DeviceBean.java:268,DeviceBean2.java:1408,DeviceRespBean.java:239), and the server sends IANA names. Timers made in the app sendtimeZoneId: sharedCache().robotTimeZone(the zone the robot reports) in the job body, so the new default doesn't change them. - Schedules that store their own
timeZoneIddon't change. That covers jobs fromPOST .../jobs(jobs.py:86), timer RPCs (timer_rpc.py:198) and the app.
Unverifiable: the visible effect in the app, and whether the robot ever reads timeZoneId from home data.
Nits:
- Existing schedules without a
timeZoneIdwill move. On a non-usserver withoutnetwork.timezone, they now fire in the region's zone, for example 6 hours earlier in absolute time ineu. That's the intended fix, but add one line to the release notes or the add-on CHANGELOG so users aren't surprised. - tzdata (already true on main, not caused by this PR):
ZoneInfoneeds system zone data, and the image (python:3.11-slim) doesn't installtzdataexplicitly. If a base image ever ships without/usr/share/zoneinfo,ZoneInforaises an error. The schedule runner andnextFireTimethen skip every job. Addingtzdatatodependenciesinpyproject.tomlwould rule this out. That could go in a follow-up.
Checks: all 727 tests pass on 6db64e9. It merges cleanly with main and with #293. The two PRs touch different files, and #293 doesn't use time zones.
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.
|
Good change, TY! |
What does this PR do?
Devices without their own time zone now get
network.timezoneif set, else the time zone of the region (for exampleEurope/Berlinforeu). Before, they gotAmerica/New_Yorkin the home data and in/user/devices/<duid>.Problem
network.timezoneand the region reached only the/locationroute (#123). The device lists used a fixedAmerica/New_Yorkfor every device that had no time zone of its own.Change
default_timezone(ctx)inshared/data_helpers.py. It holds the region table that was inroutes/bootstrap/location.py. For a region without its own time zone, it falls back toDEFAULT_TIMEZONE./locationroute, the home data and/user/devices/<duid>all use it.DEFAULT_TIMEZONEstays inshared/constants.py, so open PRs that import it still work.GET /user/devices/<duid>/jobscomputesnextFireTimewithdefault_timezonetoo. The schedule runner of Add server-side scheduling that runs jobs the way the cloud does #179 picks its zone the same way, sonextFireTimenames the time the job runs. Take aneuserver withoutnetwork.timezoneand a job at 08:00 withouttimeZoneId. Without this change, the job runs at 08:00 in Berlin, but itsnextFireTimenames 08:00 in New York.config.example.tomlsays thattimezonealso applies to devices. It also asks users to set it if their time zone differs from the region default, such asEurope/Londonin theeuregion.tests/conftest.py:write_release_configtakesregionandtimezoneoptions.#179 is now on main. Its schedule runner already calls
default_timezonewhen that exists. So with this PR, a schedule without its own time zone runs innetwork.timezoneif set, else in the region's time zone, for exampleEurope/Berlinin theeuregion. #213 and #214 importDEFAULT_TIMEZONE. They still work after this PR, but they keepAmerica/New_Yorkuntil they switch todefault_timezone(ctx).For the release notes: a schedule without its own
timeZoneIdmoves on a server outsideuswithoutnetwork.timezone. It now fires in the region's time zone, so ineuit fires about 6 hours earlier than before. Setnetwork.timezoneto keep another zone.Before you open this PR (optional, but very helpful)
PRs I reviewed:
Proof that it works
Tested on:
roborock.vacuum.a307)02.17.50a307-pluginbranch. That build is upstream main 32608dd plus this PR, feat(api): enable scene tiles via productTags and category cardSpec #208 and my other fixes for the a307. The tests ran on this branch, rebased on upstream main f1e49fd.What I did and what happened:
The change runs on my EU server. I have not checked a visible effect in the app, so the proof is the tests:
test_device_time_zone_defaults_to_the_server_time_zonecheckstimeZoneIdin the home data and in/user/devices/<duid>for four cases:eugivesEurope/Berlin,usgivesAmerica/New_York,timezone = "Europe/Vienna"wins over the region, and a device time zone ofAsia/Tokyowins over both.test_device_jobs_endpoint_returns_imported_schedulesnow runs forusandeu. Foreu, a job at 13:03 on Dec 15 gets thenextFireTime12:03Z, which is 13:03 in Berlin. Without thenextFireTimechange, it gets 18:03Z.test_server_timezone_without_a_configured_zone_uses_the_region_zonechecks the zone of the schedule runner with the realdefault_timezone.uv run --extra dev pytest -qpasses (727 tests).Screenshots (required for any UI change)
No UI changes.