Skip to content

Commit

Permalink
Remove validation for async_set_raw_config_parameter_value
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Oct 3, 2024
1 parent f1c7a1a commit 90cefd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
50 changes: 7 additions & 43 deletions zwave_js_server/model/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,44 +298,8 @@ async def async_set_raw_config_parameter_value(
property_key: int | None = None,
value_size: Literal[1, 2, 4] | None = None,
value_format: ConfigurationValueFormat | None = None,
) -> tuple[Value, SetConfigParameterResult]:
) -> SetConfigParameterResult:
"""Send setRawConfigParameterValue."""
try:
zwave_value = next(
config_value
for config_value in self.get_configuration_values().values()
if property_
== (
config_value.property_name
if isinstance(property_, str)
else config_value.property_
)
and property_key == config_value.property_key
)
except StopIteration:
raise NotFoundError(
f"Configuration parameter with parameter {property_} and bitmask "
f"{property_key} on node {self} could not be found"
) from None

if not isinstance(new_value, str):
value = new_value
else:
try:
value = int(
next(
k
for k, v in zwave_value.metadata.states.items()
if v == new_value
)
)
except StopIteration:
raise NotFoundError(
f"Configuration parameter {zwave_value.value_id} does not have "
f"{new_value} as a valid state. If this is a valid call, you must "
"use the state key instead of the string."
) from None

if (value_size is not None and value_format is None) or (
value_size is None and value_format is not None
):
Expand All @@ -351,9 +315,9 @@ async def async_set_raw_config_parameter_value(
)

options = {
"value": value,
"parameter": zwave_value.property_,
"bitMask": zwave_value.property_key,
"value": new_value,
"parameter": property_,
"bitMask": property_key,
"valueSize": value_size,
"valueFormat": value_format,
}
Expand All @@ -365,11 +329,11 @@ async def async_set_raw_config_parameter_value(
)

if data is None:
return zwave_value, SetConfigParameterResult(CommandStatus.QUEUED)
return SetConfigParameterResult(CommandStatus.QUEUED)

if (result := data.get("result")) is None:
return zwave_value, SetConfigParameterResult(CommandStatus.ACCEPTED)
return SetConfigParameterResult(CommandStatus.ACCEPTED)

return zwave_value, SetConfigParameterResult(
return SetConfigParameterResult(
CommandStatus.ACCEPTED, SupervisionResult(result)
)
2 changes: 1 addition & 1 deletion zwave_js_server/model/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ async def async_set_raw_config_parameter_value(
property_key: int | None = None,
value_size: Literal[1, 2, 4] | None = None,
value_format: ConfigurationValueFormat | None = None,
) -> tuple[Value, SetConfigParameterResult | None]:
) -> SetConfigParameterResult:
"""Send setRawConfigParameterValue."""
return await self.endpoints[0].async_set_raw_config_parameter_value(
new_value, property_, property_key, value_size, value_format
Expand Down

0 comments on commit 90cefd6

Please sign in to comment.