mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Allow string values on zwave.set_node_value (#31061)
* Allow string values on zwave.set_node_value This allows for: * Accessing longer value_ids. In some cases, value ids in z-wave nodes are very large (17 digits in my case). Passing them as int does not seem to work well (python probably truncates the number), but passing them as string works fine * Changing color values, which are represented as hex string reformat test * update services.yaml with string set_node_value
This commit is contained in:
parent
1d3647e6a1
commit
eac1f029e5
@ -126,8 +126,8 @@ SET_CONFIG_PARAMETER_SCHEMA = vol.Schema(
|
|||||||
SET_NODE_VALUE_SCHEMA = vol.Schema(
|
SET_NODE_VALUE_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
|
vol.Required(const.ATTR_NODE_ID): vol.Coerce(int),
|
||||||
vol.Required(const.ATTR_VALUE_ID): vol.Coerce(int),
|
vol.Required(const.ATTR_VALUE_ID): vol.Any(vol.Coerce(int), cv.string),
|
||||||
vol.Required(const.ATTR_CONFIG_VALUE): vol.Coerce(int),
|
vol.Required(const.ATTR_CONFIG_VALUE): vol.Any(vol.Coerce(int), cv.string),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ set_node_value:
|
|||||||
node_id:
|
node_id:
|
||||||
description: Node id of the device to set the value on (integer).
|
description: Node id of the device to set the value on (integer).
|
||||||
value_id:
|
value_id:
|
||||||
description: Value id of the value to set (integer).
|
description: Value id of the value to set (integer or string).
|
||||||
value:
|
value:
|
||||||
description: Value to set (integer).
|
description: Value to set (integer or string).
|
||||||
|
|
||||||
refresh_node_value:
|
refresh_node_value:
|
||||||
description: Refresh the value for a given value_id on a Z-Wave device.
|
description: Refresh the value for a given value_id on a Z-Wave device.
|
||||||
|
@ -1797,6 +1797,31 @@ class TestZWaveServices(unittest.TestCase):
|
|||||||
|
|
||||||
assert self.zwave_network.nodes[14].values[12].data == 2
|
assert self.zwave_network.nodes[14].values[12].data == 2
|
||||||
|
|
||||||
|
def test_set_node_value_with_long_id_and_text_value(self):
|
||||||
|
"""Test zwave set_node_value service."""
|
||||||
|
value = MockValue(
|
||||||
|
index=87512398541236578,
|
||||||
|
command_class=const.COMMAND_CLASS_SWITCH_COLOR,
|
||||||
|
data="#ff0000",
|
||||||
|
)
|
||||||
|
node = MockNode(node_id=14, command_classes=[const.COMMAND_CLASS_SWITCH_COLOR])
|
||||||
|
node.values = {87512398541236578: value}
|
||||||
|
node.get_values.return_value = node.values
|
||||||
|
self.zwave_network.nodes = {14: node}
|
||||||
|
|
||||||
|
self.hass.services.call(
|
||||||
|
"zwave",
|
||||||
|
"set_node_value",
|
||||||
|
{
|
||||||
|
const.ATTR_NODE_ID: 14,
|
||||||
|
const.ATTR_VALUE_ID: "87512398541236578",
|
||||||
|
const.ATTR_CONFIG_VALUE: "#00ff00",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.hass.block_till_done()
|
||||||
|
|
||||||
|
assert self.zwave_network.nodes[14].values[87512398541236578].data == "#00ff00"
|
||||||
|
|
||||||
def test_refresh_node_value(self):
|
def test_refresh_node_value(self):
|
||||||
"""Test zwave refresh_node_value service."""
|
"""Test zwave refresh_node_value service."""
|
||||||
node = MockNode(
|
node = MockNode(
|
||||||
|
Loading…
Reference in New Issue
Block a user