diff --git a/docs/item-schema.md b/docs/item-schema.md index 8615a80..58c305e 100644 --- a/docs/item-schema.md +++ b/docs/item-schema.md @@ -120,7 +120,7 @@ "use24Hour": false, "topOfHourAnnounce": true, "alarmEnabled": false, - "alarmTime": "" + "alarmTime": "12:00 AM" } ``` @@ -137,7 +137,8 @@ - `use24Hour`: boolean (or `on/off` in updates), default `false`. - `topOfHourAnnounce`: boolean (or `on/off` in updates), default `true`. - `alarmEnabled`: boolean (or `on/off` in updates), default `false`. -- `alarmTime`: blank when unset; when set, accepts `HH:MM` (24-hour mode) or `H:MM AM/PM` (12-hour mode). +- `alarmTime`: default `12:00 AM`; accepts `HH:MM` (24-hour mode) or `H:MM AM/PM` (12-hour mode). +- UI visibility: `alarmTime` is shown only when `alarmEnabled=true` (`visibleWhen` metadata). - Global defaults: `useSound=none`, `emitSound=sounds/clock.ogg`. - Clock speech announcement audio is emitted via `item_clock_announce` packets using `/sounds/clock/el640/*.ogg`. diff --git a/docs/item-types.md b/docs/item-types.md index f08093a..9ee5c91 100644 --- a/docs/item-types.md +++ b/docs/item-types.md @@ -103,7 +103,7 @@ This is behavior-focused documentation for item types and their defaults. - `use24Hour=false` - `topOfHourAnnounce=true` - `alarmEnabled=false` - - `alarmTime=""` + - `alarmTime="12:00 AM"` - Global: - `useSound=none` - `emitSound=sounds/clock.ogg` @@ -121,6 +121,7 @@ This is behavior-focused documentation for item types and their defaults. - `topOfHourAnnounce`: boolean or on/off style input - `alarmEnabled`: boolean or on/off style input - `alarmTime`: `HH:MM` when `use24Hour=true`, otherwise `H:MM AM/PM` + - Visible only when `alarmEnabled=true` (`visibleWhen: {"alarmEnabled": true}`) ### Audio - Spoken clock assets live under `client/public/sounds/clock/el640/`. diff --git a/server/app/items/types/clock/definition.py b/server/app/items/types/clock/definition.py index a916316..3d7d727 100644 --- a/server/app/items/types/clock/definition.py +++ b/server/app/items/types/clock/definition.py @@ -67,7 +67,7 @@ DEFAULT_PARAMS: dict = { "use24Hour": False, "topOfHourAnnounce": True, "alarmEnabled": False, - "alarmTime": "", + "alarmTime": "12:00 AM", } PARAM_KEYS: tuple[str, ...] = ("timeZone", "use24Hour", "topOfHourAnnounce", "alarmEnabled", "alarmTime") @@ -81,5 +81,6 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = { "valueType": "text", "tooltip": "Alarm time. Uses 24-hour HH:MM when 24 hour format is on, otherwise H:MM AM/PM.", "maxLength": 8, + "visibleWhen": {"alarmEnabled": True}, }, } diff --git a/server/tests/test_item_use_cooldown.py b/server/tests/test_item_use_cooldown.py index 9db039e..d2ff7ac 100644 --- a/server/tests/test_item_use_cooldown.py +++ b/server/tests/test_item_use_cooldown.py @@ -286,8 +286,9 @@ async def test_clock_timezone_update_validates(monkeypatch: pytest.MonkeyPatch) client, json.dumps({"type": "item_update", "itemId": item.id, "params": {"alarmEnabled": True}}), ) - assert send_payloads[-1].ok is False - assert "alarmtime must be a valid time" in send_payloads[-1].message.lower() + assert send_payloads[-1].ok is True + assert item.params.get("alarmEnabled") is True + assert item.params.get("alarmTime") == "12:00 AM" await server._handle_message( client,