Bugfix: Zwave set_config_parameter failed when config list contained int (#13301)
* Cast list and bool options to STR * Add button options to STR * Add TYPE_BUTTON to value types * Adjust comparison * Remove Logging * Remove Empty line * Update tests * Update tests * Mistake
This commit is contained in:
parent
3fa080a795
commit
5c4529d044
3 changed files with 44 additions and 4 deletions
|
@ -442,9 +442,16 @@ def setup(hass, config):
|
|||
if value.index != param:
|
||||
continue
|
||||
if value.type in [const.TYPE_LIST, const.TYPE_BOOL]:
|
||||
value.data = selection
|
||||
_LOGGER.info("Setting config list parameter %s on Node %s "
|
||||
"with selection %s", param, node_id,
|
||||
value.data = str(selection)
|
||||
_LOGGER.info("Setting config parameter %s on Node %s "
|
||||
"with list/bool selection %s", param, node_id,
|
||||
str(selection))
|
||||
return
|
||||
if value.type == const.TYPE_BUTTON:
|
||||
network.manager.pressButton(value.value_id)
|
||||
network.manager.releaseButton(value.value_id)
|
||||
_LOGGER.info("Setting config parameter %s on Node %s "
|
||||
"with button selection %s", param, node_id,
|
||||
selection)
|
||||
return
|
||||
value.data = int(selection)
|
||||
|
|
|
@ -327,6 +327,7 @@ TYPE_DECIMAL = "Decimal"
|
|||
TYPE_INT = "Int"
|
||||
TYPE_LIST = "List"
|
||||
TYPE_STRING = "String"
|
||||
TYPE_BUTTON = "Button"
|
||||
|
||||
DISC_COMMAND_CLASS = "command_class"
|
||||
DISC_COMPONENT = "component"
|
||||
|
|
|
@ -995,8 +995,21 @@ class TestZWaveServices(unittest.TestCase):
|
|||
type=const.TYPE_LIST,
|
||||
data_items=['item1', 'item2', 'item3'],
|
||||
)
|
||||
value_list_int = MockValue(
|
||||
index=15,
|
||||
command_class=const.COMMAND_CLASS_CONFIGURATION,
|
||||
type=const.TYPE_LIST,
|
||||
data_items=['1', '2', '3'],
|
||||
)
|
||||
value_button = MockValue(
|
||||
index=14,
|
||||
command_class=const.COMMAND_CLASS_CONFIGURATION,
|
||||
type=const.TYPE_BUTTON,
|
||||
)
|
||||
node = MockNode(node_id=14)
|
||||
node.get_values.return_value = {12: value, 13: value_list}
|
||||
node.get_values.return_value = {12: value, 13: value_list,
|
||||
14: value_button,
|
||||
15: value_list_int}
|
||||
self.zwave_network.nodes = {14: node}
|
||||
|
||||
self.hass.services.call('zwave', 'set_config_parameter', {
|
||||
|
@ -1008,6 +1021,15 @@ class TestZWaveServices(unittest.TestCase):
|
|||
|
||||
assert value_list.data == 'item3'
|
||||
|
||||
self.hass.services.call('zwave', 'set_config_parameter', {
|
||||
const.ATTR_NODE_ID: 14,
|
||||
const.ATTR_CONFIG_PARAMETER: 15,
|
||||
const.ATTR_CONFIG_VALUE: 3,
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert value_list_int.data == '3'
|
||||
|
||||
self.hass.services.call('zwave', 'set_config_parameter', {
|
||||
const.ATTR_NODE_ID: 14,
|
||||
const.ATTR_CONFIG_PARAMETER: 12,
|
||||
|
@ -1017,6 +1039,16 @@ class TestZWaveServices(unittest.TestCase):
|
|||
|
||||
assert value.data == 7
|
||||
|
||||
self.hass.services.call('zwave', 'set_config_parameter', {
|
||||
const.ATTR_NODE_ID: 14,
|
||||
const.ATTR_CONFIG_PARAMETER: 14,
|
||||
const.ATTR_CONFIG_VALUE: True,
|
||||
})
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert self.zwave_network.manager.pressButton.called
|
||||
assert self.zwave_network.manager.releaseButton.called
|
||||
|
||||
self.hass.services.call('zwave', 'set_config_parameter', {
|
||||
const.ATTR_NODE_ID: 14,
|
||||
const.ATTR_CONFIG_PARAMETER: 19,
|
||||
|
|
Loading…
Add table
Reference in a new issue