'Retrieve usercodes of node.'

@ha.callback
def get(self, request, node_id):

    nodeid = int(node_id)
    hass = request.app['hass']
    network = hass.data.get(const.DATA_NETWORK)
    node = network.nodes.get(nodeid)
    if (node is None):
        return self.json_message('Node    not    found', HTTP_NOT_FOUND)
    usercodes = {}
    if (not node.has_command_class(const.COMMAND_CLASS_USER_CODE)):
        return self.json(usercodes)
    for value in node.get_values(class_id=const.COMMAND_CLASS_USER_CODE).values():
        if (value.genre != const.GENRE_USER):
            continue
        usercodes[value.index] = {'code': value.data, 'label': value.label, 'length': len(value.data)}
    return self.json(usercodes)
