From 9ce5b7e8a5a3dffff5c10639bf21086a201d4c85 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 2 Feb 2025 12:14:11 -0500 Subject: [PATCH] feat(hass): restrict input_text to percentage values --- .../homie/modules/home-assistant/frontend.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/configurations/homie/modules/home-assistant/frontend.nix b/configurations/homie/modules/home-assistant/frontend.nix index 45ba3792..19402795 100644 --- a/configurations/homie/modules/home-assistant/frontend.nix +++ b/configurations/homie/modules/home-assistant/frontend.nix @@ -124,12 +124,16 @@ in { } ]; - # TODO: restrict to 0-100 - config.input_text = { - bathroom_light_brightness = { - name = "BathroomLightBrightness"; - pattern = "[0-9]*"; + config.input_text = let + mkPercentInput = name: { + inherit name; + # restricts to 0-100 + pattern = "^(0|[1-9][0-9]?|100)$"; + initial = "0"; + max = 3; }; + in { + bathroom_light_brightness = mkPercentInput "BathroomLightBrightness"; }; lovelaceConfig = {