Correct Quality Issues

- Fix: Decrease log message severity in `feature.py`.
- Fix: Rename `_set_range_cli` to `_set_range_from_str`.
- Add: Basic tests for string to Motion Range value converter function.
This commit is contained in:
Ryan Nitcher
2024-12-06 19:09:30 -07:00
parent 28080067db
commit 5dd71dde39
4 changed files with 53 additions and 6 deletions

View File

@@ -279,7 +279,7 @@ class Feature:
if self.type == Feature.Type.Choice:
if not isinstance(choices, list):
_LOGGER.critical(
_LOGGER.error(
"Choices are not properly defined for %s (%s). Type: <%s> Value: %s", # noqa: E501
self.name,
self.id,

View File

@@ -124,7 +124,7 @@ class Motion(IotModule):
name="Motion Sensor Range",
icon="mdi:motion-sensor",
attribute_getter="range",
attribute_setter="_set_range_cli",
attribute_setter="_set_range_from_str",
type=Feature.Type.Choice,
choices_getter="ranges",
category=Feature.Category.Config,
@@ -336,7 +336,7 @@ class Motion(IotModule):
)
return Range[value]
async def _set_range_cli(self, input: str) -> dict:
async def _set_range_from_str(self, input: str) -> dict:
value = self._parse_range_value(input)
return await self.set_range(range=value)