Add battery widget (device's own last-reported level, no live upstream)
Shows Frame.battery_percent/battery_as_of, already set by every device wake-on-battery report, plus routers/common.py's existing battery_estimate_s time-remaining estimate -- nothing new to fetch or cache. Compact (icon + percent) or detailed (+ estimate, last report age) display mode. No button actions.
This commit is contained in:
@@ -82,6 +82,9 @@ def test_expected_columns_exist_on_current_schema():
|
||||
assert "weather_widget_configs" in inspector.get_table_names() # migration 24
|
||||
weather_widget_columns = {c["name"] for c in inspector.get_columns("weather_widget_configs")}
|
||||
assert {"mode", "provider", "city_latitude", "cities"} <= weather_widget_columns
|
||||
assert "battery_widget_configs" in inspector.get_table_names() # migration 25
|
||||
battery_widget_columns = {c["name"] for c in inspector.get_columns("battery_widget_configs")}
|
||||
assert "mode" in battery_widget_columns
|
||||
|
||||
|
||||
# --- widget system backfill (migration 16 + _ensure_widgets_backfilled) ---
|
||||
@@ -192,22 +195,24 @@ def test_migration_16_raw_sql_path_applies_to_an_existing_pre_widget_database(db
|
||||
with db_module.engine.begin() as conn:
|
||||
# static_widget_configs/text_widget_configs are migration 20/21
|
||||
# tables, saved_layouts/saved_layout_widgets/saved_layout_
|
||||
# sources/saved_layout_button_actions are migration 23's, and
|
||||
# weather_widget_configs is migration 24's (all post-16, like the
|
||||
# sources/saved_layout_button_actions are migration 23's,
|
||||
# weather_widget_configs is migration 24's, and
|
||||
# battery_widget_configs is migration 25's (all post-16, like the
|
||||
# rest of this list) -- dropped here too so a real version-15
|
||||
# database is what's actually being simulated, not "version 15
|
||||
# plus tables that wouldn't exist yet". Harmless to omit as long
|
||||
# as no migration after the one that creates a table also ALTERs
|
||||
# or re-CREATEs it (that's what let a create_all-based migration
|
||||
# go unlisted safely so far), but static_widget_configs/
|
||||
# text_widget_configs/weather_widget_configs all use a raw
|
||||
# CREATE TABLE (not create_all -- see migration 20's own
|
||||
# docstring on why), so an already-present one is a real "table
|
||||
# already exists" collision, not a silent no-op.
|
||||
# text_widget_configs/weather_widget_configs/battery_widget_
|
||||
# configs all use a raw CREATE TABLE (not create_all -- see
|
||||
# migration 20's own docstring on why), so an already-present one
|
||||
# is a real "table already exists" collision, not a silent no-op.
|
||||
for table in ("frame_button_actions", "whiteboard_widget_configs", "task_widget_configs", "frame_task_lists",
|
||||
"calendar_widget_configs", "photo_widget_configs", "static_widget_configs",
|
||||
"text_widget_configs", "saved_layout_button_actions", "saved_layout_sources",
|
||||
"saved_layout_widgets", "saved_layouts", "weather_widget_configs", "widgets"):
|
||||
"saved_layout_widgets", "saved_layouts", "weather_widget_configs",
|
||||
"battery_widget_configs", "widgets"):
|
||||
conn.execute(text(f"DROP TABLE {table}"))
|
||||
conn.execute(text("DROP TABLE frame_calendars"))
|
||||
conn.execute(text(
|
||||
@@ -275,11 +280,11 @@ def test_migration_17_and_18_extract_tasks_into_a_standalone_multi_list_widget(d
|
||||
calendar_key columns either."""
|
||||
with db_module.engine.begin() as conn:
|
||||
# static_widget_configs/text_widget_configs/saved_layout_*/
|
||||
# weather_widget_configs dropped too -- see the comment on the
|
||||
# identical setup in
|
||||
# weather_widget_configs/battery_widget_configs dropped too --
|
||||
# see the comment on the identical setup in
|
||||
# test_migration_16_raw_sql_path_applies_to_an_existing_pre_widget_database above (migrations
|
||||
# 20/21/23/24's raw CREATE TABLE collides with an already-present table
|
||||
# otherwise, since this test replays 17 through 24 and none of
|
||||
# 20/21/23/24/25's raw CREATE TABLE collides with an already-present table
|
||||
# otherwise, since this test replays 17 through 25 and none of
|
||||
# these tables would really exist yet at a genuine pre-migration-17
|
||||
# schema_version).
|
||||
conn.execute(text("DROP TABLE task_widget_configs"))
|
||||
@@ -292,6 +297,7 @@ def test_migration_17_and_18_extract_tasks_into_a_standalone_multi_list_widget(d
|
||||
conn.execute(text("DROP TABLE saved_layout_widgets"))
|
||||
conn.execute(text("DROP TABLE saved_layouts"))
|
||||
conn.execute(text("DROP TABLE weather_widget_configs"))
|
||||
conn.execute(text("DROP TABLE battery_widget_configs"))
|
||||
conn.execute(text(
|
||||
"CREATE TABLE calendar_widget_configs ("
|
||||
"widget_id INTEGER PRIMARY KEY REFERENCES widgets(id) ON DELETE CASCADE, "
|
||||
@@ -393,7 +399,8 @@ def test_frame_calendars_rekey_attaches_existing_rows_to_their_calendar_widget(d
|
||||
for table in ("frame_button_actions", "whiteboard_widget_configs", "task_widget_configs", "frame_task_lists",
|
||||
"calendar_widget_configs", "photo_widget_configs", "static_widget_configs",
|
||||
"text_widget_configs", "saved_layout_button_actions", "saved_layout_sources",
|
||||
"saved_layout_widgets", "saved_layouts", "weather_widget_configs", "widgets"):
|
||||
"saved_layout_widgets", "saved_layouts", "weather_widget_configs",
|
||||
"battery_widget_configs", "widgets"):
|
||||
conn.execute(text(f"DROP TABLE {table}"))
|
||||
conn.execute(text("DROP TABLE frame_calendars"))
|
||||
conn.execute(text(
|
||||
|
||||
Reference in New Issue
Block a user