mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Prevent Homeassistant to create a segfault with OZW (#5085)
This commit is contained in:
parent
a7cc7ce476
commit
5c006cd2d2
@ -462,11 +462,29 @@ def setup(hass, config):
|
|||||||
node_id = service.data.get(const.ATTR_NODE_ID)
|
node_id = service.data.get(const.ATTR_NODE_ID)
|
||||||
node = NETWORK.nodes[node_id]
|
node = NETWORK.nodes[node_id]
|
||||||
param = service.data.get(const.ATTR_CONFIG_PARAMETER)
|
param = service.data.get(const.ATTR_CONFIG_PARAMETER)
|
||||||
value = service.data.get(const.ATTR_CONFIG_VALUE)
|
selection = service.data.get(const.ATTR_CONFIG_VALUE)
|
||||||
size = service.data.get(const.ATTR_CONFIG_SIZE, 2)
|
size = service.data.get(const.ATTR_CONFIG_SIZE, 2)
|
||||||
node.set_config_param(param, value, size)
|
i = 0
|
||||||
_LOGGER.info("Setting config parameter %s on Node %s "
|
for value in (
|
||||||
"with value %s and size=%s", param, node_id, value, size)
|
node.get_values(class_id=const.COMMAND_CLASS_CONFIGURATION)
|
||||||
|
.values()):
|
||||||
|
if value.index == param and value.type == const.TYPE_LIST:
|
||||||
|
_LOGGER.debug('Values for parameter %s: %s', param,
|
||||||
|
value.data_items)
|
||||||
|
i = len(value.data_items) - 1
|
||||||
|
if i == 0:
|
||||||
|
node.set_config_param(param, selection, size)
|
||||||
|
else:
|
||||||
|
if selection > i:
|
||||||
|
_LOGGER.info('Config parameter selection does not exist!'
|
||||||
|
' Please check zwcfg_[home_id].xml in'
|
||||||
|
' your homeassistant config directory. '
|
||||||
|
' Available selections are 0 to %s', i)
|
||||||
|
return
|
||||||
|
node.set_config_param(param, selection, size)
|
||||||
|
_LOGGER.info('Setting config parameter %s on Node %s '
|
||||||
|
'with selection %s and size=%s', param, node_id,
|
||||||
|
selection, size)
|
||||||
|
|
||||||
def print_config_parameter(service):
|
def print_config_parameter(service):
|
||||||
"""Print a config parameter from a node."""
|
"""Print a config parameter from a node."""
|
||||||
|
@ -302,3 +302,4 @@ TYPE_BYTE = "Byte"
|
|||||||
TYPE_BOOL = "Bool"
|
TYPE_BOOL = "Bool"
|
||||||
TYPE_DECIMAL = "Decimal"
|
TYPE_DECIMAL = "Decimal"
|
||||||
TYPE_INT = "Int"
|
TYPE_INT = "Int"
|
||||||
|
TYPE_LIST = "List"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user