Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node.async_set_raw_config_parameter_value command #780

Merged
merged 16 commits into from
Oct 24, 2023
Prev Previous commit
Next Next commit
fix
  • Loading branch information
raman325 committed Oct 19, 2023
commit c025471f6aa2de9ab8beaf2e936a0b0a01426b80
28 changes: 13 additions & 15 deletions test/model/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from zwave_js_server.const import (
INTERVIEW_FAILED,
CommandClass,
CommandStatus,
NodeStatus,
PowerLevel,
ProtocolDataRate,
Expand Down Expand Up @@ -48,6 +49,7 @@
from zwave_js_server.model.value import (
ConfigurationValue,
ConfigurationValueFormat,
SetConfigParameterResult,
get_value_id_str,
)

Expand Down Expand Up @@ -2515,7 +2517,9 @@ async def test_set_raw_config_parameter_value(
{},
)

assert await node.async_set_raw_config_parameter_value(1, 101, 1) is None
assert await node.async_set_raw_config_parameter_value(
1, 101, 1
) == SetConfigParameterResult(CommandStatus.QUEUED)

assert len(ack_commands) == 1

Expand All @@ -2531,12 +2535,9 @@ async def test_set_raw_config_parameter_value(
"messageId": uuid4,
}

assert (
await node.async_set_raw_config_parameter_value(
"Disable", "Stay Awake in Battery Mode"
)
is None
)
assert await node.async_set_raw_config_parameter_value(
"Disable", "Stay Awake in Battery Mode"
) == SetConfigParameterResult(CommandStatus.QUEUED)

assert len(ack_commands) == 2

Expand All @@ -2551,12 +2552,9 @@ async def test_set_raw_config_parameter_value(
"messageId": uuid4,
}

assert (
await node.async_set_raw_config_parameter_value(
1, 2, value_size=1, value_format=ConfigurationValueFormat.SIGNED_INTEGER
)
is None
)
assert await node.async_set_raw_config_parameter_value(
1, 2, value_size=1, value_format=ConfigurationValueFormat.SIGNED_INTEGER
) == SetConfigParameterResult(CommandStatus.QUEUED)

assert len(ack_commands) == 3

Expand Down Expand Up @@ -2606,8 +2604,8 @@ async def test_supervision_result(inovelli_switch: node_pkg.Node, uuid4, mock_co
)

result = await node.async_set_raw_config_parameter_value(1, 1)
assert result.status is SupervisionStatus.WORKING
duration = result.remaining_duration
assert result.result.status is SupervisionStatus.WORKING
duration = result.result.remaining_duration
assert duration.unit == "default"


Expand Down
5 changes: 4 additions & 1 deletion zwave_js_server/model/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ConfigurationValue,
ConfigurationValueFormat,
SetConfigParameterResult,
SupervisionResult,
Value,
)

Expand Down Expand Up @@ -346,4 +347,6 @@ async def async_set_raw_config_parameter_value(
if (result := data.get("result")) is None:
return SetConfigParameterResult(CommandStatus.ACCEPTED)

return SetConfigParameterResult(CommandStatus.ACCEPTED, result)
return SetConfigParameterResult(
CommandStatus.ACCEPTED, SupervisionResult(result)
)