Add missing alarm volume 'normal' (#899)

Also logs a warning in feature repr if value not in choices and fixes the returned string to be consistent with valid values.
This commit is contained in:
Teemu R 2024-05-07 10:38:09 +02:00 committed by GitHub
parent f063c83378
commit 50b5107f75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -180,7 +180,16 @@ class Feature:
if self.type == Feature.Type.Choice:
if not isinstance(choices, list) or value not in choices:
return f"Value {value} is not a valid choice ({self.id}): {choices}"
_LOGGER.warning(
"Invalid value for for choice %s (%s): %s not in %s",
self.name,
self.id,
value,
choices,
)
return (
f"{self.name} ({self.id}): invalid value '{value}' not in {choices}"
)
value = " ".join(
[f"*{choice}*" if choice == value else choice for choice in choices]
)

View File

@ -64,7 +64,7 @@ class AlarmModule(SmartModule):
attribute_setter="set_alarm_volume",
category=Feature.Category.Config,
type=Feature.Type.Choice,
choices=["low", "high"],
choices=["low", "normal", "high"],
)
)
self._add_feature(